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

ruby-changes:21886

From: mame <ko1@a...>
Date: Sat, 3 Dec 2011 20:52:19 +0900 (JST)
Subject: [ruby-changes:21886] mame:r33935 (trunk): * variable.c (set_const_visibility): Module#private_constant has

mame	2011-12-03 20:52:08 +0900 (Sat, 03 Dec 2011)

  New Revision: 33935

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

  Log:
    * variable.c (set_const_visibility): Module#private_constant has
      changed the visibility of only the first argument.  Now it changes
      all of them.  [ruby-list:48558]
    
    * test/ruby/test_module.rb: add a test for above.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
    trunk/variable.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33934)
+++ ChangeLog	(revision 33935)
@@ -1,3 +1,11 @@
+Sat Dec  3 20:43:14 2011  Yusuke Endoh  <mame@t...>
+
+	* variable.c (set_const_visibility): Module#private_constant has
+	  changed the visibility of only the first argument.  Now it changes
+	  all of them.  [ruby-list:48558]
+
+	* test/ruby/test_module.rb: add a test for above.
+
 Sat Dec  3 07:17:29 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* Makefile.in (CFLAGS): append ARCH_FLAG.
Index: variable.c
===================================================================
--- variable.c	(revision 33934)
+++ variable.c	(revision 33935)
@@ -2119,7 +2119,7 @@
 	}
 	if (RCLASS_CONST_TBL(mod) && st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) {
 	    ((rb_const_entry_t*)v)->flag = flag;
-	    return;
+	    continue;
 	}
 	rb_name_error(id, "constant %s::%s not defined", rb_class2name(mod), rb_id2name(id));
     }
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 33934)
+++ test/ruby/test_module.rb	(revision 33935)
@@ -1070,6 +1070,19 @@
     assert_raise(NameError) { c::FOO }
   end
 
+  def test_private_constant2
+    c = Class.new
+    c.const_set(:FOO, "foo")
+    c.const_set(:BAR, "bar")
+    assert_equal("foo", c::FOO)
+    assert_equal("bar", c::BAR)
+    c.private_constant(:FOO, :BAR)
+    assert_raise(NameError) { c::FOO }
+    assert_raise(NameError) { c::BAR }
+    assert_equal("foo", c.class_eval("FOO"))
+    assert_equal("bar", c.class_eval("BAR"))
+  end
+
   class PrivateClass
   end
   private_constant :PrivateClass

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

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