summaryrefslogtreecommitdiff
path: root/test/ruby/ut_eof.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-05 02:54:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-05 02:54:48 +0000
commit7fbf13f7f21876b4206701cb3913fab5e7d82843 (patch)
tree75d78dfa2134f18d318611d3ca7e3f74e417e5d9 /test/ruby/ut_eof.rb
parente3ed2691934d4f7e11b3d9469a7f744ac9e4b433 (diff)
* ext/stringio/stringio.c (strio_read): follow IO#read.
* test/ruby/ut_eof.rb, test/ruby/test_file.rb, test/ruby/test_pipe.rb, test/stringio/test_stringio.rb: add EOF test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/ut_eof.rb')
-rw-r--r--test/ruby/ut_eof.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/ruby/ut_eof.rb b/test/ruby/ut_eof.rb
new file mode 100644
index 00000000000..d1ad9a5fea0
--- /dev/null
+++ b/test/ruby/ut_eof.rb
@@ -0,0 +1,46 @@
+require 'test/unit'
+
+module TestEOF
+ def test_eof_0
+ open_file("") {|f|
+ assert_equal("", f.read(0))
+ assert_equal("", f.read(0))
+ assert_equal("", f.read)
+ assert_equal(nil, f.read(0))
+ assert_equal(nil, f.read(0))
+ }
+ open_file("") {|f|
+ assert_equal(nil, f.read(1))
+ assert_equal(nil, f.read)
+ assert_equal(nil, f.read(1))
+ }
+ end
+
+ def test_eof_1
+ open_file("a") {|f|
+ assert_equal("", f.read(0))
+ assert_equal("a", f.read(1))
+ assert_equal("" , f.read(0))
+ assert_equal("" , f.read(0))
+ assert_equal("", f.read)
+ assert_equal(nil, f.read(0))
+ assert_equal(nil, f.read(0))
+ }
+ open_file("a") {|f|
+ assert_equal("a", f.read(1))
+ assert_equal(nil, f.read(1))
+ }
+ open_file("a") {|f|
+ assert_equal("a", f.read(2))
+ assert_equal(nil, f.read(1))
+ assert_equal(nil, f.read)
+ assert_equal(nil, f.read(1))
+ }
+ open_file("a") {|f|
+ assert_equal("a", f.read)
+ assert_equal(nil, f.read(1))
+ assert_equal(nil, f.read)
+ assert_equal(nil, f.read(1))
+ }
+ end
+end