summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 03:08:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 03:08:52 +0000
commit7e35d6fcaa773afc4f492689471f5687cc41c814 (patch)
treea360ed93ddb53145839bf8d5fc1c6f496b4a323a /test
parentd7166624bf70c2fe9f0b067065b9fd490de16d20 (diff)
add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index d877f5e832..af161eae26 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2122,4 +2122,39 @@ End
end
assert_equal(File.size(__FILE__), buf.unpack('i!')[0])
end
+
+ def test_setpos
+ mkcdtmpdir {
+ File.open("tmp.txt", "w") {|f|
+ f.puts "a"
+ f.puts "bc"
+ f.puts "def"
+ }
+ pos1 = pos2 = pos3 = nil
+ File.open("tmp.txt") {|f|
+ assert_equal("a\n", f.gets)
+ pos1 = f.pos
+ assert_equal("bc\n", f.gets)
+ pos2 = f.pos
+ assert_equal("def\n", f.gets)
+ pos3 = f.pos
+ assert_equal(nil, f.gets)
+ }
+ File.open("tmp.txt") {|f|
+ f.pos = pos1
+ assert_equal("bc\n", f.gets)
+ assert_equal("def\n", f.gets)
+ assert_equal(nil, f.gets)
+ }
+ File.open("tmp.txt") {|f|
+ f.pos = pos2
+ assert_equal("def\n", f.gets)
+ assert_equal(nil, f.gets)
+ }
+ File.open("tmp.txt") {|f|
+ f.pos = pos3
+ assert_equal(nil, f.gets)
+ }
+ }
+ end
end