2017-02-05 02:54:32 -05:00
|
|
|
# frozen_string_literal: true
|
2004-09-12 13:34:30 -04:00
|
|
|
#
|
|
|
|
# test_scanner_events.rb
|
|
|
|
#
|
2006-12-31 10:02:22 -05:00
|
|
|
begin
|
2009-10-20 02:35:26 -04:00
|
|
|
require 'ripper'
|
|
|
|
require 'test/unit'
|
|
|
|
ripper_test = true
|
2009-12-07 20:01:04 -05:00
|
|
|
module TestRipper; end
|
2009-10-20 02:35:26 -04:00
|
|
|
rescue LoadError
|
|
|
|
end
|
2004-09-12 13:34:30 -04:00
|
|
|
|
2009-12-07 20:01:04 -05:00
|
|
|
class TestRipper::ScannerEvents < Test::Unit::TestCase
|
2004-09-12 13:34:30 -04:00
|
|
|
|
2005-09-22 16:58:10 -04:00
|
|
|
def test_event_coverage
|
|
|
|
dispatched = Ripper::SCANNER_EVENTS.map {|event,_| event }
|
|
|
|
dispatched.each do |e|
|
|
|
|
assert_equal true, respond_to?("test_#{e}", true), "event not tested: #{e}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-09-23 06:49:11 -04:00
|
|
|
def scan(target, str)
|
2004-10-09 14:20:46 -04:00
|
|
|
sym = "on_#{target}".intern
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
Ripper.lex(str).select {|_1,type,_2| type == sym }.map {|_1,_2,tok| tok }
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2004-10-09 14:20:46 -04:00
|
|
|
def test_tokenize
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-10-09 14:20:46 -04:00
|
|
|
Ripper.tokenize('')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['a'],
|
2004-10-09 14:20:46 -04:00
|
|
|
Ripper.tokenize('a')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1'],
|
2004-10-09 14:20:46 -04:00
|
|
|
Ripper.tokenize('1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1', ';', 'def', ' ', 'm', '(', 'arg', ')', 'end'],
|
2004-10-09 14:20:46 -04:00
|
|
|
Ripper.tokenize("1;def m(arg)end")
|
2012-12-06 03:25:50 -05:00
|
|
|
assert_equal ['print', '(', '<<''EOS', ')', "\n", "heredoc\n", "EOS\n"],
|
|
|
|
Ripper.tokenize("print(<<""EOS)\nheredoc\nEOS\n")
|
|
|
|
assert_equal ['print', '(', ' ', '<<''EOS', ')', "\n", "heredoc\n", "EOS\n"],
|
|
|
|
Ripper.tokenize("print( <<""EOS)\nheredoc\nEOS\n")
|
2004-10-09 14:20:46 -04:00
|
|
|
assert_equal ["\#\n", "\n", "\#\n", "\n", "nil", "\n"],
|
|
|
|
Ripper.tokenize("\#\n\n\#\n\nnil\n")
|
2014-10-24 09:49:44 -04:00
|
|
|
assert_equal ["1", " ", ".", "foo", "\n"],
|
|
|
|
Ripper.tokenize("1 .foo\n")
|
|
|
|
assert_equal ["1", "\n", " ", ".", "foo", "\n"],
|
|
|
|
Ripper.tokenize("1\n .foo\n")
|
2004-10-09 14:20:46 -04:00
|
|
|
end
|
|
|
|
|
2005-02-04 12:25:09 -05:00
|
|
|
def test_lex
|
2004-10-09 14:20:46 -04:00
|
|
|
assert_equal [],
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex('')
|
2004-10-09 14:20:46 -04:00
|
|
|
assert_equal [[[1,0], :on_ident, "a"]],
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex('a')
|
2004-10-09 14:20:46 -04:00
|
|
|
assert_equal [[[1, 0], :on_kw, "nil"]],
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex("nil")
|
2004-10-09 14:20:46 -04:00
|
|
|
assert_equal [[[1, 0], :on_kw, "def"],
|
|
|
|
[[1, 3], :on_sp, " "],
|
|
|
|
[[1, 4], :on_ident, "m"],
|
|
|
|
[[1, 5], :on_lparen, "("],
|
|
|
|
[[1, 6], :on_ident, "a"],
|
|
|
|
[[1, 7], :on_rparen, ")"],
|
|
|
|
[[1, 8], :on_kw, "end"]],
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex("def m(a)end")
|
2004-10-09 14:20:46 -04:00
|
|
|
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"]],
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex("1\n2\n3")
|
2012-12-06 03:25:50 -05:00
|
|
|
assert_equal [[[1, 0], :on_heredoc_beg, "<<""EOS"],
|
2004-10-09 14:20:46 -04:00
|
|
|
[[1, 5], :on_nl, "\n"],
|
|
|
|
[[2, 0], :on_tstring_content, "heredoc\n"],
|
|
|
|
[[3, 0], :on_heredoc_end, "EOS"]],
|
2012-12-06 03:25:50 -05:00
|
|
|
Ripper.lex("<<""EOS\nheredoc\nEOS")
|
|
|
|
assert_equal [[[1, 0], :on_heredoc_beg, "<<""EOS"],
|
2011-07-05 02:28:07 -04:00
|
|
|
[[1, 5], :on_nl, "\n"],
|
|
|
|
[[2, 0], :on_heredoc_end, "EOS"]],
|
2012-12-06 03:25:50 -05:00
|
|
|
Ripper.lex("<<""EOS\nEOS"),
|
2011-07-05 02:28:07 -04:00
|
|
|
"bug#4543"
|
2009-08-16 10:58:27 -04:00
|
|
|
assert_equal [[[1, 0], :on_regexp_beg, "/"],
|
2011-06-13 10:38:26 -04:00
|
|
|
[[1, 1], :on_tstring_content, "foo\nbar"],
|
2009-08-16 10:58:27 -04:00
|
|
|
[[2, 3], :on_regexp_end, "/"]],
|
|
|
|
Ripper.lex("/foo\nbar/")
|
2011-06-13 10:38:26 -04:00
|
|
|
assert_equal [[[1, 0], :on_regexp_beg, "/"],
|
|
|
|
[[1, 1], :on_tstring_content, "foo\n\u3020"],
|
|
|
|
[[2, 3], :on_regexp_end, "/"]],
|
|
|
|
Ripper.lex("/foo\n\u3020/")
|
|
|
|
assert_equal [[[1, 0], :on_tstring_beg, "'"],
|
|
|
|
[[1, 1], :on_tstring_content, "foo\n\xe3\x80\xa0"],
|
|
|
|
[[2, 3], :on_tstring_end, "'"]],
|
|
|
|
Ripper.lex("'foo\n\xe3\x80\xa0'")
|
2011-10-27 23:11:06 -04:00
|
|
|
assert_equal [[[1, 0], :on_tstring_beg, "'"],
|
|
|
|
[[1, 1], :on_tstring_content, "\u3042\n\u3044"],
|
|
|
|
[[2, 3], :on_tstring_end, "'"]],
|
|
|
|
Ripper.lex("'\u3042\n\u3044'")
|
2013-08-02 10:13:20 -04:00
|
|
|
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")
|
2016-02-02 18:21:34 -05:00
|
|
|
assert_equal [[[1, 0], :on_heredoc_beg, "<<~EOS"],
|
|
|
|
[[1, 6], :on_nl, "\n"],
|
2017-05-06 11:14:58 -04:00
|
|
|
[[2, 0], :on_ignored_sp, " "],
|
2016-02-02 18:21:34 -05:00
|
|
|
[[2, 2], :on_tstring_content, "heredoc\n"],
|
|
|
|
[[3, 0], :on_heredoc_end, "EOS"]
|
|
|
|
],
|
|
|
|
Ripper.lex("<<~EOS\n heredoc\nEOS")
|
2017-03-26 03:13:43 -04:00
|
|
|
assert_equal [[[1, 0], :on_tstring_beg, "'"],
|
|
|
|
[[1, 1], :on_tstring_content, "foo"]],
|
|
|
|
Ripper.lex("'foo")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2004-09-20 02:14:09 -04:00
|
|
|
def test_location
|
2013-05-08 00:07:21 -04:00
|
|
|
assert_location ""
|
|
|
|
assert_location " "
|
2013-05-08 00:07:22 -04:00
|
|
|
assert_location ":"
|
2013-05-08 00:07:21 -04:00
|
|
|
assert_location "\n"
|
|
|
|
assert_location "\r\n"
|
|
|
|
assert_location "\n\n\n\n\n\r\n\n\n"
|
|
|
|
assert_location "\n;\n;\n;\n;\n"
|
|
|
|
assert_location "nil"
|
|
|
|
assert_location "@ivar"
|
|
|
|
assert_location "1;2;3"
|
|
|
|
assert_location "1\n2\n3"
|
|
|
|
assert_location "1\n2\n3\n"
|
|
|
|
assert_location "def m(a) nil end"
|
|
|
|
assert_location "if true then false else nil end"
|
|
|
|
assert_location "BEGIN{print nil}"
|
|
|
|
assert_location "%w(a b\nc\r\nd \ne )"
|
|
|
|
assert_location %Q["a\nb\r\nc"]
|
|
|
|
assert_location "print(<<""EOS)\nheredoc\nEOS\n"
|
|
|
|
assert_location "print(<<-\"EOS\")\nheredoc\n EOS\n"
|
2017-03-24 21:07:35 -04:00
|
|
|
assert_location "'foo'"
|
|
|
|
assert_location "'foo"
|
2004-09-20 02:14:09 -04:00
|
|
|
end
|
|
|
|
|
2013-05-08 00:07:21 -04:00
|
|
|
def assert_location(src)
|
2017-02-05 02:54:32 -05:00
|
|
|
buf = ''.dup
|
2005-02-04 12:25:09 -05:00
|
|
|
Ripper.lex(src).each do |pos, type, tok|
|
2004-09-23 06:49:11 -04:00
|
|
|
line, col = *pos
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal buf.count("\n") + 1, line,
|
|
|
|
"wrong lineno: #{tok.inspect} (#{type}) [#{line}:#{col}]"
|
|
|
|
assert_equal buf.sub(/\A.*\n/m, '').size, col,
|
|
|
|
"wrong column: #{tok.inspect} (#{type}) [#{line}:#{col}]"
|
|
|
|
buf << tok
|
|
|
|
end
|
|
|
|
assert_equal src, buf
|
|
|
|
end
|
|
|
|
|
2004-09-12 13:34:30 -04:00
|
|
|
def test_backref
|
|
|
|
assert_equal ["$`", "$&", "$'", '$1', '$2', '$3'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('backref', %q[m($~, $`, $&, $', $1, $2, $3)])
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_backtick
|
|
|
|
assert_equal ["`"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('backtick', %q[p `make all`])
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_comma
|
|
|
|
assert_equal [','] * 6,
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comma', %q[ m(0,1,2,3,4,5,6) ])
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comma', %q[".,.,.,.,.,.,.."])
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('comma', "<<""EOS\n,,,,,,,,,,\nEOS")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_period
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['.'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', 'a.b')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['.'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', 'Object.new')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', '"."')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', '1..2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('period', '1...3')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_const
|
|
|
|
assert_equal ['CONST'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'CONST')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['C'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'C')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['CONST_A'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'CONST_A')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['Const', 'Const2', 'Const3'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'Const; Const2; Const3')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['Const'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'Const(a)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['M', 'A', 'A2'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'M(A,A2)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('const', 'm(lvar, @ivar, @@cvar, $gvar)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_cvar
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@cvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', '@@cvar')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@__cvar__'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', '@@__cvar__')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@CVAR'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', '@@CVAR')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@cvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', ' @@cvar#comment')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@cvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', ':@@cvar')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@@cvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', 'm(lvar, @ivar, @@cvar, $gvar)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('cvar', '"@@cvar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_embexpr_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_beg', '"#{expr}"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_beg', '%q[#{expr}]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_beg', '%Q[#{expr}]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#{'],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('embexpr_beg', "m(<<""EOS)\n\#{expr}\nEOS")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_embexpr_end
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_end', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_end', '"#{expr}"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_end', '%q[#{expr}]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embexpr_end', '%Q[#{expr}]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('embexpr_end', "m(<<""EOS)\n\#{expr}\nEOS")
|
2005-09-22 16:58:10 -04:00
|
|
|
end
|
2004-09-12 13:34:30 -04:00
|
|
|
|
|
|
|
def test_embvar
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"#$gvar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"#@ivar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"#@@cvar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"#lvar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"#"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"\#$gvar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '"\#@ivar"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '%q[#@ivar]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['#'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embvar', '%Q[#@ivar]')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_float
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.000'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '1.000')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['123.456'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '123.456')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.2345678901234567890123456789'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '1.2345678901234567890123456789')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.000'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', ' 1.000# comment')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.234e5'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '1.234e5')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.234e1234567890'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', '1.234e1234567890')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1.0'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('float', 'm(a,b,1.0,c,d)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2013-08-02 10:13:20 -04:00
|
|
|
def test_rational
|
|
|
|
assert_equal [],
|
|
|
|
scan('rational', '')
|
|
|
|
assert_equal ['1r', '10r', '10.1r'],
|
|
|
|
scan('rational', 'm(1r,10r,10.1r)')
|
|
|
|
end
|
|
|
|
|
2004-09-12 13:34:30 -04:00
|
|
|
def test_gvar
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('gvar', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['$a'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('gvar', '$a')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['$A'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('gvar', '$A')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['$gvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('gvar', 'm(lvar, @ivar, @@cvar, $gvar)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w($_ $~ $* $$ $? $! $@ $/ $\\ $; $, $. $= $: $< $> $"),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('gvar', 'm($_, $~, $*, $$, $?, $!, $@, $/, $\\, $;, $,, $., $=, $:, $<, $>, $")')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ident
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ident', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['lvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ident', 'lvar')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['m', 'lvar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ident', 'm(lvar, @ivar, @@cvar, $gvar)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2013-08-02 10:13:20 -04:00
|
|
|
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
|
|
|
|
|
2004-09-12 13:34:30 -04:00
|
|
|
def test_int
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('int', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['1', '10', '100000000000000'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('int', 'm(1,10,100000000000000)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ivar
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ivar', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@ivar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ivar', '@ivar')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@__ivar__'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ivar', '@__ivar__')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@IVAR'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ivar', '@IVAR')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['@ivar'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ivar', 'm(lvar, @ivar, @@cvar, $gvar)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_kw
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(not),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'not 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(and),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 and 2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(or),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 or 2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(if then else end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'if 1 then 2 else 3 end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(if then elsif else end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'if 1 then 2 elsif 3 else 4 end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(unless then end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'unless 1 then end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(if true),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 if true')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(unless false),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '2 unless false')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(case when when else end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'case n; when 1; when 2; else 3 end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(while do nil end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'while 1 do nil end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(until do nil end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'until 1 do nil end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(while),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 while 2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(until),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 until 2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(while break next retry end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'while 1; break; next; retry end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(for in next break end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'for x in obj; next 1; break 2 end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(begin rescue retry end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'begin 1; rescue; retry; end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(rescue),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', '1 rescue 2')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(def redo return end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'def m() redo; return end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(def yield yield end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'def m() yield; yield 1 end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(def super super super end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'def m() super; super(); super(1) end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(alias),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'alias a b')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(undef),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'undef public')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(class end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'class A < Object; end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(module end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'module M; end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(class end),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'class << obj; end')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(BEGIN),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'BEGIN { }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(END),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'END { }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(self),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'self.class')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(nil true false),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'p(nil, true, false)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(__FILE__ __LINE__),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'p __FILE__, __LINE__')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(defined?),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('kw', 'defined?(Object)')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_lbrace
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '3.times{ }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '3.times { }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '3.times{}')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '"{}"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['{'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbrace', '{1=>2}')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_rbrace
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '3.times{ }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '3.times { }')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '3.times{}')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '"{}"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['}'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbrace', '{1=>2}')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_lbracket
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbracket', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['['],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbracket', '[]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['['],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbracket', 'a[1]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lbracket', 'm(%q[])')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_rbracket
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbracket', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [']'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbracket', '[]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [']'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbracket', 'a[1]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rbracket', 'm(%q[])')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_lparen
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', '()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', 'm()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', 'm (a)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', '"()"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('lparen', '"%w()"')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_rparen
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [')'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', '()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [')'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', 'm()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [')'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', 'm (a)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', '"()"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('rparen', '"%w()"')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_op
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['|'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 | 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['^'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 ^ 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['&'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 & 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['<=>'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 <=> 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['=='],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 == 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['==='],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 === 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['=~'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 =~ 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['>'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 > 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['>='],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 >= 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['<'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 < 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['<='],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 <= 1')
|
2012-12-06 03:25:50 -05:00
|
|
|
assert_equal ['<''<'],
|
|
|
|
scan('op', '1 <''< 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['>>'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 >> 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['+'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 + 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['-'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 - 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['*'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 * 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['/'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 / 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 % 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['**'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '1 ** 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['~'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '~1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['-'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '-a')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['+'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', '+a')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['[]'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', ':[]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['[]='],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', ':[]=')
|
2015-11-05 22:39:23 -05:00
|
|
|
assert_equal ['&.'],
|
|
|
|
scan('op', 'a&.f')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('op', %q[`make all`])
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_symbeg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('symbeg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [':'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('symbeg', ':sym')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [':'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('symbeg', '[1,2,3,:sym]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('symbeg', '":sym"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('symbeg', 'a ? b : c')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tstring_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['"'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_beg', '"abcdef"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%q['],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_beg', '%q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%Q['],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_beg', '%Q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tstring_content
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['abcdef'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '"abcdef"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['abcdef'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '%q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['abcdef'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '%Q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['abc', 'def'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '"abc#{1}def"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['sym'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', ':"sym"')
|
2011-06-13 10:38:26 -04:00
|
|
|
assert_equal ['a b c'],
|
|
|
|
scan('tstring_content', ':"a b c"'),
|
|
|
|
"bug#4544"
|
|
|
|
assert_equal ["a\nb\nc"],
|
|
|
|
scan('tstring_content', ":'a\nb\nc'"),
|
|
|
|
"bug#4544"
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tstring_end
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_end', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['"'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_end', '"abcdef"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [']'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_end', '%q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [']'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_end', '%Q[abcdef]')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_regexp_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['/'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_beg', '/re/')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%r<'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_beg', '%r<re>')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_beg', '5 / 5')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_regexp_end
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_end', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['/'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_end', '/re/')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['>'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('regexp_end', '%r<re>')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_words_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%W('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_beg', '%W()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%W('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_beg', '%W(w w w)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%W( '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_beg', '%W( w w w )')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_qwords_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('qwords_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%w('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('qwords_beg', '%w()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%w('],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('qwords_beg', '%w(w w w)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['%w( '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('qwords_beg', '%w( w w w )')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2012-07-24 14:10:35 -04:00
|
|
|
def test_qsymbols_beg
|
|
|
|
assert_equal [],
|
|
|
|
scan('qsymbols_beg', '')
|
|
|
|
assert_equal ['%i('],
|
|
|
|
scan('qsymbols_beg', '%i()')
|
|
|
|
assert_equal ['%i('],
|
|
|
|
scan('qsymbols_beg', '%i(w w w)')
|
|
|
|
assert_equal ['%i( '],
|
|
|
|
scan('qsymbols_beg', '%i( w w w )')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_symbols_beg
|
|
|
|
assert_equal [],
|
|
|
|
scan('symbols_beg', '')
|
|
|
|
assert_equal ['%I('],
|
|
|
|
scan('symbols_beg', '%I()')
|
|
|
|
assert_equal ['%I('],
|
|
|
|
scan('symbols_beg', '%I(w w w)')
|
|
|
|
assert_equal ['%I( '],
|
|
|
|
scan('symbols_beg', '%I( w w w )')
|
|
|
|
end
|
|
|
|
|
2004-09-12 13:34:30 -04:00
|
|
|
# FIXME: Close paren must not present (`words_end' scanner event?).
|
|
|
|
def test_words_sep
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_sep', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [')'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_sep', '%w()')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' ', ' ', ')'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_sep', '%w(w w w)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' ', ' ', ' )'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_sep', '%w( w w w )')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n", ' ', ' )'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('words_sep', "%w( w\nw w )")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_heredoc_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('heredoc_beg', '')
|
2012-12-06 03:25:50 -05:00
|
|
|
assert_equal ['<<''EOS'],
|
|
|
|
scan('heredoc_beg', "<<""EOS\nheredoc\nEOS")
|
|
|
|
assert_equal ['<<''EOS'],
|
|
|
|
scan('heredoc_beg', "<<""EOS\nheredoc\nEOS\n")
|
|
|
|
assert_equal ['<<''EOS'],
|
|
|
|
scan('heredoc_beg', "<<""EOS\nheredoc\nEOS \n")
|
|
|
|
assert_equal ['<<''-EOS'],
|
|
|
|
scan('heredoc_beg', "<<""-EOS\nheredoc\n\tEOS \n")
|
|
|
|
assert_equal ['<<''"EOS"'],
|
|
|
|
scan('heredoc_beg', '<<''"EOS"'"\nheredoc\nEOS")
|
|
|
|
assert_equal ["<<""'EOS'"],
|
|
|
|
scan('heredoc_beg', "<<""'EOS'\nheredoc\nEOS")
|
|
|
|
assert_equal ['<<''`EOS`'],
|
|
|
|
scan('heredoc_beg', "<<""`EOS`\nheredoc\nEOS")
|
|
|
|
assert_equal ['<<''" "'],
|
|
|
|
scan('heredoc_beg', '<<''" "'"\nheredoc\nEOS")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2004-09-20 01:40:23 -04:00
|
|
|
def test_tstring_content_HEREDOC
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('tstring_content', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["heredoc\n"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('tstring_content', "<<""EOS\nheredoc\nEOS")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["heredoc\n"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('tstring_content', "<<""EOS\nheredoc\nEOS\n")
|
2009-10-20 01:50:53 -04:00
|
|
|
assert_equal ["here\ndoc \nEOS \n"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('tstring_content', "<<""EOS\nhere\ndoc \nEOS \n")
|
2009-10-20 01:50:53 -04:00
|
|
|
assert_equal ["heredoc\n\tEOS \n"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('tstring_content', "<<""-EOS\nheredoc\n\tEOS \n")
|
2012-12-06 03:29:16 -05:00
|
|
|
bug7255 = '[ruby-core:48703]'
|
|
|
|
assert_equal ["there\n""heredoc", "\n"],
|
|
|
|
scan('tstring_content', "<<""EOS\n""there\n""heredoc\#{foo}\nEOS"),
|
|
|
|
bug7255
|
|
|
|
assert_equal ["there\n""heredoc", "\n"],
|
|
|
|
scan('tstring_content', "<<""EOS\n""there\n""heredoc\#@foo\nEOS"),
|
|
|
|
bug7255
|
2014-10-16 02:05:03 -04:00
|
|
|
bug10392 = '[ruby-dev:48647] [Bug #10392]'
|
|
|
|
assert_equal [" E\n\n"],
|
|
|
|
scan('tstring_content', "<<""'E'\n E\n\n"),
|
|
|
|
bug10392
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_heredoc_end
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('heredoc_end', '')
|
2011-07-05 02:28:07 -04:00
|
|
|
assert_equal ["EOS"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('heredoc_end', "<<""EOS\nEOS"),
|
2011-07-05 02:28:07 -04:00
|
|
|
"bug#4543"
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["EOS"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('heredoc_end', "<<""EOS\nheredoc\nEOS")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["EOS\n"],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('heredoc_end', "<<""EOS\nheredoc\nEOS\n")
|
2009-10-20 01:50:53 -04:00
|
|
|
assert_equal [],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('heredoc_end', "<<""EOS\nheredoc\nEOS \n")
|
2009-10-20 01:50:53 -04:00
|
|
|
assert_equal [],
|
2012-12-06 03:25:50 -05:00
|
|
|
scan('heredoc_end', "<<""-EOS\nheredoc\n\tEOS \n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_semicolon
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(;),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', ';')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(; ;),
|
2005-06-07 23:30:56 -04:00
|
|
|
scan('semicolon', '; ;')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(; ; ;),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', 'nil;nil;nil;')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal %w(; ; ;),
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', 'nil;nil;nil;nil')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', '";"')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', '%w(;)')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('semicolon', '/;/')
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_comment
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comment', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ['# comment'],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comment', '# comment')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["# comment\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comment', "# comment\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["# comment\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comment', "# comment\n1 + 1")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["# comment\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('comment', "1 + 1 + 1# comment\n1 + 1")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_embdoc_beg
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_beg', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["=begin\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_beg', "=begin\ndoc\n=end")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["=begin \n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_beg', "=begin \ndoc\n=end\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["=begin comment\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_beg', "=begin comment\ndoc\n=end\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_embdoc
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["doc\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc', "=begin\ndoc\n=end")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["doc\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc', "=begin\ndoc\n=end\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_embdoc_end
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_end', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["=end"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_end', "=begin\ndoc\n=end")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["=end\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('embdoc_end', "=begin\ndoc\n=end\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_sp
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', ' ')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', ' 1')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', " \n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [' ', ' '],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "1 + 1")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "' '")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "%w( )")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "%w( w )")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('sp', "p(/ /)")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# `nl' event always means End-Of-Statement.
|
|
|
|
def test_nl
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1 + 1\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n", "\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1 + 1\n2 + 2\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1 +\n1")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1;\n")
|
2004-09-19 23:03:12 -04:00
|
|
|
assert_equal ["\r\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1 + 1\r\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('nl', "1;\r\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ignored_nl
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', '')
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1 + 1\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1 + 1\n2 + 2\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1 +\n1")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal ["\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1;\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1 + 1\r\n")
|
2004-09-19 23:03:12 -04:00
|
|
|
assert_equal ["\r\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('ignored_nl', "1;\r\n")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test___end__
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('__end__', "")
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal ["__END__"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('__end__', "__END__")
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal ["__END__\n"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('__end__', "__END__\n")
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal ["__END__\n"],
|
2004-10-09 14:20:46 -04:00
|
|
|
Ripper.tokenize("__END__\njunk junk junk")
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal ["__END__"],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('__end__', "1\n__END__")
|
2004-09-20 02:14:09 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('__end__', "print('__END__')")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_CHAR
|
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('CHAR', "")
|
2013-05-08 00:07:22 -04:00
|
|
|
assert_equal ["?a"],
|
|
|
|
scan('CHAR', "?a")
|
2004-09-12 13:34:30 -04:00
|
|
|
assert_equal [],
|
2004-09-23 06:49:11 -04:00
|
|
|
scan('CHAR', "@ivar")
|
2004-09-12 13:34:30 -04:00
|
|
|
end
|
|
|
|
|
2005-09-22 16:58:10 -04:00
|
|
|
def test_label
|
2014-07-25 07:22:49 -04:00
|
|
|
assert_equal %w(foo:),
|
|
|
|
scan('label', '{foo: 1}')
|
2005-09-22 16:58:10 -04:00
|
|
|
end
|
|
|
|
|
2014-09-19 21:48:43 -04:00
|
|
|
def test_label_end
|
|
|
|
assert_equal %w(":),
|
|
|
|
scan('label_end', '{"foo-bar": 1}')
|
|
|
|
end
|
|
|
|
|
2005-09-22 17:22:23 -04:00
|
|
|
def test_tlambda
|
2014-07-25 07:22:49 -04:00
|
|
|
assert_equal %w(->),
|
|
|
|
scan('tlambda', '->{}')
|
2005-09-22 16:58:10 -04:00
|
|
|
end
|
|
|
|
|
2005-09-22 17:22:23 -04:00
|
|
|
def test_tlambeg
|
2014-07-25 07:22:49 -04:00
|
|
|
assert_equal %w({),
|
|
|
|
scan('tlambeg', '-> {}')
|
2005-09-22 16:58:10 -04:00
|
|
|
end
|
|
|
|
|
2005-09-22 17:22:23 -04:00
|
|
|
def test_tlambda_arg
|
2014-07-25 07:22:49 -04:00
|
|
|
assert_equal %w(),
|
|
|
|
scan('tlambda_arg', '-> {}')
|
2005-09-22 16:58:10 -04:00
|
|
|
end
|
|
|
|
|
2009-10-20 02:35:26 -04:00
|
|
|
end if ripper_test
|