summaryrefslogtreecommitdiff
path: root/spec/ruby/library/bigdecimal/to_r_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/bigdecimal/to_r_spec.rb')
-rw-r--r--spec/ruby/library/bigdecimal/to_r_spec.rb43
1 files changed, 23 insertions, 20 deletions
diff --git a/spec/ruby/library/bigdecimal/to_r_spec.rb b/spec/ruby/library/bigdecimal/to_r_spec.rb
index c350beff08..0d787a2eff 100644
--- a/spec/ruby/library/bigdecimal/to_r_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_r_spec.rb
@@ -1,28 +1,31 @@
require_relative '../../spec_helper'
-require 'bigdecimal'
-describe "BigDecimal#to_r" do
+ruby_version_is ""..."3.4" do
+ require 'bigdecimal'
- it "returns a Rational" do
- BigDecimal("3.14159").to_r.should be_kind_of(Rational)
- end
+ describe "BigDecimal#to_r" do
- it "returns a Rational with bignum values" do
- r = BigDecimal("3.141592653589793238462643").to_r
- r.numerator.should eql(3141592653589793238462643)
- r.denominator.should eql(1000000000000000000000000)
- end
+ it "returns a Rational" do
+ BigDecimal("3.14159").to_r.should be_kind_of(Rational)
+ end
- it "returns a Rational from a BigDecimal with an exponent" do
- r = BigDecimal("1E2").to_r
- r.numerator.should eql(100)
- r.denominator.should eql(1)
- end
+ it "returns a Rational with bignum values" do
+ r = BigDecimal("3.141592653589793238462643").to_r
+ r.numerator.should eql(3141592653589793238462643)
+ r.denominator.should eql(1000000000000000000000000)
+ end
- it "returns a Rational from a negative BigDecimal with an exponent" do
- r = BigDecimal("-1E2").to_r
- r.numerator.should eql(-100)
- r.denominator.should eql(1)
- end
+ it "returns a Rational from a BigDecimal with an exponent" do
+ r = BigDecimal("1E2").to_r
+ r.numerator.should eql(100)
+ r.denominator.should eql(1)
+ end
+
+ it "returns a Rational from a negative BigDecimal with an exponent" do
+ r = BigDecimal("-1E2").to_r
+ r.numerator.should eql(-100)
+ r.denominator.should eql(1)
+ end
+ end
end