summaryrefslogtreecommitdiff
path: root/test/ruby/test_argf.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-22 17:22:04 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-22 17:22:04 +0000
commitc47c095b9740e7c19d6fdca29ab661c1089221d4 (patch)
tree6a8204e2977b6743db056b348b2167cdbc11a06b /test/ruby/test_argf.rb
parent2742b6bc432e82a502a7fe7234090592a31dc432 (diff)
Deprecate #{lines,bytes,chars,codepoints} of IO-likes.
* io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints): Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF. [Feature #6670] * ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars) (strio_codepoints): Deprecate StringIO#{lines,bytes,chars,codepoints}. [Feature #6670] * ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes): Deprecate Zlib::GzipReader#{lines,bytes}. [Feature #6670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_argf.rb')
-rw-r--r--test/ruby/test_argf.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 7fb9348c1e2..8243a6ed861 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -771,26 +771,54 @@ class TestArgf < Test::Unit::TestCase
assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)
end
+ def test_lines
+ ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ $stderr = $stdout
+ s = []
+ ARGF.lines {|l| s << l }
+ p s
+ SRC
+ assert_match(/deprecated/, f.gets)
+ assert_equal("[\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\"]\n", f.read)
+ end
+ end
+
+ def test_lines
+ ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ $stderr = $stdout
+ print Marshal.dump(ARGF.bytes.to_a)
+ SRC
+ assert_match(/deprecated/, f.gets)
+ assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
+ end
+ end
+
def test_bytes
- ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ $stderr = $stdout
print Marshal.dump(ARGF.bytes.to_a)
SRC
+ assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end
def test_chars
- ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ $stderr = $stdout
print [Marshal.dump(ARGF.chars.to_a)].pack('m')
SRC
+ assert_match(/deprecated/, f.gets)
assert_equal(["1", "\n", "2", "\n", "3", "\n", "4", "\n", "5", "\n", "6", "\n"], Marshal.load(f.read.unpack('m').first))
end
end
def test_codepoints
- ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+ $stderr = $stdout
print Marshal.dump(ARGF.codepoints.to_a)
SRC
+ assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end