diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-23 10:03:30 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-23 10:03:30 +0000 |
commit | 65658ea0d4f17b90bb09003405a7560d6df0b58e (patch) | |
tree | 156fdae18505dc97515c157a5ca2bffcdd8482a1 /test | |
parent | 2bcd502a71bc0a140f3b78ed0d148745fb648555 (diff) | |
download | ruby-65658ea0d4f17b90bb09003405a7560d6df0b58e.tar.gz |
* parse.y (rb_enc_symname_type): :$a!, @a! and so on are not
valid symbols, so they should be inspected with quotes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_symbol.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 282964cdf5..2a21c78540 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -75,6 +75,19 @@ class TestSymbol < Test::Unit::TestCase assert_inspect_evaled(':$1') end + def test_inspect + valid = %w{$a @a @@a < << <= <=> > >> >= =~ == === * ** + +@ - -@ + | ^ & / % ~ ` [] []= ! != !~ a a? a! a= A A? A! A=} + valid.each do |sym| + assert_equal(':' + sym, sym.intern.inspect) + end + + invalid = %w{$a? $a! $a= @a? @a! @a= @@a? @@a! @@a= =} + invalid.each do |sym| + assert_equal(':"' + sym + '"', sym.intern.inspect) + end + end + def test_to_proc assert_equal %w(1 2 3), (1..3).map(&:to_s) [ |