Merge branch 'master' of github.com:iij/mruby-io

This commit is contained in:
Tomoyuki Sahara
2015-10-20 15:13:28 +09:00
4 changed files with 30 additions and 2 deletions
+9
View File
@@ -108,6 +108,11 @@ class IO
raise IOError
end
def <<(str)
write(str)
self
end
def eof?
return true if @buf && @buf.size > 0
@@ -136,6 +141,10 @@ class IO
seek(i, SEEK_SET)
end
def rewind
seek(0, SEEK_SET)
end
def seek(i, whence = SEEK_SET)
raise IOError if closed?
@pos = sysseek(i, whence)
+1
View File
@@ -20,6 +20,7 @@ MRuby::Build.new do |conf|
conf.gembox 'default'
conf.gem :git => 'https://github.com/iij/mruby-env.git'
conf.enable_test
conf.gem File.expand_path(File.dirname(__FILE__))
end
+1 -2
View File
@@ -525,8 +525,7 @@ mrb_value
mrb_io_sysseek(mrb_state *mrb, mrb_value io)
{
struct mrb_io *fptr;
int pos;
mrb_int offset, whence = -1;
mrb_int pos, offset, whence = -1;
mrb_get_args(mrb, "i|i", &offset, &whence);
if (whence < 0) {
+19
View File
@@ -150,6 +150,14 @@ assert('IO#write', '15.2.20.5.20') do
true
end
assert('IO#<<') do
io = IO.open(IO.sysopen($mrbtest_io_wfname))
io << "" << ""
assert_equal 0, io.pos
io.close
true
end
assert('IO.for_fd') do
fd = IO.sysopen($mrbtest_io_rfname)
io = IO.for_fd(fd)
@@ -248,6 +256,17 @@ assert('IO#pos=, IO#seek') do
io.closed?
end
assert('IO#rewind') do
fd = IO.sysopen $mrbtest_io_rfname
io = IO.new fd
assert_equal 'm', io.getc
assert_equal 1, io.pos
assert_equal 0, io.rewind
assert_equal 0, io.pos
io.close
io.closed?
end
assert('IO#gets') do
fd = IO.sysopen $mrbtest_io_rfname
io = IO.new fd