summaryrefslogtreecommitdiff
path: root/spec/ruby/library/bigdecimal/add_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/bigdecimal/add_spec.rb')
-rw-r--r--spec/ruby/library/bigdecimal/add_spec.rb24
1 files changed, 8 insertions, 16 deletions
diff --git a/spec/ruby/library/bigdecimal/add_spec.rb b/spec/ruby/library/bigdecimal/add_spec.rb
index f844ca96fa..a4237298f4 100644
--- a/spec/ruby/library/bigdecimal/add_spec.rb
+++ b/spec/ruby/library/bigdecimal/add_spec.rb
@@ -24,7 +24,7 @@ describe "BigDecimal#add" do
end
it "returns a + b with given precision" do
- # documentation states, that precision ist optional, but it ain't,
+ # documentation states that precision is optional, but it ain't,
@two.add(@one, 1).should == @three
@one .add(@two, 1).should == @three
@one.add(@one_minus, 1).should == @zero
@@ -41,14 +41,14 @@ describe "BigDecimal#add" do
@frac_3.add(@frac_4, 6).should == BigDecimal("0.11111E16")
end
- it "returns a + [Integer value] with given precision" do
+ it "returns a + [Fixnum value] with given precision" do
(1..10).each {|precision|
@dot_ones.add(0, precision).should == BigDecimal("0." + "1" * precision)
}
BigDecimal("0.88").add(0, 1).should == BigDecimal("0.9")
end
- it "returns a + [Integer value] with given precision" do
+ it "returns a + [Bignum value] with given precision" do
bignum = 10000000000000000000
(1..20).each {|precision|
@dot_ones.add(bignum, precision).should == BigDecimal("0.1E20")
@@ -60,7 +60,7 @@ describe "BigDecimal#add" do
end
# TODO:
-# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17374
+# https://blade.ruby-lang.org/ruby-core/17374
#
# This doesn't work on MRI and looks like a bug to me:
# one can use BigDecimal + Float, but not Bigdecimal.add(Float)
@@ -73,14 +73,6 @@ describe "BigDecimal#add" do
# BigDecimal("0.88").add(0.0, 1).should == BigDecimal("0.9")
# end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@frac_3).and_return([@frac_3, @frac_4])
- @frac_3.add(object, 1).should == BigDecimal("0.1E16")
- end
- end
-
describe "with Rational" do
it "produces a BigDecimal" do
(@three + Rational(500, 2)).should == BigDecimal("0.253e3")
@@ -173,21 +165,21 @@ describe "BigDecimal#add" do
it "raises TypeError when adds nil" do
-> {
@one.add(nil, 10)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
-> {
@one.add(nil, 0)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
it "raises TypeError when precision parameter is nil" do
-> {
@one.add(@one, nil)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
it "raises ArgumentError when precision parameter is negative" do
-> {
@one.add(@one, -10)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
end