diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-20 08:25:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-20 08:25:02 +0000 |
commit | a1140a3ebff3fcd9940e2777a22e8a060d3500df (patch) | |
tree | f42d111461c93cbeb88bfcd9ed7ab9ffc1f23766 /test/ruby/test_argf.rb | |
parent | 883770f4c01f486bd0fbb8dcb7eb5cf4b7d6e784 (diff) | |
download | ruby-a1140a3ebff3fcd9940e2777a22e8a060d3500df.tar.gz |
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/test_argf.rb')
-rw-r--r-- | test/ruby/test_argf.rb | 12 |
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' |