From bdb8607cb7549f8555fed781392231ead86d984b Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 8 Dec 2012 13:35:12 +0000 Subject: * eval.c (top_using): raise a RuntimeError if using is called in a module definition or a method definition. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_refinement.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 0d934d737e..016aa15f19 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -624,6 +624,33 @@ class TestRefinement < Test::Unit::TestCase end end + def test_using_in_module + assert_raise(RuntimeError) do + eval(<<-EOF, TOPLEVEL_BINDING) + $main = self + module M + end + module M2 + $main.send(:using, M) + end + EOF + end + end + + def test_using_in_method + assert_raise(RuntimeError) do + eval(<<-EOF, TOPLEVEL_BINDING) + $main = self + module M + end + def call_using_in_method + $main.send(:using, M) + end + call_using_in_method + EOF + end + end + private def eval_using(mod, s) -- cgit v1.2.3