summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-28 04:06:14 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-28 04:06:14 +0000
commit0a7785431c05d6b1854af94465f49c6b6d27a304 (patch)
tree0aee16ded97f0211567451d5b584fd01f926a2c5 /test
parent37377b24d1aa2cff005da926115e4b690ded3545 (diff)
* io.c (interpret_seek_whence): support SEEK_DATA and SEEK_HOLE.
These are whences for lseek(2) supported by Linux since version 3.1. [ruby-core:56123] [Feature #8671] * test/ruby/test_io.rb: Add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 999be76aacb..469498cb0c0 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1565,6 +1565,22 @@ class TestIO < Test::Unit::TestCase
f.seek(2, IO::SEEK_CUR)
assert_equal("r\nbaz\n", f.read)
}
+
+ if defined?(IO::SEEK_DATA)
+ open(t.path) { |f|
+ assert_equal("foo\n", f.gets)
+ f.seek(0, IO::SEEK_DATA)
+ assert_equal("foo\nbar\nbaz\n", f.read)
+ }
+ end
+
+ if defined?(IO::SEEK_HOLE)
+ open(t.path) { |f|2
+ assert_equal("foo\n", f.gets)
+ f.seek(0, IO::SEEK_HOLE)
+ assert_equal("", f.read)
+ }
+ end
}
end
@@ -1585,6 +1601,22 @@ class TestIO < Test::Unit::TestCase
f.seek(2, :CUR)
assert_equal("r\nbaz\n", f.read)
}
+
+ if defined?(IO::SEEK_DATA)
+ open(t.path) { |f|
+ assert_equal("foo\n", f.gets)
+ f.seek(0, :DATA)
+ assert_equal("foo\nbar\nbaz\n", f.read)
+ }
+ end
+
+ if defined?(IO::SEEK_HOLE)
+ open(t.path) { |f|
+ assert_equal("foo\n", f.gets)
+ f.seek(0, :HOLE)
+ assert_equal("", f.read)
+ }
+ end
}
end