mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
4046ca5796
commit
9c86c513f0
2 changed files with 34 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue