mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (top_using): remove Kernel#using, and add main.using instead.
* test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b0c8aeeb9c
commit
10ba3bdd53
3 changed files with 34 additions and 7 deletions
|
@ -474,10 +474,32 @@ class TestRefinement < Test::Unit::TestCase
|
|||
assert_equal("c", c.class_eval { 123.foo })
|
||||
end
|
||||
|
||||
def test_kernel_using_class
|
||||
c = Class.new
|
||||
assert_raise(TypeError) do
|
||||
using c
|
||||
def test_main_using
|
||||
assert_in_out_err([], <<-INPUT, %w(:C :M), [])
|
||||
class C
|
||||
def foo
|
||||
:C
|
||||
end
|
||||
end
|
||||
|
||||
module M
|
||||
refine C do
|
||||
def foo
|
||||
:M
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
c = C.new
|
||||
p c.foo
|
||||
using M
|
||||
p c.foo
|
||||
INPUT
|
||||
end
|
||||
|
||||
def test_no_kernel_using
|
||||
assert_raise(NoMethodError) do
|
||||
using Module.new
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue