ruby-changes:30895
From: ko1 <ko1@a...>
Date: Thu, 19 Sep 2013 14:30:11 +0900 (JST)
Subject: [ruby-changes:30895] ko1:r42974 (trunk): * include/ruby/ruby.h: make Symbol objects frozen.
ko1 2013-09-19 14:30:02 +0900 (Thu, 19 Sep 2013) New Revision: 42974 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42974 Log: * include/ruby/ruby.h: make Symbol objects frozen. [Feature #8906] I want to freeze this good day, too. * test/ruby/test_eval.rb: catch up this change. * test/ruby/test_symbol.rb: add a test to check frozen symbols. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h trunk/test/ruby/test_eval.rb trunk/test/ruby/test_symbol.rb Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 42973) +++ include/ruby/ruby.h (revision 42974) @@ -1247,7 +1247,7 @@ struct RBignum { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1247 RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT; \ } while (0) -#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)))) +#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)||SYMBOL_P(x)))) #define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE) #if USE_RGENGC Index: ChangeLog =================================================================== --- ChangeLog (revision 42973) +++ ChangeLog (revision 42974) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Sep 19 14:12:02 2013 Koichi Sasada <ko1@a...> + + * include/ruby/ruby.h: make Symbol objects frozen. + [Feature #8906] + I want to freeze this good day, too. + + * test/ruby/test_eval.rb: catch up this change. + + * test/ruby/test_symbol.rb: add a test to check frozen symbols. + Thu Sep 19 09:11:33 2013 Eric Hodel <drbrain@s...> * NEWS: Update for RDoc 4.1.0.preview.1 and RubyGems 2.2.0.preview.1 Index: test/ruby/test_eval.rb =================================================================== --- test/ruby/test_eval.rb (revision 42973) +++ test/ruby/test_eval.rb (revision 42974) @@ -128,7 +128,7 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L128 end def forall_TYPE - objects = [Object.new, [], nil, true, false, :sym] # TODO: check + objects = [Object.new, [], nil, true, false] # TODO: check objects.each do |obj| obj.instance_variable_set :@ivar, 12 yield obj Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 42973) +++ test/ruby/test_symbol.rb (revision 42974) @@ -198,4 +198,12 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L198 def test_singleton_method assert_raise(TypeError) { a = :foo; def a.foo; end } end + + def test_frozen_symbol + assert_equal(true, :foo.frozen?) + assert_equal(true, :each.frozen?) + assert_equal(true, :+.frozen?) + assert_equal(true, "foo#{Time.now.to_i}".to_sym.frozen?) + assert_equal(true, :foo.to_sym.frozen?) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/