aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 07:15:18 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 07:15:18 +0000
commitd622818377ac5fc255bf9acb7da278b245e76389 (patch)
treee1aabedd0e97ed66468be5f3ca79e3016f144af5 /test
parentc837fe405611cc24faa88f677bd186978fdc97ec (diff)
downloadruby-d622818377ac5fc255bf9acb7da278b245e76389.tar.gz
* vm_eval.c (eval_string_with_cref): copy cref to limit the scope of
refienements in the eval string. [ruby-core:56329] [Bug #8722] * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index f1f5e9d3e5..ffecebd5e8 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -929,6 +929,38 @@ class TestRefinement < Test::Unit::TestCase
assert_equal("FooExt2#y Foo#y", FooFoo2ExtClient.invoke_y_on(foo))
end
+ def test_eval_scoping
+ assert_in_out_err([], <<-INPUT, ["HELLO WORLD", "dlrow olleh", "HELLO WORLD"], [])
+ module M
+ refine String do
+ def upcase
+ reverse
+ end
+ end
+ end
+
+ puts "hello world".upcase
+ puts eval(%{using M; "hello world".upcase})
+ puts "hello world".upcase
+ INPUT
+ end
+
+ def test_eval_with_binding_scoping
+ assert_in_out_err([], <<-INPUT, ["HELLO WORLD", "dlrow olleh", "HELLO WORLD"], [])
+ module M
+ refine String do
+ def upcase
+ reverse
+ end
+ end
+ end
+
+ puts "hello world".upcase
+ puts eval(%{using M; "hello world".upcase}, TOPLEVEL_BINDING)
+ puts eval(%{"hello world".upcase}, TOPLEVEL_BINDING)
+ INPUT
+ end
+
private
def eval_using(mod, s)