diff options
| author | takahashim <[email protected]> | 2015-09-27 00:29:17 +0900 |
|---|---|---|
| committer | takahashim <[email protected]> | 2015-09-27 00:29:17 +0900 |
| commit | c26f998ed5976c453afc4ba68aa24aaa9d0c0d4e (patch) | |
| tree | 082a6f0b90f340d3da99eaf69b536635589ddab4 | |
| parent | 6c4d39412f693301eca34daf7a413248839be404 (diff) | |
| download | mruby-c26f998ed5976c453afc4ba68aa24aaa9d0c0d4e.tar.gz mruby-c26f998ed5976c453afc4ba68aa24aaa9d0c0d4e.zip | |
support IO#<<
| -rw-r--r-- | mrblib/io.rb | 5 | ||||
| -rw-r--r-- | test/io.rb | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/mrblib/io.rb b/mrblib/io.rb index c838b96e5..30eb47404 100644 --- a/mrblib/io.rb +++ b/mrblib/io.rb @@ -108,6 +108,11 @@ class IO raise IOError end + def <<(str) + write(str) + self + end + def eof? return true if @buf && @buf.size > 0 diff --git a/test/io.rb b/test/io.rb index b828fef49..a5ce7e049 100644 --- a/test/io.rb +++ b/test/io.rb @@ -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) |
