mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
92cd831366
commit
1e27eda2fa
4 changed files with 20 additions and 2 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Thu Sep 19 14:12:02 2013 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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@segment7.net>
|
||||
|
||||
* NEWS: Update for RDoc 4.1.0.preview.1 and RubyGems 2.2.0.preview.1
|
||||
|
|
|
@ -1247,7 +1247,7 @@ struct RBignum {
|
|||
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
|
||||
|
|
|
@ -128,7 +128,7 @@ class TestEval < Test::Unit::TestCase
|
|||
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
|
||||
|
|
|
@ -198,4 +198,12 @@ class TestSymbol < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue