diff options
Diffstat (limited to 'spec/ruby/shared')
-rw-r--r-- | spec/ruby/shared/queue/deque.rb | 23 | ||||
-rw-r--r-- | spec/ruby/shared/rational/marshal_dump.rb | 5 | ||||
-rw-r--r-- | spec/ruby/shared/rational/marshal_load.rb | 5 | ||||
-rw-r--r-- | spec/ruby/shared/rational/quo.rb | 5 | ||||
-rw-r--r-- | spec/ruby/shared/string/times.rb | 18 | ||||
-rw-r--r-- | spec/ruby/shared/types/rb_num2dbl_fails.rb | 17 |
6 files changed, 44 insertions, 29 deletions
diff --git a/spec/ruby/shared/queue/deque.rb b/spec/ruby/shared/queue/deque.rb index 616e56ec8a..9e6b45009d 100644 --- a/spec/ruby/shared/queue/deque.rb +++ b/spec/ruby/shared/queue/deque.rb @@ -37,6 +37,15 @@ describe :queue_deq, shared: true do q.send(@method).should == 1 end + it "converts false-ish for non_blocking to boolean" do + q = @object.call + q << 1 + q << 2 + + q.send(@method, false).should == 1 + q.send(@method, nil).should == 2 + end + it "returns nil for a closed empty queue" do q = @object.call q.close @@ -114,6 +123,12 @@ describe :queue_deq, shared: true do "can't set a timeout if non_block is enabled", ) end + + it "returns nil for a closed empty queue" do + q = @object.call + q.close + q.send(@method, timeout: 0).should == nil + end end end @@ -143,5 +158,13 @@ describe :queue_deq, shared: true do q.close -> { q.send(@method, true) }.should raise_error(ThreadError) end + + it "converts true-ish non_blocking argument to true" do + q = @object.call + + -> { q.send(@method, true) }.should raise_error(ThreadError) + -> { q.send(@method, 1) }.should raise_error(ThreadError) + -> { q.send(@method, "") }.should raise_error(ThreadError) + end end end diff --git a/spec/ruby/shared/rational/marshal_dump.rb b/spec/ruby/shared/rational/marshal_dump.rb deleted file mode 100644 index 09782b45a5..0000000000 --- a/spec/ruby/shared/rational/marshal_dump.rb +++ /dev/null @@ -1,5 +0,0 @@ -require_relative '../../spec_helper' - -describe :rational_marshal_dump, shared: true do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/shared/rational/marshal_load.rb b/spec/ruby/shared/rational/marshal_load.rb deleted file mode 100644 index 20bdd6fdf4..0000000000 --- a/spec/ruby/shared/rational/marshal_load.rb +++ /dev/null @@ -1,5 +0,0 @@ -require_relative '../../spec_helper' - -describe :rational_marshal_load, shared: true do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/shared/rational/quo.rb b/spec/ruby/shared/rational/quo.rb deleted file mode 100644 index 53b32fed2f..0000000000 --- a/spec/ruby/shared/rational/quo.rb +++ /dev/null @@ -1,5 +0,0 @@ -require_relative '../../spec_helper' - -describe :rational_quo, shared: true do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb index 8ca9507570..be3b622f73 100644 --- a/spec/ruby/shared/string/times.rb +++ b/spec/ruby/shared/string/times.rb @@ -32,20 +32,10 @@ describe :string_times, shared: true do @object.call("", max_long).should == "" end - ruby_version_is ''...'3.0' do - it "returns subclass instances" do - @object.call(MyString.new("cool"), 0).should be_an_instance_of(MyString) - @object.call(MyString.new("cool"), 1).should be_an_instance_of(MyString) - @object.call(MyString.new("cool"), 2).should be_an_instance_of(MyString) - end - end - - ruby_version_is '3.0' do - it "returns String instances" do - @object.call(MyString.new("cool"), 0).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 1).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 2).should be_an_instance_of(String) - end + it "returns String instances" do + @object.call(MyString.new("cool"), 0).should be_an_instance_of(String) + @object.call(MyString.new("cool"), 1).should be_an_instance_of(String) + @object.call(MyString.new("cool"), 2).should be_an_instance_of(String) end it "returns a String in the same encoding as self" do diff --git a/spec/ruby/shared/types/rb_num2dbl_fails.rb b/spec/ruby/shared/types/rb_num2dbl_fails.rb new file mode 100644 index 0000000000..ec7cc11986 --- /dev/null +++ b/spec/ruby/shared/types/rb_num2dbl_fails.rb @@ -0,0 +1,17 @@ +# +# Shared tests for rb_num2dbl related conversion failures. +# +# Usage example: +# it_behaves_like :rb_num2dbl_fails, nil, -> v { o = A.new; o.foo(v) } +# + +describe :rb_num2dbl_fails, shared: true do + it "fails if string is provided" do + -> { @object.call("123") }.should raise_error(TypeError, "no implicit conversion to float from string") + end + + it "fails if boolean is provided" do + -> { @object.call(true) }.should raise_error(TypeError, "no implicit conversion to float from true") + -> { @object.call(false) }.should raise_error(TypeError, "no implicit conversion to float from false") + end +end |