diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ripper/test_parser_events.rb | 4 | ||||
-rw-r--r-- | test/ripper/test_scanner_events.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_hash.rb | 11 |
3 files changed, 20 insertions, 0 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 537d3fc406..1942157b89 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -548,6 +548,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru_dyna_symbol = false parse(':"#{foo}"', :on_dyna_symbol) {thru_dyna_symbol = true} assert_equal true, thru_dyna_symbol + + thru_dyna_symbol = false + parse('{"#{foo}": 1}', :on_dyna_symbol) {thru_dyna_symbol = true} + assert_equal true, thru_dyna_symbol end def test_else diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index ac34ac57df..91903e3dcd 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -878,6 +878,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('label', '{foo: 1}') end + def test_label_end + assert_equal %w(":), + scan('label_end', '{"foo-bar": 1}') + end + def test_tlambda assert_equal %w(->), scan('tlambda', '->{}') 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(*) |