Skip to content

Commit 1e27eda

Browse files
committed
* 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
1 parent 92cd831 commit 1e27eda

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Thu Sep 19 14:12:02 2013 Koichi Sasada <[email protected]>
2+
3+
* include/ruby/ruby.h: make Symbol objects frozen.
4+
[Feature #8906]
5+
I want to freeze this good day, too.
6+
7+
* test/ruby/test_eval.rb: catch up this change.
8+
9+
* test/ruby/test_symbol.rb: add a test to check frozen symbols.
10+
111
Thu Sep 19 09:11:33 2013 Eric Hodel <[email protected]>
212

313
* NEWS: Update for RDoc 4.1.0.preview.1 and RubyGems 2.2.0.preview.1

include/ruby/ruby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ struct RBignum {
12471247
RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT; \
12481248
} while (0)
12491249

1250-
#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x))))
1250+
#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)||SYMBOL_P(x))))
12511251
#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
12521252

12531253
#if USE_RGENGC

test/ruby/test_eval.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_module_eval_block_basic
128128
end
129129

130130
def forall_TYPE
131-
objects = [Object.new, [], nil, true, false, :sym] # TODO: check
131+
objects = [Object.new, [], nil, true, false] # TODO: check
132132
objects.each do |obj|
133133
obj.instance_variable_set :@ivar, 12
134134
yield obj

test/ruby/test_symbol.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,12 @@ def test_symbol_encoding
198198
def test_singleton_method
199199
assert_raise(TypeError) { a = :foo; def a.foo; end }
200200
end
201+
202+
def test_frozen_symbol
203+
assert_equal(true, :foo.frozen?)
204+
assert_equal(true, :each.frozen?)
205+
assert_equal(true, :+.frozen?)
206+
assert_equal(true, "foo#{Time.now.to_i}".to_sym.frozen?)
207+
assert_equal(true, :foo.to_sym.frozen?)
208+
end
201209
end

0 commit comments

Comments
 (0)