From 856a9afb98b8443a8b32483a97e271560af6de1b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 2 Aug 2013 14:13:20 +0000 Subject: eventids2.c: new literals * ext/ripper/eventids2.c (ripper_init_eventids2): ripper support for new literals, tRATIONAL and tIMAGINARY. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ripper/test_scanner_events.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/ripper') diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index a96edef063..2474588f76 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -87,6 +87,17 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase [[1, 1], :on_tstring_content, "\u3042\n\u3044"], [[2, 3], :on_tstring_end, "'"]], Ripper.lex("'\u3042\n\u3044'") + assert_equal [[[1, 0], :on_rational, "1r"], + [[1, 2], :on_nl, "\n"], + [[2, 0], :on_imaginary, "2i"], + [[2, 2], :on_nl, "\n"], + [[3, 0], :on_imaginary, "3ri"], + [[3, 3], :on_nl, "\n"], + [[4, 0], :on_rational, "4.2r"], + [[4, 4], :on_nl, "\n"], + [[5, 0], :on_imaginary, "5.6ri"], + ], + Ripper.lex("1r\n2i\n3ri\n4.2r\n5.6ri") end def test_location @@ -264,6 +275,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('float', 'm(a,b,1.0,c,d)') end + def test_rational + assert_equal [], + scan('rational', '') + assert_equal ['1r', '10r', '10.1r'], + scan('rational', 'm(1r,10r,10.1r)') + end + def test_gvar assert_equal [], scan('gvar', '') @@ -286,6 +304,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('ident', 'm(lvar, @ivar, @@cvar, $gvar)') end + def test_imaginary + assert_equal [], + scan('imaginary', '') + assert_equal ['1i', '10ri', '10.0i', '10.1ri'], + scan('imaginary', 'm(1i,10ri,10.0i,10.1ri)') + end + def test_int assert_equal [], scan('int', '') -- cgit v1.2.3