test/test_lineinput.rb in review-2.3.0 vs test/test_lineinput.rb in review-2.4.0
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
require 'test_helper'
require 'lineinput'
require 'tempfile'
require 'stringio'
@@ -15,11 +13,11 @@
end
def test_gets
content = "abc\ndef\r\nghi\rjkl"
do_test_gets(StringIO.new(content))
- Tempfile.open("lineinput_test") do |io|
+ Tempfile.open('lineinput_test') do |io|
io.print content
io.rewind
do_test_gets(io)
end
end
@@ -104,31 +102,31 @@
content = "abc\ndef\nghi"
io = StringIO.new(content)
li = LineInput.new(io)
data = ''
- li.each {|l| data << l }
+ li.each { |l| data << l }
assert_equal content, data
end
def test_while_match
io = StringIO.new("abc\ndef\nghi")
li = LineInput.new(io)
li.while_match(/^[ad]/) {}
assert_equal 2, li.lineno
- assert_equal "ghi", li.gets
+ assert_equal 'ghi', li.gets
end
def test_getlines_while
io = StringIO.new("abc\ndef\nghi")
li = LineInput.new(io)
buf = li.getlines_while(/^[ad]/)
assert_equal ["abc\n", "def\n"], buf
assert_equal 2, li.lineno
- assert_equal "ghi", li.gets
+ assert_equal 'ghi', li.gets
end
def test_until_match
io = StringIO.new("abc\ndef\nghi")
li = LineInput.new(io)
@@ -151,21 +149,21 @@
def test_until_terminator
io = StringIO.new("abc\n//}\ndef\nghi\n//}\njkl\nmno")
li = LineInput.new(io)
data = ''
- li.until_terminator(%r<\A//\}>) {|l| data << l }
+ li.until_terminator(%r<\A//\}>) { |l| data << l }
assert_equal "abc\n", data
assert_equal 2, li.lineno
data = ''
- li.until_terminator(%r<\A//\}>) {|l| data << l }
+ li.until_terminator(%r<\A//\}>) { |l| data << l }
assert_equal "def\nghi\n", data
assert_equal 5, li.lineno
data = ''
- li.until_terminator(%r<\A//\}>) {|l| data << l }
+ li.until_terminator(%r<\A//\}>) { |l| data << l }
assert_equal "jkl\nmno", data
assert_equal 8, li.lineno
end
def test_until_terminator2
@@ -175,6 +173,5 @@
data = li.getblock(%r<\A//\}>)
assert_equal ["abc\n", "def\n"], data
assert_equal 3, li.lineno
end
end
-