diff options
Diffstat (limited to 'spec/ruby/core/numeric')
-rw-r--r-- | spec/ruby/core/numeric/clone_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/core/numeric/fdiv_spec.rb | 1 | ||||
-rw-r--r-- | spec/ruby/core/numeric/magnitude_spec.rb | 1 | ||||
-rw-r--r-- | spec/ruby/core/numeric/quo_spec.rb | 3 | ||||
-rw-r--r-- | spec/ruby/core/numeric/remainder_spec.rb | 3 | ||||
-rw-r--r-- | spec/ruby/core/numeric/shared/quo.rb | 7 | ||||
-rw-r--r-- | spec/ruby/core/numeric/shared/step.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/numeric/step_spec.rb | 85 |
8 files changed, 14 insertions, 104 deletions
diff --git a/spec/ruby/core/numeric/clone_spec.rb b/spec/ruby/core/numeric/clone_spec.rb index c3b06ca0c9..423cec85dd 100644 --- a/spec/ruby/core/numeric/clone_spec.rb +++ b/spec/ruby/core/numeric/clone_spec.rb @@ -14,7 +14,7 @@ describe "Numeric#clone" do 1.clone.frozen?.should == true end - it "accepts optonal keyword argument :freeze" do + it "accepts optional keyword argument :freeze" do value = 1 value.clone(freeze: true).should equal(value) end @@ -23,10 +23,8 @@ describe "Numeric#clone" do -> { 1.clone(freeze: false) }.should raise_error(ArgumentError, /can't unfreeze/) end - ruby_version_is "3.0" do - it "does not change frozen status if passed freeze: nil" do - value = 1 - value.clone(freeze: nil).should equal(value) - end + it "does not change frozen status if passed freeze: nil" do + value = 1 + value.clone(freeze: nil).should equal(value) end end diff --git a/spec/ruby/core/numeric/fdiv_spec.rb b/spec/ruby/core/numeric/fdiv_spec.rb index 907e5d343c..e97fa77f79 100644 --- a/spec/ruby/core/numeric/fdiv_spec.rb +++ b/spec/ruby/core/numeric/fdiv_spec.rb @@ -1,5 +1,4 @@ require_relative '../../spec_helper' -require_relative 'shared/quo' describe "Numeric#fdiv" do it "coerces self with #to_f" do diff --git a/spec/ruby/core/numeric/magnitude_spec.rb b/spec/ruby/core/numeric/magnitude_spec.rb index 7a3290b036..1371dff21f 100644 --- a/spec/ruby/core/numeric/magnitude_spec.rb +++ b/spec/ruby/core/numeric/magnitude_spec.rb @@ -1,3 +1,4 @@ +require_relative "../../spec_helper" require_relative 'shared/abs' describe "Numeric#magnitude" do diff --git a/spec/ruby/core/numeric/quo_spec.rb b/spec/ruby/core/numeric/quo_spec.rb index b4a23fd476..6e3ce7a374 100644 --- a/spec/ruby/core/numeric/quo_spec.rb +++ b/spec/ruby/core/numeric/quo_spec.rb @@ -1,6 +1,5 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -require_relative 'shared/quo' describe "Numeric#quo" do it "returns the result of self divided by the given Integer as a Rational" do @@ -20,7 +19,7 @@ describe "Numeric#quo" do -> { 10.quo(0) }.should raise_error(ZeroDivisionError) -> { -10.quo(0) }.should raise_error(ZeroDivisionError) -> { bignum_value.quo(0) }.should raise_error(ZeroDivisionError) - -> { -bignum_value.quo(0) }.should raise_error(ZeroDivisionError) + -> { (-bignum_value).quo(0) }.should raise_error(ZeroDivisionError) end it "calls #to_r to convert the object to a Rational" do diff --git a/spec/ruby/core/numeric/remainder_spec.rb b/spec/ruby/core/numeric/remainder_spec.rb index 1e2f5f3a96..674fa22d8e 100644 --- a/spec/ruby/core/numeric/remainder_spec.rb +++ b/spec/ruby/core/numeric/remainder_spec.rb @@ -6,6 +6,9 @@ describe "Numeric#remainder" do @obj = NumericSpecs::Subclass.new @result = mock("Numeric#% result") @other = mock("Passed Object") + ruby_version_is "3.3" do + @other.should_receive(:coerce).with(@obj).and_return([@obj, @other]) + end end it "returns the result of calling self#% with other if self is 0" do diff --git a/spec/ruby/core/numeric/shared/quo.rb b/spec/ruby/core/numeric/shared/quo.rb deleted file mode 100644 index 2392636fe7..0000000000 --- a/spec/ruby/core/numeric/shared/quo.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :numeric_quo_18, shared: true do - it "returns the result of calling self#/ with other" do - obj = mock_numeric('numeric') - obj.should_receive(:/).with(19).and_return(:result) - obj.send(@method, 19).should == :result - end -end diff --git a/spec/ruby/core/numeric/shared/step.rb b/spec/ruby/core/numeric/shared/step.rb index 8b1a7bf307..977ec6de02 100644 --- a/spec/ruby/core/numeric/shared/step.rb +++ b/spec/ruby/core/numeric/shared/step.rb @@ -5,7 +5,7 @@ require_relative '../fixtures/classes' # To be able to do it, the @step ivar must contain a Proc that transforms # the step call arguments passed as positional arguments to the style of # arguments pretended to test. -describe :numeric_step, :shared => true do +describe :numeric_step, shared: true do before :each do ScratchPad.record [] @prc = -> x { ScratchPad << x } @@ -258,12 +258,6 @@ describe :numeric_step, :shared => true do describe "when no block is given" do step_enum_class = Enumerator::ArithmeticSequence - ruby_version_is ""..."3.0" do - it "returns an #{step_enum_class} when step is 0" do - @step.call(1, 2, 0).should be_an_instance_of(step_enum_class) - end - end - it "returns an #{step_enum_class} when not passed a block and self > stop" do @step.call(1, 0, 2).should be_an_instance_of(step_enum_class) end diff --git a/spec/ruby/core/numeric/step_spec.rb b/spec/ruby/core/numeric/step_spec.rb index 095c474fec..1705fb1b4e 100644 --- a/spec/ruby/core/numeric/step_spec.rb +++ b/spec/ruby/core/numeric/step_spec.rb @@ -23,30 +23,8 @@ describe "Numeric#step" do describe "when no block is given" do step_enum_class = Enumerator::ArithmeticSequence - ruby_version_is ""..."3.0" do - it "returns an #{step_enum_class} when step is 0" do - 1.step(5, 0).should be_an_instance_of(step_enum_class) - end - - it "returns an #{step_enum_class} when step is 0.0" do - 1.step(2, 0.0).should be_an_instance_of(step_enum_class) - end - end - describe "returned #{step_enum_class}" do describe "size" do - ruby_version_is ""..."3.0" do - it "is infinity when step is 0" do - enum = 1.step(5, 0) - enum.size.should == Float::INFINITY - end - - it "is infinity when step is 0.0" do - enum = 1.step(2, 0.0) - enum.size.should == Float::INFINITY - end - end - it "defaults to an infinite size" do enum = 1.step enum.size.should == Float::INFINITY @@ -63,22 +41,6 @@ describe "Numeric#step" do end describe 'with keyword arguments' do - ruby_version_is ""..."3.0" do - it "doesn't raise an error when step is 0" do - -> { 1.step(to: 5, by: 0) { break } }.should_not raise_error - end - - it "doesn't raise an error when step is 0.0" do - -> { 1.step(to: 2, by: 0.0) { break } }.should_not raise_error - end - - it "should loop over self when step is 0 or 0.0" do - 1.step(to: 2, by: 0.0).take(5).should eql [1.0, 1.0, 1.0, 1.0, 1.0] - 1.step(to: 2, by: 0).take(5).should eql [1, 1, 1, 1, 1] - 1.1.step(to: 2, by: 0).take(5).should eql [1.1, 1.1, 1.1, 1.1, 1.1] - end - end - describe "when no block is given" do describe "returned Enumerator" do describe "size" do @@ -86,16 +48,6 @@ describe "Numeric#step" do 1.step(by: 42).size.should == infinity_value end - ruby_version_is ""..."3.0" do - it "should return infinity_value when step is 0" do - 1.step(to: 5, by: 0).size.should == infinity_value - end - - it "should return infinity_value when step is 0.0" do - 1.step(to: 2, by: 0.0).size.should == infinity_value - end - end - it "should return infinity_value when ascending towards a limit of Float::INFINITY" do 1.step(to: Float::INFINITY, by: 42).size.should == infinity_value end @@ -128,24 +80,12 @@ describe "Numeric#step" do end describe 'with mixed arguments' do - ruby_version_is ""..."3.0" do - it "doesn't raise an error when step is 0" do - -> { 1.step(5, by: 0) { break } }.should_not raise_error - end - - it "doesn't raise an error when step is 0.0" do - -> { 1.step(2, by: 0.0) { break } }.should_not raise_error - end + it " raises an ArgumentError when step is 0" do + -> { 1.step(5, by: 0) { break } }.should raise_error(ArgumentError) end - ruby_version_is "3.0" do - it " raises an ArgumentError when step is 0" do - -> { 1.step(5, by: 0) { break } }.should raise_error(ArgumentError) - end - - it "raises an ArgumentError when step is 0.0" do - -> { 1.step(2, by: 0.0) { break } }.should raise_error(ArgumentError) - end + it "raises an ArgumentError when step is 0.0" do + -> { 1.step(2, by: 0.0) { break } }.should raise_error(ArgumentError) end it "raises a ArgumentError when limit and to are defined" do @@ -156,26 +96,9 @@ describe "Numeric#step" do -> { 1.step(5, 1, by: 5) { break } }.should raise_error(ArgumentError) end - ruby_version_is ""..."3.0" do - it "should loop over self when step is 0 or 0.0" do - 1.step(2, by: 0.0).take(5).should eql [1.0, 1.0, 1.0, 1.0, 1.0] - 1.step(2, by: 0).take(5).should eql [1, 1, 1, 1, 1] - 1.1.step(2, by: 0).take(5).should eql [1.1, 1.1, 1.1, 1.1, 1.1] - end - end - describe "when no block is given" do describe "returned Enumerator" do describe "size" do - ruby_version_is ""..."3.0" do - it "should return infinity_value when step is 0" do - 1.step(5, by: 0).size.should == infinity_value - end - - it "should return infinity_value when step is 0.0" do - 1.step(2, by: 0.0).size.should == infinity_value - end - end end end end |