summaryrefslogtreecommitdiff
path: root/ext/-test-/exception/ensured.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-08 07:09:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-08 07:09:48 +0000
commit98932f5150c2e6e26976c9e20b34d79c645e6593 (patch)
tree43a9cfa2cf7e62ac78f8c055bada6b642ca6a780 /ext/-test-/exception/ensured.c
parent49c5a3da6f7d17cb7864eebc564533754725c31d (diff)
eval.c: preserve errinfo
* eval.c (rb_ensure): preserve errinfo accross ensure proc before JUMP_TAG(). [ruby-core:52022] [Bug #7802] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/exception/ensured.c')
-rw-r--r--ext/-test-/exception/ensured.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/-test-/exception/ensured.c b/ext/-test-/exception/ensured.c
new file mode 100644
index 0000000..365e1f4
--- /dev/null
+++ b/ext/-test-/exception/ensured.c
@@ -0,0 +1,25 @@
+#include <ruby.h>
+
+static VALUE
+begin(VALUE object)
+{
+ return rb_funcall(object, rb_intern("try_method"), 0);
+}
+
+static VALUE
+ensure(VALUE object)
+{
+ return rb_funcall(object, rb_intern("ensured_method"), 0);
+}
+
+static VALUE
+ensured(VALUE module, VALUE object)
+{
+ return rb_ensure(begin, object, ensure, object);
+}
+
+void
+Init_ensured(VALUE klass)
+{
+ rb_define_module_function(klass, "ensured", ensured, 1);
+}