* ext/stringio/stringio.c (strio_read): adjust behavior at reading
beyond EOF to IO. [ruby-dev:22205] * test/ruby/ut_eof.rb (TestEOF::Seek): test behaviors at reading beyond EOF. * test/ruby/test_file.rb, * test/stringio/test_stringio.rb: include TestEOF::Seek test case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d6ce2b7b2b
commit
6395c3b38d
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Wed Dec 10 17:16:06 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_read): adjust behavior at reading
|
||||||
|
beyond EOF to IO. [ruby-dev:22205]
|
||||||
|
|
||||||
|
* test/ruby/ut_eof.rb (TestEOF::Seek): test behaviors at reading
|
||||||
|
beyond EOF.
|
||||||
|
|
||||||
|
* test/ruby/test_file.rb, * test/stringio/test_stringio.rb:
|
||||||
|
include TestEOF::Seek test case.
|
||||||
|
|
||||||
Wed Dec 10 15:01:19 2003 Shugo Maeda <shugo@ruby-lang.org>
|
Wed Dec 10 15:01:19 2003 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* test/monitor/test_monitor.rb (test_cond): use Queue#deq
|
* test/monitor/test_monitor.rb (test_cond): use Queue#deq
|
||||||
|
@ -867,6 +867,7 @@ strio_read(argc, argv, self)
|
|||||||
}
|
}
|
||||||
str = rb_str_substr(ptr->string, ptr->pos, len);
|
str = rb_str_substr(ptr->string, ptr->pos, len);
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
|
if (!(ptr->flags & STRIO_EOF)) str = rb_str_new(0, 0);
|
||||||
ptr->flags |= STRIO_EOF;
|
ptr->flags |= STRIO_EOF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -41,4 +41,6 @@ class TestFile < Test::Unit::TestCase
|
|||||||
yield f
|
yield f
|
||||||
end
|
end
|
||||||
alias open_file_rw open_file
|
alias open_file_rw open_file
|
||||||
|
|
||||||
|
include TestEOF::Seek
|
||||||
end
|
end
|
||||||
|
@ -53,4 +53,31 @@ module TestEOF
|
|||||||
assert_equal(nil, f.read(1))
|
assert_equal(nil, f.read(1))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Seek
|
||||||
|
def open_file_seek(content, pos)
|
||||||
|
open_file(content) do |f|
|
||||||
|
f.seek(pos)
|
||||||
|
yield f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_eof_0_seek
|
||||||
|
open_file_seek("", 10) {|f|
|
||||||
|
assert_equal("", f.read)
|
||||||
|
assert_equal(nil, f.read)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_eof_1_seek
|
||||||
|
open_file_seek("a", 10) {|f|
|
||||||
|
assert_equal("", f.read)
|
||||||
|
assert_equal(nil, f.read)
|
||||||
|
}
|
||||||
|
open_file_seek("a", 1) {|f|
|
||||||
|
assert_equal("", f.read)
|
||||||
|
assert_equal(nil, f.read)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,4 +12,6 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
yield f
|
yield f
|
||||||
end
|
end
|
||||||
alias open_file_rw open_file
|
alias open_file_rw open_file
|
||||||
|
|
||||||
|
include TestEOF::Seek
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user