add tests for #tell and #seek.

This commit is contained in:
Tomoyuki Sahara
2014-06-20 15:25:10 +09:00
parent 193c82174f
commit 6cc24d0793
+20 -2
View File
@@ -1,5 +1,3 @@
# Note: testing telldir(3) and seekdir(3) in portable manner is very hard.
assert('Dir') do
assert_equal(Class, Dir.class)
end
@@ -105,6 +103,26 @@ assert('Dir#rewind') do
assert_true a.include? "b"
end
# Note: behaviors of seekdir(3) and telldir(3) are so platform-dependent
# that we cannot write portable tests here.
assert('Dir#tell') do
n = nil
Dir.open(DirTest.sandbox) { |d|
n = d.tell
}
assert_true n.is_a? Integer
end
assert('Dir#seek') do
d1 = Dir.open(DirTest.sandbox)
d1.read
n = d1.tell
d1.read
d2 = d1.seek(n)
assert_equal d1, d2
end
assert('DirTest.teardown') do
DirTest.teardown
end