summaryrefslogtreecommitdiff
path: root/spec/ruby/core/io/getbyte_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/io/getbyte_spec.rb')
-rw-r--r--spec/ruby/core/io/getbyte_spec.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/ruby/core/io/getbyte_spec.rb b/spec/ruby/core/io/getbyte_spec.rb
new file mode 100644
index 0000000000..668d81519c
--- /dev/null
+++ b/spec/ruby/core/io/getbyte_spec.rb
@@ -0,0 +1,58 @@
+# -*- encoding: utf-8 -*-
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
+
+describe "IO#getbyte" do
+ before :each do
+ @io = IOSpecs.io_fixture "lines.txt"
+ end
+
+ after :each do
+ @io.close if @io
+ end
+
+ it "returns the next byte from the stream" do
+ @io.readline.should == "Voici la ligne une.\n"
+ letters = @io.getbyte, @io.getbyte, @io.getbyte, @io.getbyte, @io.getbyte
+ letters.should == [81, 117, 105, 32, 195]
+ end
+
+ it "returns nil when invoked at the end of the stream" do
+ @io.read
+ @io.getbyte.should == nil
+ end
+
+ it "raises an IOError on closed stream" do
+ -> { IOSpecs.closed_io.getbyte }.should.raise(IOError)
+ end
+end
+
+describe "IO#getbyte" do
+ before :each do
+ @io = IOSpecs.io_fixture "empty.txt"
+ end
+
+ after :each do
+ @io.close if @io
+ end
+
+ it "returns nil on empty stream" do
+ @io.getbyte.should == nil
+ end
+end
+
+describe "IO#getbyte" do
+ before :each do
+ @name = tmp("io_getbyte.txt")
+ @io = new_io(@name, 'w')
+ end
+
+ after :each do
+ @io.close if @io
+ rm_r @name if @name
+ end
+
+ it "raises an IOError if the stream is not readable" do
+ -> { @io.getbyte }.should.raise(IOError)
+ end
+end
39622fc5d77ab0f0'>Update to ruby/spec@15c9619Benoit Daloze 2019-03-28Update to ruby/spec@e81b3cderegon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2019-02-21Update to ruby/spec@7a16e01eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-11-27Update to ruby/spec@cdd6ff7eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-10-27spec/../shared/exit.rb: move the mingw guard to herek0kubun from terminate_spec.rb, as suggested here: https://github.com/ruby/ruby/commit/c7220bd3dea0a113b81f267cc3b656da7d7d7abb#commitcomment-31068714 to guard other inclusions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-10-27Update to ruby/spec@8b743a3eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-10-13kill_spec.rb: exclude spec unstable on MinGWk0kubun like r64991, until we get helpful error logs on worker death or the unstability is fixed. Since mspec worker randomly dies on MinGW, maybe it should have an option to retry worker death. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-10-10spec: add comments to re-enable specs for MinGW [ci skip]k0kubun r64918 and r64988 should not be kept forever. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-10-10terminate_spec.rb: exclude unstable spec for MinGWk0kubun This spec seems to randomly kill mspec worker. https://ci.appveyor.com/project/ruby/ruby/builds/19390874/job/wv1bsm8skd4e1pxl To make CI stable, let me exclude this for MinGW until we get some logs that help debugging or resolve that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-09-25Update to ruby/spec@241f9e7eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-08-03Update to ruby/spec@9be7c7eeregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-06-27Update to ruby/spec@a454137eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-06-13Update to ruby/spec@4bc7a2beregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-04-28Update to ruby/spec@6f38a82eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-04-25Avoid "should_not raise_error" in Thread#raise speceregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-04-25Fix style in Thread#raise speceregon * Add space after { and before }. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-04-25Use Thread.pass in loop{} to check interrupts more ofteneregon * The spec now runs in ~5ms vs ~100ms before. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-03-04Update to ruby/spec@c1b568beregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2018-01-29Update to ruby/spec@83063a3eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-27Update to ruby/spec@0fe33aceregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-21Simplify Thread#[]= speceregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-20fix threading bug.ko1 * spec/ruby/core/thread/element_set_spec.rb: `t` can be uninitialized. Use `Thread.current` explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-14The main Thread should have report_on_exception=true for consistencyeregon * Adapt test and add specs. * See [Feature #14143] [ruby-core:84227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-12Set Thread.report_on_exception=true by default to report exceptions in Threadseregon * [Feature #14143] [ruby-core:83979] * vm.c (vm_init2): Set Thread.report_on_exception to true. * thread.c (thread_start_func_2): Add indication the message is caused by report_on_exception = true. * spec/ruby: Specify the new behavior. * test/ruby/test_thread.rb: Adapt and improve tests for Thread.report_on_exception and Thread#report_on_exception. * test/ruby/test_thread.rb, test/ruby/test_exception.rb: Unset report_on_exception for tests expecting no extra output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-12-01Update to ruby/spec@bacedc5eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-10-28Update to ruby/spec@a6b8805eregon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2017-09-20Move spec/rubyspec to spec/ruby for consistencyeregon * Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e