diff options
| author | Hiroshi Mimaki <[email protected]> | 2020-06-05 12:42:56 +0900 |
|---|---|---|
| committer | Hiroshi Mimaki <[email protected]> | 2020-06-05 12:42:56 +0900 |
| commit | 81d340e0421daf39a8208a0181d6a54e726db134 (patch) | |
| tree | 18cefdd763a716dbd27c23bfdf98ffa2135f7624 /mrbgems/mruby-eval/test/eval.rb | |
| parent | f9d113f7647121f8578742a2a9ac256ece365e3f (diff) | |
| parent | 4e40169ed6d200918e542aa8d8e64634794e1864 (diff) | |
| download | mruby-81d340e0421daf39a8208a0181d6a54e726db134.tar.gz mruby-81d340e0421daf39a8208a0181d6a54e726db134.zip | |
Merge master.
Diffstat (limited to 'mrbgems/mruby-eval/test/eval.rb')
| -rw-r--r-- | mrbgems/mruby-eval/test/eval.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mrbgems/mruby-eval/test/eval.rb b/mrbgems/mruby-eval/test/eval.rb index 4930259c1..639ed68f9 100644 --- a/mrbgems/mruby-eval/test/eval.rb +++ b/mrbgems/mruby-eval/test/eval.rb @@ -130,3 +130,24 @@ Proc.new { foo } EOS } end + +assert('Calling the same method as the variable name') do + hoge = Object.new + def hoge.fuga + "Hit!" + end + assert_equal("Hit!") { fuga = "Miss!"; eval "hoge.fuga" } + assert_equal("Hit!") { fuga = "Miss!"; -> { eval "hoge.fuga" }.call } + assert_equal("Hit!") { -> { fuga = "Miss!"; eval "hoge.fuga" }.call } + assert_equal("Hit!") { fuga = "Miss!"; eval("-> { hoge.fuga }").call } +end + +assert('Access numbered parameter from eval') do + hoge = Object.new + def hoge.fuga(a, &b) + b.call(a) + end + assert_equal(6) { + hoge.fuga(3) { _1 + eval("_1") } + } +end |
