summaryrefslogtreecommitdiff
path: root/test/irb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-29 12:20:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-29 12:20:26 +0000
commit3abb4948b248da896e0bf03de6caf147543a5432 (patch)
tree4b80f2e661bc54e2a7a77889ccfc281e8fbddc0a /test/irb
parent25ad4a790780338fd348dffca07bb7fc29dbb6c9 (diff)
downloadruby-3abb4948b248da896e0bf03de6caf147543a5432.tar.gz
test for comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_ruby-lex.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/irb/test_ruby-lex.rb b/test/irb/test_ruby-lex.rb
index f7d331bc24..b5255e9b53 100644
--- a/test/irb/test_ruby-lex.rb
+++ b/test/irb/test_ruby-lex.rb
@@ -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