summaryrefslogtreecommitdiff
path: root/spec/ruby/core/integer
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-08 19:43:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-01 15:36:20 +0900
commit826f44834fe11f3f9c52343443a15b6c83466889 (patch)
treef2c2abed62db1c750515cd8b0fbac6442b6d4200 /spec/ruby/core/integer
parent3a2073e61b6ccce6d07d31ebd89d4c385b9a55f2 (diff)
Drop support for ruby 2.4 from ruby/spec
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2892
Diffstat (limited to 'spec/ruby/core/integer')
-rw-r--r--spec/ruby/core/integer/allbits_spec.rb62
-rw-r--r--spec/ruby/core/integer/anybits_spec.rb60
-rw-r--r--spec/ruby/core/integer/comparison_spec.rb22
-rw-r--r--spec/ruby/core/integer/divide_spec.rb8
-rw-r--r--spec/ruby/core/integer/gt_spec.rb8
-rw-r--r--spec/ruby/core/integer/gte_spec.rb8
-rw-r--r--spec/ruby/core/integer/lt_spec.rb8
-rw-r--r--spec/ruby/core/integer/lte_spec.rb8
-rw-r--r--spec/ruby/core/integer/minus_spec.rb8
-rw-r--r--spec/ruby/core/integer/multiply_spec.rb8
-rw-r--r--spec/ruby/core/integer/nobits_spec.rb60
-rw-r--r--spec/ruby/core/integer/plus_spec.rb8
-rw-r--r--spec/ruby/core/integer/pow_spec.rb70
-rw-r--r--spec/ruby/core/integer/round_spec.rb26
-rw-r--r--spec/ruby/core/integer/shared/arithmetic_coerce.rb20
-rw-r--r--spec/ruby/core/integer/shared/integer_rounding.rb16
-rw-r--r--spec/ruby/core/integer/sqrt_spec.rb46
17 files changed, 164 insertions, 282 deletions
diff --git a/spec/ruby/core/integer/allbits_spec.rb b/spec/ruby/core/integer/allbits_spec.rb
index f4a6fe9905..11acb52e1f 100644
--- a/spec/ruby/core/integer/allbits_spec.rb
+++ b/spec/ruby/core/integer/allbits_spec.rb
@@ -1,39 +1,37 @@
require_relative '../../spec_helper'
-ruby_version_is '2.5' do
- describe "Integer#allbits?" do
- it "returns true iff all the bits of the argument are set in the receiver" do
- 42.allbits?(42).should == true
- 0b1010_1010.allbits?(0b1000_0010).should == true
- 0b1010_1010.allbits?(0b1000_0001).should == false
- 0b1000_0010.allbits?(0b1010_1010).should == false
- (0b1010_1010 | bignum_value).allbits?(0b1000_0010 | bignum_value).should == true
- (0b1010_1010 | bignum_value).allbits?(0b1000_0001 | bignum_value).should == false
- (0b1000_0010 | bignum_value).allbits?(0b1010_1010 | bignum_value).should == false
- end
+describe "Integer#allbits?" do
+ it "returns true iff all the bits of the argument are set in the receiver" do
+ 42.allbits?(42).should == true
+ 0b1010_1010.allbits?(0b1000_0010).should == true
+ 0b1010_1010.allbits?(0b1000_0001).should == false
+ 0b1000_0010.allbits?(0b1010_1010).should == false
+ (0b1010_1010 | bignum_value).allbits?(0b1000_0010 | bignum_value).should == true
+ (0b1010_1010 | bignum_value).allbits?(0b1000_0001 | bignum_value).should == false
+ (0b1000_0010 | bignum_value).allbits?(0b1010_1010 | bignum_value).should == false
+ end
- it "handles negative values using two's complement notation" do
- (~0b1).allbits?(42).should == true
- (-42).allbits?(-42).should == true
- (~0b1010_1010).allbits?(~0b1110_1011).should == true
- (~0b1010_1010).allbits?(~0b1000_0010).should == false
- (~(0b1010_1010 | bignum_value)).allbits?(~(0b1110_1011 | bignum_value)).should == true
- (~(0b1010_1010 | bignum_value)).allbits?(~(0b1000_0010 | bignum_value)).should == false
- end
+ it "handles negative values using two's complement notation" do
+ (~0b1).allbits?(42).should == true
+ (-42).allbits?(-42).should == true
+ (~0b1010_1010).allbits?(~0b1110_1011).should == true
+ (~0b1010_1010).allbits?(~0b1000_0010).should == false
+ (~(0b1010_1010 | bignum_value)).allbits?(~(0b1110_1011 | bignum_value)).should == true
+ (~(0b1010_1010 | bignum_value)).allbits?(~(0b1000_0010 | bignum_value)).should == false
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.allbits?(obj).should == true
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.allbits?(obj).should == true
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.allbits?(obj)
- }.should raise_error(TypeError)
- -> { 13.allbits?("10") }.should raise_error(TypeError)
- -> { 13.allbits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ -> {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.allbits?(obj)
+ }.should raise_error(TypeError)
+ -> { 13.allbits?("10") }.should raise_error(TypeError)
+ -> { 13.allbits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/anybits_spec.rb b/spec/ruby/core/integer/anybits_spec.rb
index 91f349258a..7e510fd00b 100644
--- a/spec/ruby/core/integer/anybits_spec.rb
+++ b/spec/ruby/core/integer/anybits_spec.rb
@@ -1,38 +1,36 @@
require_relative '../../spec_helper'
-ruby_version_is '2.5' do
- describe "Integer#anybits?" do
- it "returns true iff all the bits of the argument are set in the receiver" do
- 42.anybits?(42).should == true
- 0b1010_1010.anybits?(0b1000_0010).should == true
- 0b1010_1010.anybits?(0b1000_0001).should == true
- 0b1000_0010.anybits?(0b0010_1100).should == false
- different_bignum = (2 * bignum_value) & (~bignum_value)
- (0b1010_1010 | different_bignum).anybits?(0b1000_0010 | bignum_value).should == true
- (0b1010_1010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == true
- (0b1000_0010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == false
- end
+describe "Integer#anybits?" do
+ it "returns true iff all the bits of the argument are set in the receiver" do
+ 42.anybits?(42).should == true
+ 0b1010_1010.anybits?(0b1000_0010).should == true
+ 0b1010_1010.anybits?(0b1000_0001).should == true
+ 0b1000_0010.anybits?(0b0010_1100).should == false
+ different_bignum = (2 * bignum_value) & (~bignum_value)
+ (0b1010_1010 | different_bignum).anybits?(0b1000_0010 | bignum_value).should == true
+ (0b1010_1010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == true
+ (0b1000_0010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == false
+ end
- it "handles negative values using two's complement notation" do
- (~42).anybits?(42).should == false
- (-42).anybits?(-42).should == true
- (~0b100).anybits?(~0b1).should == true
- (~(0b100 | bignum_value)).anybits?(~(0b1 | bignum_value)).should == true
- end
+ it "handles negative values using two's complement notation" do
+ (~42).anybits?(42).should == false
+ (-42).anybits?(-42).should == true
+ (~0b100).anybits?(~0b1).should == true
+ (~(0b100 | bignum_value)).anybits?(~(0b1 | bignum_value)).should == true
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.anybits?(obj).should == true
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.anybits?(obj).should == true
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.anybits?(obj)
- }.should raise_error(TypeError)
- -> { 13.anybits?("10") }.should raise_error(TypeError)
- -> { 13.anybits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ -> {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.anybits?(obj)
+ }.should raise_error(TypeError)
+ -> { 13.anybits?("10") }.should raise_error(TypeError)
+ -> { 13.anybits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/comparison_spec.rb b/spec/ruby/core/integer/comparison_spec.rb
index 2ff557c7c6..db050aa8b9 100644
--- a/spec/ruby/core/integer/comparison_spec.rb
+++ b/spec/ruby/core/integer/comparison_spec.rb
@@ -124,23 +124,11 @@ describe "Integer#<=>" do
@big <=> @num
end
- ruby_version_is ""..."2.5" do
- it "returns nil if #coerce raises an exception" do
- @num.should_receive(:coerce).with(@big).and_raise(RuntimeError)
- -> {
- @result = (@big <=> @num)
- }.should complain(/Numerical comparison operators will no more rescue exceptions/)
- @result.should be_nil
- end
- end
-
- ruby_version_is "2.5" do
- it "lets the exception go through if #coerce raises an exception" do
- @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error"))
- -> {
- @big <=> @num
- }.should raise_error(RuntimeError, "my error")
- end
+ it "lets the exception go through if #coerce raises an exception" do
+ @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error"))
+ -> {
+ @big <=> @num
+ }.should raise_error(RuntimeError, "my error")
end
it "raises an exception if #coerce raises a non-StandardError exception" do
diff --git a/spec/ruby/core/integer/divide_spec.rb b/spec/ruby/core/integer/divide_spec.rb
index a32d68c229..5ac2dc538d 100644
--- a/spec/ruby/core/integer/divide_spec.rb
+++ b/spec/ruby/core/integer/divide_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/arithmetic_coerce'
describe "Integer#/" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :/
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :/
- end
+ it_behaves_like :integer_arithmetic_coerce_not_rescue, :/
context "fixnum" do
it "returns self divided by the given argument" do
diff --git a/spec/ruby/core/integer/gt_spec.rb b/spec/ruby/core/integer/gt_spec.rb
index 428a6f6888..f0179e566d 100644
--- a/spec/ruby/core/integer/gt_spec.rb
+++ b/spec/ruby/core/integer/gt_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison_coerce'
describe "Integer#>" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :>
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :>
- end
+ it_behaves_like :integer_comparison_coerce_not_rescue, :>
context "fixnum" do
it "returns true if self is greater than the given argument" do
diff --git a/spec/ruby/core/integer/gte_spec.rb b/spec/ruby/core/integer/gte_spec.rb
index ce1385c360..6237fc2c51 100644
--- a/spec/ruby/core/integer/gte_spec.rb
+++ b/spec/ruby/core/integer/gte_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison_coerce'
describe "Integer#>=" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :>=
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :>=
- end
+ it_behaves_like :integer_comparison_coerce_not_rescue, :>=
context "fixnum" do
it "returns true if self is greater than or equal to the given argument" do
diff --git a/spec/ruby/core/integer/lt_spec.rb b/spec/ruby/core/integer/lt_spec.rb
index dfe2d9e369..c182f82555 100644
--- a/spec/ruby/core/integer/lt_spec.rb
+++ b/spec/ruby/core/integer/lt_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison_coerce'
describe "Integer#<" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :<
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :<
- end
+ it_behaves_like :integer_comparison_coerce_not_rescue, :<
context "fixnum" do
it "returns true if self is less than the given argument" do
diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb
index 40a89f094a..65b71d77f2 100644
--- a/spec/ruby/core/integer/lte_spec.rb
+++ b/spec/ruby/core/integer/lte_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison_coerce'
describe "Integer#<=" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :<=
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :<=
- end
+ it_behaves_like :integer_comparison_coerce_not_rescue, :<=
context "fixnum" do
it "returns true if self is less than or equal to other" do
diff --git a/spec/ruby/core/integer/minus_spec.rb b/spec/ruby/core/integer/minus_spec.rb
index 34dd36c1a7..ce50c8752f 100644
--- a/spec/ruby/core/integer/minus_spec.rb
+++ b/spec/ruby/core/integer/minus_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/arithmetic_coerce'
describe "Integer#-" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :-
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :-
- end
+ it_behaves_like :integer_arithmetic_coerce_not_rescue, :-
context "fixnum" do
it "returns self minus the given Integer" do
diff --git a/spec/ruby/core/integer/multiply_spec.rb b/spec/ruby/core/integer/multiply_spec.rb
index 919786cbcc..d1e9c2640d 100644
--- a/spec/ruby/core/integer/multiply_spec.rb
+++ b/spec/ruby/core/integer/multiply_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/arithmetic_coerce'
describe "Integer#*" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :*
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :*
- end
+ it_behaves_like :integer_arithmetic_coerce_not_rescue, :*
context "fixnum" do
it "returns self multiplied by the given Integer" do
diff --git a/spec/ruby/core/integer/nobits_spec.rb b/spec/ruby/core/integer/nobits_spec.rb
index af3b9e7db0..b132a4a724 100644
--- a/spec/ruby/core/integer/nobits_spec.rb
+++ b/spec/ruby/core/integer/nobits_spec.rb
@@ -1,38 +1,36 @@
require_relative '../../spec_helper'
-ruby_version_is '2.5' do
- describe "Integer#nobits?" do
- it "returns true iff all no bits of the argument are set in the receiver" do
- 42.nobits?(42).should == false
- 0b1010_1010.nobits?(0b1000_0010).should == false
- 0b1010_1010.nobits?(0b1000_0001).should == false
- 0b0100_0101.nobits?(0b1010_1010).should == true
- different_bignum = (2 * bignum_value) & (~bignum_value)
- (0b1010_1010 | different_bignum).nobits?(0b1000_0010 | bignum_value).should == false
- (0b1010_1010 | different_bignum).nobits?(0b1000_0001 | bignum_value).should == false
- (0b0100_0101 | different_bignum).nobits?(0b1010_1010 | bignum_value).should == true
- end
+describe "Integer#nobits?" do
+ it "returns true iff all no bits of the argument are set in the receiver" do
+ 42.nobits?(42).should == false
+ 0b1010_1010.nobits?(0b1000_0010).should == false
+ 0b1010_1010.nobits?(0b1000_0001).should == false
+ 0b0100_0101.nobits?(0b1010_1010).should == true
+ different_bignum = (2 * bignum_value) & (~bignum_value)
+ (0b1010_1010 | different_bignum).nobits?(0b1000_0010 | bignum_value).should == false
+ (0b1010_1010 | different_bignum).nobits?(0b1000_0001 | bignum_value).should == false
+ (0b0100_0101 | different_bignum).nobits?(0b1010_1010 | bignum_value).should == true
+ end
- it "handles negative values using two's complement notation" do
- (~0b1101).nobits?(0b1101).should == true
- (-42).nobits?(-42).should == false
- (~0b1101).nobits?(~0b10).should == false
- (~(0b1101 | bignum_value)).nobits?(~(0b10 | bignum_value)).should == false
- end
+ it "handles negative values using two's complement notation" do
+ (~0b1101).nobits?(0b1101).should == true
+ (-42).nobits?(-42).should == false
+ (~0b1101).nobits?(~0b10).should == false
+ (~(0b1101 | bignum_value)).nobits?(~(0b10 | bignum_value)).should == false
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.nobits?(obj).should == false
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.nobits?(obj).should == false
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.nobits?(obj)
- }.should raise_error(TypeError)
- -> { 13.nobits?("10") }.should raise_error(TypeError)
- -> { 13.nobits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ -> {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.nobits?(obj)
+ }.should raise_error(TypeError)
+ -> { 13.nobits?("10") }.should raise_error(TypeError)
+ -> { 13.nobits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb
index 7e919a16db..be626c3305 100644
--- a/spec/ruby/core/integer/plus_spec.rb
+++ b/spec/ruby/core/integer/plus_spec.rb
@@ -2,13 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/arithmetic_coerce'
describe "Integer#+" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :+
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :+
- end
+ it_behaves_like :integer_arithmetic_coerce_not_rescue, :+
context "fixnum" do
it "returns self plus the given Integer" do
diff --git a/spec/ruby/core/integer/pow_spec.rb b/spec/ruby/core/integer/pow_spec.rb
index ed14c40a27..f3fb1da916 100644
--- a/spec/ruby/core/integer/pow_spec.rb
+++ b/spec/ruby/core/integer/pow_spec.rb
@@ -2,48 +2,46 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/exponent'
-ruby_version_is "2.5" do
- describe "Integer#pow" do
- context "one argument is passed" do
- it_behaves_like :integer_exponent, :pow
- end
+describe "Integer#pow" do
+ context "one argument is passed" do
+ it_behaves_like :integer_exponent, :pow
+ end
- context "two arguments are passed" do
- it "returns modulo of self raised to the given power" do
- 2.pow(5, 12).should == 8
- 2.pow(6, 13).should == 12
- 2.pow(7, 14).should == 2
- 2.pow(8, 15).should == 1
- end
+ context "two arguments are passed" do
+ it "returns modulo of self raised to the given power" do
+ 2.pow(5, 12).should == 8
+ 2.pow(6, 13).should == 12
+ 2.pow(7, 14).should == 2
+ 2.pow(8, 15).should == 1
+ end
- it "works well with bignums" do
- 2.pow(61, 5843009213693951).should eql 3697379018277258
- 2.pow(62, 5843009213693952).should eql 1551748822859776
- 2.pow(63, 5843009213693953).should eql 3103497645717974
- 2.pow(64, 5843009213693954).should eql 363986077738838
- end
+ it "works well with bignums" do
+ 2.pow(61, 5843009213693951).should eql 3697379018277258
+ 2.pow(62, 5843009213693952).should eql 1551748822859776
+ 2.pow(63, 5843009213693953).should eql 3103497645717974
+ 2.pow(64, 5843009213693954).should eql 363986077738838
+ end
- it "handles sign like #divmod does" do
- 2.pow(5, 12).should == 8
- 2.pow(5, -12).should == -4
- -2.pow(5, 12).should == 4
- -2.pow(5, -12).should == -8
- end
+ it "handles sign like #divmod does" do
+ 2.pow(5, 12).should == 8
+ 2.pow(5, -12).should == -4
+ -2.pow(5, 12).should == 4
+ -2.pow(5, -12).should == -8
+ end
- it "ensures all arguments are integers" do
- -> { 2.pow(5, 12.0) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
- -> { 2.pow(5, Rational(12, 1)) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
- end
+ it "ensures all arguments are integers" do
+ -> { 2.pow(5, 12.0) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
+ -> { 2.pow(5, Rational(12, 1)) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
+ end
- it "raises TypeError for non-numeric value" do
- -> { 2.pow(5, "12") }.should raise_error(TypeError)
- -> { 2.pow(5, []) }.should raise_error(TypeError)
- -> { 2.pow(5, nil) }.should raise_error(TypeError)
- end
+ it "raises TypeError for non-numeric value" do
+ -> { 2.pow(5, "12") }.should raise_error(TypeError)
+ -> { 2.pow(5, []) }.should raise_error(TypeError)
+ -> { 2.pow(5, nil) }.should raise_error(TypeError)
+ end
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { 2.pow(5, 0) }.should raise_error(ZeroDivisionError)
- end
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ -> { 2.pow(5, 0) }.should raise_error(ZeroDivisionError)
end
end
end
diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb
index feb6d475d3..45ac126fd3 100644
--- a/spec/ruby/core/integer/round_spec.rb
+++ b/spec/ruby/core/integer/round_spec.rb
@@ -6,14 +6,6 @@ describe "Integer#round" do
it_behaves_like :integer_to_i, :round
it_behaves_like :integer_rounding_positive_precision, :round
- ruby_version_is ""..."2.5" do # Not just since 2.4
- it "rounds itself as a float if passed a positive precision" do
- [2, -4, 10**70, -10**100].each do |v|
- v.round(42).should eql(v.to_f)
- end
- end
- end
-
# redmine:5228
it "returns itself rounded if passed a negative value" do
+249.round(-2).should eql(+200)
@@ -78,20 +70,10 @@ describe "Integer#round" do
(-25).round(-1, half: nil).should eql(-30)
end
- ruby_version_is "2.4"..."2.5" do
- it "returns itself as a float if passed a positive precision and the half option" do
- 35.round(1, half: :up).should eql(35.0)
- 35.round(1, half: :down).should eql(35.0)
- 35.round(1, half: :even).should eql(35.0)
- end
- end
-
- ruby_version_is "2.5" do
- it "returns itself if passed a positive precision and the half option" do
- 35.round(1, half: :up).should eql(35)
- 35.round(1, half: :down).should eql(35)
- 35.round(1, half: :even).should eql(35)
- end
+ it "returns itself if passed a positive precision and the half option" do
+ 35.round(1, half: :up).should eql(35)
+ 35.round(1, half: :down).should eql(35)
+ 35.round(1, half: :even).should eql(35)
end
it "raises ArgumentError for an unknown rounding mode" do
diff --git a/spec/ruby/core/integer/shared/arithmetic_coerce.rb b/spec/ruby/core/integer/shared/arithmetic_coerce.rb
index 4c0cbcb999..1260192df1 100644
--- a/spec/ruby/core/integer/shared/arithmetic_coerce.rb
+++ b/spec/ruby/core/integer/shared/arithmetic_coerce.rb
@@ -1,25 +1,5 @@
require_relative '../fixtures/classes'
-describe :integer_arithmetic_coerce_rescue, shared: true do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
-
- # e.g. 1 + b
- -> { 1.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Integer/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. 1 + b
- -> { 1.send(@method, b) }.should raise_error(exception)
- end
- end
-end
-
describe :integer_arithmetic_coerce_not_rescue, shared: true do
it "does not rescue exception raised in other#coerce" do
b = mock("numeric with failed #coerce")
diff --git a/spec/ruby/core/integer/shared/integer_rounding.rb b/spec/ruby/core/integer/shared/integer_rounding.rb
index 3fb6e830ef..56d1819f84 100644
--- a/spec/ruby/core/integer/shared/integer_rounding.rb
+++ b/spec/ruby/core/integer/shared/integer_rounding.rb
@@ -11,19 +11,9 @@ describe :integer_rounding_positive_precision, shared: true do
end
end
- ruby_version_is "2.4"..."2.5" do
- it "returns itself as a float if passed a positive precision" do
- [2, -4, 10**70, -10**100].each do |v|
- v.send(@method, 42).should eql(v.to_f)
- end
- end
- end
-
- ruby_version_is "2.5" do
- it "returns itself if passed a positive precision" do
- [2, -4, 10**70, -10**100].each do |v|
- v.send(@method, 42).should eql(v)
- end
+ it "returns itself if passed a positive precision" do
+ [2, -4, 10**70, -10**100].each do |v|
+ v.send(@method, 42).should eql(v)
end
end
end
diff --git a/spec/ruby/core/integer/sqrt_spec.rb b/spec/ruby/core/integer/sqrt_spec.rb
index e56da058a0..4149ca2cc9 100644
--- a/spec/ruby/core/integer/sqrt_spec.rb
+++ b/spec/ruby/core/integer/sqrt_spec.rb
@@ -1,33 +1,31 @@
require_relative '../../spec_helper'
-ruby_version_is "2.5" do
- describe "Integer.sqrt" do
- it "returns an integer" do
- Integer.sqrt(10).should be_kind_of(Integer)
- end
+describe "Integer.sqrt" do
+ it "returns an integer" do
+ Integer.sqrt(10).should be_kind_of(Integer)
+ end
- it "returns the integer square root of the argument" do
- Integer.sqrt(0).should == 0
- Integer.sqrt(1).should == 1
- Integer.sqrt(24).should == 4
- Integer.sqrt(25).should == 5
- Integer.sqrt(10**400).should == 10**200
- end
+ it "returns the integer square root of the argument" do
+ Integer.sqrt(0).should == 0
+ Integer.sqrt(1).should == 1
+ Integer.sqrt(24).should == 4
+ Integer.sqrt(25).should == 5
+ Integer.sqrt(10**400).should == 10**200
+ end
- it "raises a Math::DomainError if the argument is negative" do
- -> { Integer.sqrt(-4) }.should raise_error(Math::DomainError)
- end
+ it "raises a Math::DomainError if the argument is negative" do
+ -> { Integer.sqrt(-4) }.should raise_error(Math::DomainError)
+ end
- it "accepts any argument that can be coerced to Integer" do
- Integer.sqrt(10.0).should == 3
- end
+ it "accepts any argument that can be coerced to Integer" do
+ Integer.sqrt(10.0).should == 3
+ end
- it "converts the argument with #to_int" do
- Integer.sqrt(mock_int(10)).should == 3
- end
+ it "converts the argument with #to_int" do
+ Integer.sqrt(mock_int(10)).should == 3
+ end
- it "raises a TypeError if the argument cannot be coerced to Integer" do
- -> { Integer.sqrt("test") }.should raise_error(TypeError)
- end
+ it "raises a TypeError if the argument cannot be coerced to Integer" do
+ -> { Integer.sqrt("test") }.should raise_error(TypeError)
end
end