diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ripper/dummyparser.rb | 26 | ||||
-rw-r--r-- | test/ripper/test_parser_events.rb | 12 |
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 |