Skip to content

Commit 771315a

Browse files
committed
Add test_class_tokenize_lambda
1 parent 7dbe38e commit 771315a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/test_rdoc_ruby_lex.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,36 @@ def test_class_tokenize_identifier_high_unicode
238238
assert_equal expected, tokens.first
239239
end
240240

241+
def test_class_tokenize_lambda
242+
tokens = RDoc::RubyLex.tokenize 'a = -> x, y { x + y }', nil
243+
244+
expected = [
245+
@TK::TkIDENTIFIER.new( 0, 1, 0, 'a'),
246+
@TK::TkSPACE .new( 1, 1, 1, ' '),
247+
@TK::TkASSIGN .new( 2, 1, 2, '='),
248+
@TK::TkSPACE .new( 3, 1, 3, ' '),
249+
@TK::TkLAMBDA .new( 4, 1, 4, '->'),
250+
@TK::TkSPACE .new( 6, 1, 6, ' '),
251+
@TK::TkIDENTIFIER.new( 7, 1, 7, 'x'),
252+
@TK::TkCOMMA .new( 8, 1, 8, ','),
253+
@TK::TkSPACE .new( 9, 1, 9, ' '),
254+
@TK::TkIDENTIFIER.new(10, 1, 10, 'y'),
255+
@TK::TkSPACE .new(11, 1, 11, ' '),
256+
@TK::TkfLBRACE .new(12, 1, 12, '{'),
257+
@TK::TkSPACE .new(13, 1, 13, ' '),
258+
@TK::TkIDENTIFIER.new(14, 1, 14, 'x'),
259+
@TK::TkSPACE .new(15, 1, 15, ' '),
260+
@TK::TkPLUS .new(16, 1, 16, '+'),
261+
@TK::TkSPACE .new(17, 1, 17, ' '),
262+
@TK::TkIDENTIFIER.new(18, 1, 18, 'y'),
263+
@TK::TkSPACE .new(19, 1, 19, ' '),
264+
@TK::TkRBRACE .new(20, 1, 20, '}'),
265+
@TK::TkNL .new(21, 1, 21, "\n")
266+
]
267+
268+
assert_equal expected, tokens
269+
end
270+
241271
def test_class_tokenize_percent_1
242272
tokens = RDoc::RubyLex.tokenize 'v%10==10', nil
243273

0 commit comments

Comments
 (0)