diff --git a/ChangeLog b/ChangeLog index e1587dec9b..5c9e9f3482 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Nov 11 15:12:18 2012 Shugo Maeda + + * eval.c (top_using): remove Kernel#using, and add main.using instead. + + * test/ruby/test_refinement.rb: related test. + Sun Nov 11 13:41:01 2012 Shugo Maeda * eval.c (rb_using_refinement, rb_mod_using, f_using): clear method diff --git a/eval.c b/eval.c index f7c0a8a83b..9288917b27 100644 --- a/eval.c +++ b/eval.c @@ -1386,7 +1386,7 @@ top_include(int argc, VALUE *argv, VALUE self) */ static VALUE -f_using(VALUE self, VALUE module) +top_using(VALUE self, VALUE module) { NODE *cref = rb_vm_cref(); @@ -1593,8 +1593,7 @@ Init_eval(void) rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1); rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1); - - rb_define_global_function("using", f_using, 1); + rb_define_singleton_method(rb_vm_top_self(), "using", top_using, 1); rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1); diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 450a308839..9343f543f2 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -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