[前][次][番号順一覧][スレッド一覧]

ruby-changes:25562

From: shugo <ko1@a...>
Date: Sun, 11 Nov 2012 15:16:39 +0900 (JST)
Subject: [ruby-changes:25562] shugo:r37619 (trunk): * eval.c (top_using): remove Kernel#using, and add main.using instead.

shugo	2012-11-11 15:14:16 +0900 (Sun, 11 Nov 2012)

  New Revision: 37619

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37619

  Log:
    * eval.c (top_using): remove Kernel#using, and add main.using instead.
    
    * test/ruby/test_refinement.rb: related test.

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/test/ruby/test_refinement.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37618)
+++ ChangeLog	(revision 37619)
@@ -1,3 +1,9 @@
+Sun Nov 11 15:12:18 2012  Shugo Maeda  <shugo@r...>
+
+	* 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  <shugo@r...>
 
 	* eval.c (rb_using_refinement, rb_mod_using, f_using): clear method
Index: eval.c
===================================================================
--- eval.c	(revision 37618)
+++ eval.c	(revision 37619)
@@ -1386,7 +1386,7 @@
  */
 
 static VALUE
-f_using(VALUE self, VALUE module)
+top_using(VALUE self, VALUE module)
 {
     NODE *cref = rb_vm_cref();
 
@@ -1593,9 +1593,8 @@
     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_singleton_method(rb_vm_top_self(), "using", top_using, 1);
 
-    rb_define_global_function("using", f_using, 1);
-
     rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
 
     rb_define_global_function("trace_var", rb_f_trace_var, -1);	/* in variable.c */
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 37618)
+++ test/ruby/test_refinement.rb	(revision 37619)
@@ -474,10 +474,32 @@
     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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]