diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
commit | 3fa5bd38af50fb3d98de0ea51043d73f8d06a24b (patch) | |
tree | d473b71cc6925ee1e17727215e9f9a66e3f24802 /spec/ruby/core/numeric | |
parent | 1e658d45e1f8dbadab18f9c35b5cfb5a5fec98bf (diff) | |
download | ruby-3fa5bd38af50fb3d98de0ea51043d73f8d06a24b.tar.gz |
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/numeric')
-rw-r--r-- | spec/ruby/core/numeric/abs_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/angle_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/arg_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/coerce_spec.rb | 35 | ||||
-rw-r--r-- | spec/ruby/core/numeric/conj_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/conjugate_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/imag_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/imaginary_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/magnitude_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/phase_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/polar_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/real_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/rect_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/numeric/rectangular_spec.rb | 2 |
14 files changed, 22 insertions, 39 deletions
diff --git a/spec/ruby/core/numeric/abs_spec.rb b/spec/ruby/core/numeric/abs_spec.rb index 4aa25359a2..ac431d65d1 100644 --- a/spec/ruby/core/numeric/abs_spec.rb +++ b/spec/ruby/core/numeric/abs_spec.rb @@ -1,5 +1,5 @@ require File.expand_path('../shared/abs', __FILE__) describe "Numeric#abs" do - it_behaves_like(:numeric_abs, :abs) + it_behaves_like :numeric_abs, :abs end diff --git a/spec/ruby/core/numeric/angle_spec.rb b/spec/ruby/core/numeric/angle_spec.rb index d7134168b3..933cba9d6e 100644 --- a/spec/ruby/core/numeric/angle_spec.rb +++ b/spec/ruby/core/numeric/angle_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) describe "Numeric#angle" do - it_behaves_like(:numeric_arg, :angle) + it_behaves_like :numeric_arg, :angle end diff --git a/spec/ruby/core/numeric/arg_spec.rb b/spec/ruby/core/numeric/arg_spec.rb index 0729a29226..aa43023942 100644 --- a/spec/ruby/core/numeric/arg_spec.rb +++ b/spec/ruby/core/numeric/arg_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) describe "Numeric#arg" do - it_behaves_like(:numeric_arg, :arg) + it_behaves_like :numeric_arg, :arg end diff --git a/spec/ruby/core/numeric/coerce_spec.rb b/spec/ruby/core/numeric/coerce_spec.rb index 820d900dd5..63cec4a9b4 100644 --- a/spec/ruby/core/numeric/coerce_spec.rb +++ b/spec/ruby/core/numeric/coerce_spec.rb @@ -29,33 +29,16 @@ describe "Numeric#coerce" do end end - it "calls #to_f to convert other if self responds to #to_f" do - # Do not use NumericSpecs::Subclass here, because coerce checks the classes of the receiver - # and arguments before calling #to_f. - other = mock("numeric") - lambda { @obj.coerce(other) }.should raise_error(TypeError) - end - it "returns [other.to_f, self.to_f] if self and other are instances of different classes" do - result = @obj.coerce(2.5) - result.should == [2.5, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) - - result = @obj.coerce(3) - result.should == [3.0, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) - - result = @obj.coerce("4.4") - result.should == [4.4, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) + @obj.coerce(2.5).should == [2.5, 10.5] + @obj.coerce(3).should == [3.0, 10.5] + @obj.coerce("4.4").should == [4.4, 10.5] + @obj.coerce(bignum_value).should == [bignum_value.to_f, 10.5] + end - result = @obj.coerce(bignum_value) - result.should == [bignum_value.to_f, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) + it "raise TypeError if they are instances of different classes and other does not respond to #to_f" do + other = mock("numeric") + lambda { @obj.coerce(other) }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do @@ -70,7 +53,7 @@ describe "Numeric#coerce" do lambda { @obj.coerce(:symbol) }.should raise_error(TypeError) end - it "raises an ArgumentError when passed a String" do + it "raises an ArgumentError when passed a non-numeric String" do lambda { @obj.coerce("test") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/numeric/conj_spec.rb b/spec/ruby/core/numeric/conj_spec.rb index 8fa0fd9457..190bbf1a73 100644 --- a/spec/ruby/core/numeric/conj_spec.rb +++ b/spec/ruby/core/numeric/conj_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/conj', __FILE__) describe "Numeric#conj" do - it_behaves_like(:numeric_conj, :conj) + it_behaves_like :numeric_conj, :conj end diff --git a/spec/ruby/core/numeric/conjugate_spec.rb b/spec/ruby/core/numeric/conjugate_spec.rb index f7e095514e..7a9a50476a 100644 --- a/spec/ruby/core/numeric/conjugate_spec.rb +++ b/spec/ruby/core/numeric/conjugate_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/conj', __FILE__) describe "Numeric#conjugate" do - it_behaves_like(:numeric_conj, :conjugate) + it_behaves_like :numeric_conj, :conjugate end diff --git a/spec/ruby/core/numeric/imag_spec.rb b/spec/ruby/core/numeric/imag_spec.rb index a80e42d265..821753184f 100644 --- a/spec/ruby/core/numeric/imag_spec.rb +++ b/spec/ruby/core/numeric/imag_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/imag', __FILE__) describe "Numeric#imag" do - it_behaves_like(:numeric_imag, :imag) + it_behaves_like :numeric_imag, :imag end diff --git a/spec/ruby/core/numeric/imaginary_spec.rb b/spec/ruby/core/numeric/imaginary_spec.rb index 41226569b3..b9d1701840 100644 --- a/spec/ruby/core/numeric/imaginary_spec.rb +++ b/spec/ruby/core/numeric/imaginary_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/imag', __FILE__) describe "Numeric#imaginary" do - it_behaves_like(:numeric_imag, :imaginary) + it_behaves_like :numeric_imag, :imaginary end diff --git a/spec/ruby/core/numeric/magnitude_spec.rb b/spec/ruby/core/numeric/magnitude_spec.rb index 947ee69730..1da082cbcd 100644 --- a/spec/ruby/core/numeric/magnitude_spec.rb +++ b/spec/ruby/core/numeric/magnitude_spec.rb @@ -1,5 +1,5 @@ require File.expand_path('../shared/abs', __FILE__) describe "Numeric#magnitude" do - it_behaves_like(:numeric_abs, :magnitude) + it_behaves_like :numeric_abs, :magnitude end diff --git a/spec/ruby/core/numeric/phase_spec.rb b/spec/ruby/core/numeric/phase_spec.rb index 7c408db83b..b3bcefb09b 100644 --- a/spec/ruby/core/numeric/phase_spec.rb +++ b/spec/ruby/core/numeric/phase_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) describe "Numeric#phase" do - it_behaves_like(:numeric_arg, :phase) + it_behaves_like :numeric_arg, :phase end diff --git a/spec/ruby/core/numeric/polar_spec.rb b/spec/ruby/core/numeric/polar_spec.rb index 5492483215..4d3b8c04d1 100644 --- a/spec/ruby/core/numeric/polar_spec.rb +++ b/spec/ruby/core/numeric/polar_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../shared/complex/numeric/polar', __FILE__) describe "Numeric#polar" do - it_behaves_like(:numeric_polar, :polar) + it_behaves_like :numeric_polar, :polar end diff --git a/spec/ruby/core/numeric/real_spec.rb b/spec/ruby/core/numeric/real_spec.rb index 3e34410155..6f6b4922b4 100644 --- a/spec/ruby/core/numeric/real_spec.rb +++ b/spec/ruby/core/numeric/real_spec.rb @@ -3,7 +3,7 @@ require File.expand_path('../../../shared/complex/numeric/real', __FILE__) require File.expand_path('../fixtures/classes', __FILE__) describe "Numeric#real" do - it_behaves_like(:numeric_real, :real) + it_behaves_like :numeric_real, :real end describe "Numeric#real?" do diff --git a/spec/ruby/core/numeric/rect_spec.rb b/spec/ruby/core/numeric/rect_spec.rb index 88d5ee3881..f5bee4c082 100644 --- a/spec/ruby/core/numeric/rect_spec.rb +++ b/spec/ruby/core/numeric/rect_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../shared/rect', __FILE__) describe "Numeric#rect" do - it_behaves_like(:numeric_rect, :rect) + it_behaves_like :numeric_rect, :rect end diff --git a/spec/ruby/core/numeric/rectangular_spec.rb b/spec/ruby/core/numeric/rectangular_spec.rb index b34100ca74..9037cb6e60 100644 --- a/spec/ruby/core/numeric/rectangular_spec.rb +++ b/spec/ruby/core/numeric/rectangular_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../shared/rect', __FILE__) describe "Numeric#rectangular" do - it_behaves_like(:numeric_rect, :rectangular) + it_behaves_like :numeric_rect, :rectangular end |