From b81ea661dbc3c31073de782a8b0b9f3f86e3de5e Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 3 Apr 2013 12:25:09 +0000 Subject: * io.c (rb_io_seek_m): Accept :CUR, :END, :SET as "whence" argument. (interpret_seek_whence): New function. [ruby-dev:45818] [Feature #6643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 8ccb5de03b..b968bb6fcd 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1514,6 +1514,26 @@ class TestIO < Test::Unit::TestCase } end + def test_seek_symwhence + make_tempfile {|t| + open(t.path) { |f| + f.seek(9, :SET) + assert_equal("az\n", f.read) + } + + open(t.path) { |f| + f.seek(-4, :END) + assert_equal("baz\n", f.read) + } + + open(t.path) { |f| + assert_equal("foo\n", f.gets) + f.seek(2, :CUR) + assert_equal("r\nbaz\n", f.read) + } + } + end + def test_sysseek make_tempfile {|t| open(t.path) do |f| -- cgit v1.2.3