summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-io/test/io.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-09-14 15:58:11 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-09-14 23:21:44 +0900
commit6f1c08f7d8a43a5d220aca7a5c449a8d04d3017b (patch)
tree909b7875490061854828f40e5495e8cc335c631d /mrbgems/mruby-io/test/io.rb
parentdcc2d44d930ee5dea7e737ad6fa298d3f4bf9f59 (diff)
downloadmruby-6f1c08f7d8a43a5d220aca7a5c449a8d04d3017b.tar.gz
mruby-6f1c08f7d8a43a5d220aca7a5c449a8d04d3017b.zip
Replace `String#byteslice` by custom `IO._bufread`.
`byteslice` creates 2 string objects. `_bufread` creates one, and modifies the original buffer string, that is more efficient.
Diffstat (limited to 'mrbgems/mruby-io/test/io.rb')
-rw-r--r--mrbgems/mruby-io/test/io.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb
index 3aaa109a8..e3024cf9a 100644
--- a/mrbgems/mruby-io/test/io.rb
+++ b/mrbgems/mruby-io/test/io.rb
@@ -129,10 +129,11 @@ end
assert "IO#read(n) with n > IO::BUF_SIZE" do
skip "pipe is not supported on this platform" if MRubyIOTestUtil.win?
- r,w = IO.pipe
- n = IO::BUF_SIZE+1
- w.write 'a'*n
- assert_equal r.read(n), 'a'*n
+ IO.pipe do |r,w|
+ n = IO::BUF_SIZE+1
+ w.write 'a'*n
+ assert_equal 'a'*n, r.read(n)
+ end
end
assert('IO#readchar', '15.2.20.5.15') do