summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-20 08:25:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-20 08:25:02 +0000
commit9b6e1a9f38ee299b7b2a2282ec7071d54a1494a4 (patch)
treef42d111461c93cbeb88bfcd9ed7ab9ffc1f23766 /test/ruby
parentdc2d359b70725e890eff902e25bc0176245b0784 (diff)
io.c: update argf lineno
* io.c (argf_block_call_line): update line number in non-global ARGF instance. [ruby-core:78728] [Bug #13051] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_argf.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index d4be87e954..5c3805ca19 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -137,6 +137,18 @@ class TestArgf < Test::Unit::TestCase
INPUT
end
+ def test_new_lineno
+ f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
+ result = []
+ f.each {|line| result << [f.lineno, line]; break if result.size == 3}
+ assert_equal(3, f.lineno)
+ assert_equal((1..3).map {|i| [i, "#{i}\n"]}, result)
+
+ f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
+ f.each_char.to_a
+ assert_equal(0, f.lineno)
+ end
+
def test_inplace
assert_in_out_err(["-", @t1.path, @t2.path, @t3.path], <<-INPUT, [], [])
ARGF.inplace_mode = '.bak'