summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-24 04:26:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-24 04:26:23 +0000
commit9c86c513f0912af07c9addb57026bab385abea35 (patch)
tree7a7527778f1f368d21e4ab89168d00df0056885c
parent4046ca57967b016fd82f3f065aae3732c15c301e (diff)
test_parser_events.rb: results of list literals
* test/ripper/test_parser_events.rb (test_qwords_add), (test_qsymbols_add, test_symbols_add, test_words_add): more assertions for results of list literals. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ripper/dummyparser.rb26
-rw-r--r--test/ripper/test_parser_events.rb12
2 files changed, 34 insertions, 4 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
index 4261ab5e82..ca36985893 100644
--- a/test/ripper/dummyparser.rb
+++ b/test/ripper/dummyparser.rb
@@ -24,6 +24,16 @@ class Node
end
list
end
+
+ class Sym < self
+ def initialize(name)
+ @name = name
+ end
+
+ def to_s
+ ":#{@name}"
+ end
+ end
end
class NodeList
@@ -218,6 +228,22 @@ class DummyParser < Ripper
words.push word
end
+ def on_symbols_new
+ NodeList.new
+ end
+
+ def on_symbols_add(symbols, symbol)
+ symbols.push Node::Sym.new(symbol)
+ end
+
+ def on_qsymbols_new
+ NodeList.new
+ end
+
+ def on_qsymbols_add(symbols, symbol)
+ symbols.push Node::Sym.new(symbol)
+ end
+
def on_mlhs_new
NodeList.new
end
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index cf118a49c2..86720b1446 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -1014,20 +1014,23 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_qwords_add
thru_qwords_add = false
- parse('%w[a]', :on_qwords_add) {thru_qwords_add = true}
+ 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
thru_qsymbols_add = false
- parse('%i[a]', :on_qsymbols_add) {thru_qsymbols_add = true}
+ 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
thru_symbols_add = false
- parse('%I[a]', :on_symbols_add) {thru_symbols_add = true}
+ 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
@@ -1377,8 +1380,9 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_words_add
thru_words_add = false
- parse('%W[a]', :on_words_add) {thru_words_add = true}
+ 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