From eb13bcec58cfd2a65b0d6996af65865f357699ad Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 24 Nov 2017 04:26:27 +0000 Subject: parse.y: refactor list literals * parse.y (words, symbols, qwords, qsymbols): unify empty list and non-empty list. * parse.y (parser_parse_string): always dispatch a word separator at the beginning of list literals. [ruby-core:83871] [Bug #14126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ripper/test_parser_events.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ripper/test_parser_events.rb') diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 86720b1446..2fca61e1d1 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1017,6 +1017,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase tree = parse('%w[a]', :on_qwords_add) {thru_qwords_add = true} assert_equal true, thru_qwords_add assert_equal '[array([a])]', tree + thru_qwords_add = false + tree = parse('%w[ a ]', :on_qwords_add) {thru_qwords_add = true} + assert_equal true, thru_qwords_add + assert_equal '[array([a])]', tree end def test_qsymbols_add @@ -1024,6 +1028,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase tree = parse('%i[a]', :on_qsymbols_add) {thru_qsymbols_add = true} assert_equal true, thru_qsymbols_add assert_equal '[array([:a])]', tree + thru_qsymbols_add = false + tree = parse('%i[ a ]', :on_qsymbols_add) {thru_qsymbols_add = true} + assert_equal true, thru_qsymbols_add + assert_equal '[array([:a])]', tree end def test_symbols_add @@ -1031,6 +1039,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase tree = parse('%I[a]', :on_symbols_add) {thru_symbols_add = true} assert_equal true, thru_symbols_add assert_equal '[array([:a])]', tree + thru_symbols_add = false + tree = parse('%I[ a ]', :on_symbols_add) {thru_symbols_add = true} + assert_equal true, thru_symbols_add + assert_equal '[array([:a])]', tree end def test_qwords_new @@ -1383,6 +1395,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase tree = parse('%W[a]', :on_words_add) {thru_words_add = true} assert_equal true, thru_words_add assert_equal '[array([a])]', tree + thru_words_add = false + tree = parse('%W[ a ]', :on_words_add) {thru_words_add = true} + assert_equal true, thru_words_add + assert_equal '[array([a])]', tree end def test_words_new -- cgit v1.2.1