summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-12 09:04:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-12 09:04:49 +0000
commitf8844ba78b1027a94453dc052b504b6939454c3e (patch)
tree7bd74e92f90db80d8eb0384911bb122a7543e92b /test
parent289a3196224056a4367341e4310517b112830626 (diff)
add tests for reading an extended file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_file.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index f86d929..2458dde 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -67,4 +67,42 @@ class TestFile < Test::Unit::TestCase
f.truncate(3)
assert_equal(nil, f.gets)
end
+
+ def test_read_all_extended_file
+ f = Tempfile.new("test-extended-file")
+ assert_nil(f.getc)
+ open(f.path, "w") {|g| g.print "a" }
+ assert_equal("a", f.read)
+ end
+
+ def test_gets_extended_file
+ f = Tempfile.new("test-extended-file")
+ assert_nil(f.getc)
+ open(f.path, "w") {|g| g.print "a" }
+ assert_equal("a", f.gets("a"))
+ end
+
+ def test_gets_para_extended_file
+ f = Tempfile.new("test-extended-file")
+ assert_nil(f.getc)
+ open(f.path, "w") {|g| g.print "\na" }
+ assert_equal("a", f.gets(""))
+ end
+
+ def test_each_byte_extended_file
+ f = Tempfile.new("test-extended-file")
+ assert_nil(f.getc)
+ open(f.path, "w") {|g| g.print "a" }
+ result = []
+ f.each_byte {|b| result << b }
+ assert_equal([?a], result)
+ end
+
+ def test_getc_extended_file
+ f = Tempfile.new("test-extended-file")
+ assert_nil(f.getc)
+ open(f.path, "w") {|g| g.print "a" }
+ assert_equal(?a, f.getc)
+ end
+
end