1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ripper/test_scanner_events.rb: fix test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2005-02-04 17:25:09 +00:00
parent 41cd3d868d
commit 828c5ec400
2 changed files with 13 additions and 9 deletions

View file

@ -1,3 +1,7 @@
Sat Feb 5 02:24:06 2005 Minero Aoki <aamine@loveruby.net>
* test/ripper/test_scanner_events.rb: fix test.
Fri Feb 4 18:44:35 2005 Minero Aoki <aamine@loveruby.net>
* ext/ripper/lib/ripper/lexer.rb: last Lexer fix was incomplete;

View file

@ -9,7 +9,7 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase
def scan(target, str)
sym = "on_#{target}".intern
Ripper.scan(str).select {|_,type,_| type == sym }.map {|_,_,tok| tok }
Ripper.lex(str).select {|_,type,_| type == sym }.map {|_,_,tok| tok }
end
def test_tokenize
@ -29,13 +29,13 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase
Ripper.tokenize("\#\n\n\#\n\nnil\n")
end
def test_scan
def test_lex
assert_equal [],
Ripper.scan('')
Ripper.lex('')
assert_equal [[[1,0], :on_ident, "a"]],
Ripper.scan('a')
Ripper.lex('a')
assert_equal [[[1, 0], :on_kw, "nil"]],
Ripper.scan("nil")
Ripper.lex("nil")
assert_equal [[[1, 0], :on_kw, "def"],
[[1, 3], :on_sp, " "],
[[1, 4], :on_ident, "m"],
@ -43,18 +43,18 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase
[[1, 6], :on_ident, "a"],
[[1, 7], :on_rparen, ")"],
[[1, 8], :on_kw, "end"]],
Ripper.scan("def m(a)end")
Ripper.lex("def m(a)end")
assert_equal [[[1, 0], :on_int, "1"],
[[1, 1], :on_nl, "\n"],
[[2, 0], :on_int, "2"],
[[2, 1], :on_nl, "\n"],
[[3, 0], :on_int, "3"]],
Ripper.scan("1\n2\n3")
Ripper.lex("1\n2\n3")
assert_equal [[[1, 0], :on_heredoc_beg, "<<EOS"],
[[1, 5], :on_nl, "\n"],
[[2, 0], :on_tstring_content, "heredoc\n"],
[[3, 0], :on_heredoc_end, "EOS"]],
Ripper.scan("<<EOS\nheredoc\nEOS")
Ripper.lex("<<EOS\nheredoc\nEOS")
end
def test_location
@ -81,7 +81,7 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase
def validate_location(src)
buf = ''
Ripper.scan(src).each do |pos, type, tok|
Ripper.lex(src).each do |pos, type, tok|
line, col = *pos
assert_equal buf.count("\n") + 1, line,
"wrong lineno: #{tok.inspect} (#{type}) [#{line}:#{col}]"