summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-proc-ext/test/proc.rb
diff options
context:
space:
mode:
authortake_cheeze <[email protected]>2014-03-31 09:50:28 +0900
committertake_cheeze <[email protected]>2014-03-31 10:01:17 +0900
commitbf6b1dfe216976f1adb7f41a74f20339fedcbec8 (patch)
tree15901b85b1c8a4b242384e0a12a4c9a42a5c1385 /mrbgems/mruby-proc-ext/test/proc.rb
parent3eb3c99a6a5aa0fdcfe6127248e8e16b42c35d05 (diff)
downloadmruby-bf6b1dfe216976f1adb7f41a74f20339fedcbec8.tar.gz
mruby-bf6b1dfe216976f1adb7f41a74f20339fedcbec8.zip
Add API to define cfunc Proc with userdata.
The APIs are defined in mruby-proc-ext so include it before using this API. See mruby-proc-ext's test code for usage. This should resolve #1794.
Diffstat (limited to 'mrbgems/mruby-proc-ext/test/proc.rb')
-rw-r--r--mrbgems/mruby-proc-ext/test/proc.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/mrbgems/mruby-proc-ext/test/proc.rb b/mrbgems/mruby-proc-ext/test/proc.rb
index ef8b7f31c..f5aacd490 100644
--- a/mrbgems/mruby-proc-ext/test/proc.rb
+++ b/mrbgems/mruby-proc-ext/test/proc.rb
@@ -46,3 +46,26 @@ end
assert('Kernel#proc') do
assert_true !proc{|a|}.lambda?
end
+
+assert('mrb_proc_new_cfunc_with_env') do
+ ProcExtTest.mrb_proc_new_cfunc_with_env(:test)
+ ProcExtTest.mrb_proc_new_cfunc_with_env(:mruby)
+
+ t = ProcExtTest.new
+
+ assert_equal :test, t.test
+ assert_equal :mruby, t.mruby
+end
+
+assert('mrb_cfunc_env_get') do
+ ProcExtTest.mrb_cfunc_env_get :get_int, [0, 1, 2]
+
+ t = ProcExtTest.new
+
+ assert_raise(TypeError) { t.cfunc_without_env }
+
+ assert_raise(IndexError) { t.get_int(-1) }
+ assert_raise(IndexError) { t.get_int(3) }
+
+ assert_equal 1, t.get_int(1)
+end