зеркало из https://github.com/github/ruby.git
test for comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
25ad4a7907
Коммит
3abb4948b2
|
@ -1,6 +1,7 @@
|
|||
# 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
|
|||
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче