diff options
| author | Tomoyuki Sahara <[email protected]> | 2016-08-08 10:12:20 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-08-08 10:12:20 +0900 |
| commit | b341ee7c1217d314af673a280e099c222b1c5727 (patch) | |
| tree | ed9699176c4e0a22f3fdec4bd4eab4995500d116 /test | |
| parent | 9ccf03e5ae76a08538dbbd1e86a6a39f7d4610ca (diff) | |
| parent | d2c1f4d10b29040aad3fbf38b2b27fe46e145e63 (diff) | |
| download | mruby-b341ee7c1217d314af673a280e099c222b1c5727.tar.gz mruby-b341ee7c1217d314af673a280e099c222b1c5727.zip | |
Merge pull request #63 from ksss/opt
Enable option :in, :out, :err to IO.popen
Diffstat (limited to 'test')
| -rw-r--r-- | test/io.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/io.rb b/test/io.rb index f0f30e3ce..1b0a2d52e 100644 --- a/test/io.rb +++ b/test/io.rb @@ -393,6 +393,44 @@ assert('IO.popen') do end end +assert('IO.popen with in option') do + begin + IO.pipe do |r, w| + w.write 'hello' + w.close + assert_equal "hello", IO.popen("cat", "r", in: r) { |i| i.read } + assert_equal "", r.read + end + assert_raise(ArgumentError) { IO.popen("hello", "r", in: Object.new) } + rescue NotImplementedError => e + skip e.message + end +end + +assert('IO.popen with out option') do + begin + IO.pipe do |r, w| + IO.popen("echo 'hello'", "w", out: w) {} + w.close + assert_equal "hello\n", r.read + end + rescue NotImplementedError => e + skip e.message + end +end + +assert('IO.popen with err option') do + begin + IO.pipe do |r, w| + assert_equal "", IO.popen("echo 'hello' 1>&2", "r", err: w) { |i| i.read } + w.close + assert_equal "hello\n", r.read + end + rescue NotImplementedError => e + skip e.message + end +end + assert('IO.read') do # empty file fd = IO.sysopen $mrbtest_io_wfname, "w" |
