From f85906b67920c0e69599c6e59d843274aef152be Mon Sep 17 00:00:00 2001 From: dearblue Date: Thu, 21 May 2020 21:27:51 +0900 Subject: Remove `patch_irep()` in `mruby-eval` - It can now deal with operands in the range of `OP_EXT*`. - It can now call the same method as the variable name without arguments. ```ruby def a "Safe!" end a = "Auto!" eval "a()" # call method `a` ``` --- mrbgems/mruby-eval/test/eval.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mrbgems/mruby-eval/test/eval.rb') 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 -- cgit v1.2.3