aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_io.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_io.rb
parent2742b6bc432e82a502a7fe7234090592a31dc432 (diff)
downloadruby-c47c095b9740e7c19d6fdca29ab661c1089221d4.tar.gz
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_io.rb')
-rw-r--r--test/ruby/test_io.rb37
1 files changed, 34 insertions, 3 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index d509a9bfe2..0b3b5591e3 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -260,6 +260,19 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_codepoints
+ make_tempfile {|t|
+ bug2959 = '[ruby-core:28650]'
+ a = ""
+ File.open(t, 'rt') {|f|
+ assert_warn(/deprecated/) {
+ f.codepoints {|c| a << c}
+ }
+ }
+ assert_equal("foo\nbar\nbaz\n", a, bug2959)
+ }
+ end
+
def test_rubydev33072
t = make_tempfile
path = t.path
@@ -1303,21 +1316,28 @@ class TestIO < Test::Unit::TestCase
end
def test_lines
+ verbose, $VERBOSE = $VERBOSE, nil
pipe(proc do |w|
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
end, proc do |r|
- e = r.lines
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.lines
+ }
assert_equal("foo\n", e.next)
assert_equal("bar\n", e.next)
assert_equal("baz\n", e.next)
assert_raise(StopIteration) { e.next }
end)
+ ensure
+ $VERBOSE = verbose
end
def test_bytes
+ verbose, $VERBOSE = $VERBOSE, nil
pipe(proc do |w|
w.binmode
w.puts "foo"
@@ -1325,27 +1345,38 @@ class TestIO < Test::Unit::TestCase
w.puts "baz"
w.close
end, proc do |r|
- e = r.bytes
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.bytes
+ }
(%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
assert_equal(c.ord, e.next)
end
assert_raise(StopIteration) { e.next }
end)
+ ensure
+ $VERBOSE = verbose
end
def test_chars
+ verbose, $VERBOSE = $VERBOSE, nil
pipe(proc do |w|
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
end, proc do |r|
- e = r.chars
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.chars
+ }
(%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
assert_equal(c, e.next)
end
assert_raise(StopIteration) { e.next }
end)
+ ensure
+ $VERBOSE = verbose
end
def test_readbyte