ruby-changes:45381
From: nobu <ko1@a...>
Date: Sun, 29 Jan 2017 21:20:31 +0900 (JST)
Subject: [ruby-changes:45381] nobu:r57454 (trunk): test for comment
nobu 2017-01-29 21:20:26 +0900 (Sun, 29 Jan 2017) New Revision: 57454 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57454 Log: test for comment Modified files: trunk/test/irb/test_ruby-lex.rb Index: test/irb/test_ruby-lex.rb =================================================================== --- test/irb/test_ruby-lex.rb (revision 57453) +++ test/irb/test_ruby-lex.rb (revision 57454) @@ -1,6 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/test/irb/test_ruby-lex.rb#L1 # frozen_string_literal: false require 'test/unit' require 'irb/ruby-lex' +require 'stringio' module TestIRB class TestRubyLex < Test::Unit::TestCase @@ -10,9 +11,28 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_ruby-lex.rb#L11 def test_set_input_proc called = false - @scanner.set_input(self) {|x| called = true; nil} - assert_nil(@scanner.lex) + @scanner.set_input(nil) {called = true; nil} + @scanner.each_top_level_statement {} assert(called) end + + def test_comment + assert_equal([["#\n", 1]], top_level_statement("#\n")) + end + + def top_level_statement(lines) + input = InputLines.new(lines, "r") + scanned = [] + @scanner.set_input(input) + @scanner.each_top_level_statement {|*e| + scanned << e + yield(*e) if defined?(yield) + } + scanned + end + + class InputLines < StringIO + alias encoding external_encoding + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/