From 1344cfba26ac2ecbb206ddbb13e1a31dafceaba3 Mon Sep 17 00:00:00 2001 From: aamine Date: Sat, 9 Oct 2004 18:20:46 +0000 Subject: [PATCH] * test/ripper/test_scanner_events.rb: test location information. * test/ripper/test_scanner_events.rb: test \n between comments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ripper/test_scanner_events.rb | 62 +++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 21aa9a8312..57be40c4dc 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -8,27 +8,53 @@ require 'test/unit' class TestRipper_ScannerEvents < Test::Unit::TestCase def scan(target, str) - if target - sym = "on_#{target}".intern - Ripper.scan(str).select {|_,type,_| type == sym }.map {|_,_,tok| tok } - else - Ripper.scan(str).map {|_,_,tok| tok } - end + sym = "on_#{target}".intern + Ripper.scan(str).select {|_,type,_| type == sym }.map {|_,_,tok| tok } + end + + def test_tokenize + assert_equal [], + Ripper.tokenize('') + assert_equal ['a'], + Ripper.tokenize('a') + assert_equal ['1'], + Ripper.tokenize('1') + assert_equal ['1', ';', 'def', ' ', 'm', '(', 'arg', ')', 'end'], + Ripper.tokenize("1;def m(arg)end") + assert_equal ['print', '(', '<