diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-31 11:45:45 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-31 11:45:45 +0900 |
| commit | 2c3530ff10f477c09145fc7ab79cd87432acccaf (patch) | |
| tree | abe38a6c48e7fc9d560ee85131fda77a24c693c7 /mrbgems/mruby-proc-ext/test/proc.rb | |
| parent | d1e755df0fd86e349107334594595e1a5f8f6ac1 (diff) | |
| parent | bf6b1dfe216976f1adb7f41a74f20339fedcbec8 (diff) | |
| download | mruby-2c3530ff10f477c09145fc7ab79cd87432acccaf.tar.gz mruby-2c3530ff10f477c09145fc7ab79cd87432acccaf.zip | |
Merge pull request #1985 from take-cheeze/cfunc_with_env
Add API to define cfunc Proc with userdata.
Diffstat (limited to 'mrbgems/mruby-proc-ext/test/proc.rb')
| -rw-r--r-- | mrbgems/mruby-proc-ext/test/proc.rb | 23 |
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 |
