diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-20 01:48:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-20 01:48:43 +0000 |
commit | b0c03f63e5b3865684d8d37e8cac666ba7e0e3e0 (patch) | |
tree | 96a42bddc5ce6514cb9eda0322e87c8c5d7d41c4 /test/ruby/test_hash.rb | |
parent | 7190c04417a52c29d1dcf6b2f04bb55b30cbfd9f (diff) | |
download | ruby-b0c03f63e5b3865684d8d37e8cac666ba7e0e3e0.tar.gz |
parse.y: quoted ID key
* parse.y (assoc): allow quoted ID as a key of a hash literal.
[ruby-core:34453] [Feature #4276]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index dd93a63340..4431552dd9 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1269,6 +1269,17 @@ class TestHash < Test::Unit::TestCase assert_equal(bug9381, hash[wrapper.new(5)]) end + def test_label_syntax + return unless @cls == Hash + + feature4935 = '[ruby-core:37553] [Feature #4935]' + x = 'world' + hash = assert_nothing_raised(SyntaxError) do + break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4})) + end + assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4}, hash) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) |