diff options
Diffstat (limited to 'spec/rubyspec/core/complex')
39 files changed, 0 insertions, 548 deletions
diff --git a/spec/rubyspec/core/complex/abs2_spec.rb b/spec/rubyspec/core/complex/abs2_spec.rb deleted file mode 100644 index debfade075..0000000000 --- a/spec/rubyspec/core/complex/abs2_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/abs2', __FILE__) - -describe "Complex#abs2" do - it_behaves_like(:complex_abs2, :abs2) -end diff --git a/spec/rubyspec/core/complex/abs_spec.rb b/spec/rubyspec/core/complex/abs_spec.rb deleted file mode 100644 index a00d161ee9..0000000000 --- a/spec/rubyspec/core/complex/abs_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/abs', __FILE__) - -describe "Complex#abs" do - it_behaves_like(:complex_abs, :abs) -end diff --git a/spec/rubyspec/core/complex/angle_spec.rb b/spec/rubyspec/core/complex/angle_spec.rb deleted file mode 100644 index f0c46bfd03..0000000000 --- a/spec/rubyspec/core/complex/angle_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -require File.expand_path('../../../shared/complex/arg', __FILE__) - -describe "Complex#angle" do - it_behaves_like(:complex_arg, :angle) -end diff --git a/spec/rubyspec/core/complex/arg_spec.rb b/spec/rubyspec/core/complex/arg_spec.rb deleted file mode 100644 index 48f8a94cf5..0000000000 --- a/spec/rubyspec/core/complex/arg_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -require File.expand_path('../../../shared/complex/arg', __FILE__) - -describe "Complex#arg" do - it_behaves_like(:complex_arg, :arg) -end diff --git a/spec/rubyspec/core/complex/coerce_spec.rb b/spec/rubyspec/core/complex/coerce_spec.rb deleted file mode 100644 index 7c01170fde..0000000000 --- a/spec/rubyspec/core/complex/coerce_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/coerce', __FILE__) - -describe "Complex#coerce" do - it_behaves_like(:complex_coerce, :coerce) -end diff --git a/spec/rubyspec/core/complex/conj_spec.rb b/spec/rubyspec/core/complex/conj_spec.rb deleted file mode 100644 index ad2c885b3b..0000000000 --- a/spec/rubyspec/core/complex/conj_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../../shared/complex/conjugate', __FILE__) - -describe "Complex#conj" do - it_behaves_like(:complex_conjugate, :conj) -end diff --git a/spec/rubyspec/core/complex/conjugate_spec.rb b/spec/rubyspec/core/complex/conjugate_spec.rb deleted file mode 100644 index 7fc2ddb430..0000000000 --- a/spec/rubyspec/core/complex/conjugate_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../../shared/complex/conjugate', __FILE__) - -describe "Complex#conjugate" do - it_behaves_like(:complex_conjugate, :conjugate) -end diff --git a/spec/rubyspec/core/complex/constants_spec.rb b/spec/rubyspec/core/complex/constants_spec.rb deleted file mode 100644 index a8fcebbd31..0000000000 --- a/spec/rubyspec/core/complex/constants_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/constants', __FILE__) - -describe "Complex::I" do - it_behaves_like :complex_I, :I -end diff --git a/spec/rubyspec/core/complex/denominator_spec.rb b/spec/rubyspec/core/complex/denominator_spec.rb deleted file mode 100644 index 2568967968..0000000000 --- a/spec/rubyspec/core/complex/denominator_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/denominator', __FILE__) - -describe "Complex#denominator" do - it_behaves_like(:complex_denominator, :denominator) -end diff --git a/spec/rubyspec/core/complex/divide_spec.rb b/spec/rubyspec/core/complex/divide_spec.rb deleted file mode 100644 index 71614c76e1..0000000000 --- a/spec/rubyspec/core/complex/divide_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/divide', __FILE__) - -describe "Complex#/" do - it_behaves_like :complex_divide, :/ -end diff --git a/spec/rubyspec/core/complex/eql_spec.rb b/spec/rubyspec/core/complex/eql_spec.rb deleted file mode 100644 index c8e432029f..0000000000 --- a/spec/rubyspec/core/complex/eql_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#eql?" do - it "returns false if other is not Complex" do - Complex(1).eql?(1).should be_false - end - - it "returns true when the respective parts are of the same classes and self == other" do - Complex(1, 2).eql?(Complex(1, 2)).should be_true - end - - it "returns false when the real parts are of different classes" do - Complex(1).eql?(Complex(1.0)).should be_false - end - - it "returns false when the imaginary parts are of different classes" do - Complex(1, 2).eql?(Complex(1, 2.0)).should be_false - end - - it "returns false when self == other is false" do - Complex(1, 2).eql?(Complex(2, 3)).should be_false - end - - it "does NOT send #eql? to real or imaginary parts" do - real = mock_numeric('real') - imag = mock_numeric('imag') - real.should_not_receive(:eql?) - imag.should_not_receive(:eql?) - Complex(real, imag).eql?(Complex(real, imag)).should be_true - end -end diff --git a/spec/rubyspec/core/complex/equal_value_spec.rb b/spec/rubyspec/core/complex/equal_value_spec.rb deleted file mode 100644 index b3d93911bd..0000000000 --- a/spec/rubyspec/core/complex/equal_value_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/equal_value', __FILE__) - -describe "Complex#==" do - it_behaves_like :complex_equal_value, :== -end diff --git a/spec/rubyspec/core/complex/exponent_spec.rb b/spec/rubyspec/core/complex/exponent_spec.rb deleted file mode 100644 index 62f61a2bf3..0000000000 --- a/spec/rubyspec/core/complex/exponent_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/exponent', __FILE__) - -describe "Complex#**" do - it_behaves_like :complex_exponent, :** -end diff --git a/spec/rubyspec/core/complex/fdiv_spec.rb b/spec/rubyspec/core/complex/fdiv_spec.rb deleted file mode 100644 index 8211dfc9de..0000000000 --- a/spec/rubyspec/core/complex/fdiv_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#fdiv" do - it "accepts a numeric argument" do - lambda { Complex(20).fdiv(2) }.should_not raise_error(TypeError) - lambda { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError) - lambda { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError) - end - - it "accepts a negative numeric argument" do - lambda { Complex(20).fdiv(-2) }.should_not raise_error(TypeError) - lambda { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError) - lambda { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError) - end - - it "raises a TypeError if passed a non-numeric argument" do - lambda { Complex(20).fdiv([]) }.should raise_error(TypeError) - lambda { Complex(20).fdiv(:sym) }.should raise_error(TypeError) - lambda { Complex(20).fdiv('s') }.should raise_error(TypeError) - end - - it "sets the real part to NaN if self's real part is NaN" do - Complex(nan_value).fdiv(2).real.nan?.should be_true - end - - it "sets the imaginary part to NaN if self's imaginary part is NaN" do - Complex(2, nan_value).fdiv(2).imag.nan?.should be_true - end - - it "sets the real and imaginary part to NaN if self's real and imaginary parts are NaN" do - Complex(nan_value, nan_value).fdiv(2).imag.nan?.should be_true - Complex(nan_value, nan_value).fdiv(2).real.nan?.should be_true - end - - it "sets the real and imaginary part to NaN if self's real part and the argument are both NaN" do - Complex(nan_value, 2).fdiv(nan_value).imag.nan?.should be_true - Complex(nan_value, 2).fdiv(nan_value).real.nan?.should be_true - end - - it "sets the real and imaginary part to NaN if self's real part, self's imaginary part, and the argument are NaN" do - Complex(nan_value, nan_value).fdiv(nan_value).imag.nan?.should be_true - Complex(nan_value, nan_value).fdiv(nan_value).real.nan?.should be_true - end - - it "sets the real part to Infinity if self's real part is Infinity" do - Complex(infinity_value).fdiv(2).real.infinite?.should == 1 - Complex(infinity_value,2).fdiv(2).real.infinite?.should == 1 - end - - it "sets the imaginary part to Infinity if self's imaginary part is Infinity" do - Complex(2, infinity_value).fdiv(2).imag.infinite?.should == 1 - Complex(2, infinity_value).fdiv(2).imag.infinite?.should == 1 - end - - it "sets the imaginary and real part to Infinity if self's imaginary and real parts are Infinity" do - Complex(infinity_value, infinity_value).fdiv(2).real.infinite?.should == 1 - Complex(infinity_value, infinity_value).fdiv(2).imag.infinite?.should == 1 - end - - it "sets the real part to NaN and the imaginary part to NaN if self's imaginary part, self's real part, and the argument are Infinity" do - Complex(infinity_value, infinity_value).fdiv(infinity_value).real.nan?.should be_true - Complex(infinity_value, infinity_value).fdiv(infinity_value).imag.nan?.should be_true - end -end - -describe "Complex#fdiv with no imaginary part" do - before :each do - @numbers = [1, 5.43, 10, bignum_value, 99872.2918710].map{|n| [n,-n]}.flatten - end - - it "returns a Complex number" do - @numbers.each do |real| - @numbers.each do |other| - Complex(real).fdiv(other).should be_an_instance_of(Complex) - end - end - end - - it "sets the real part to self's real part fdiv'd with the argument" do - @numbers.each do |real| - @numbers.each do |other| - Complex(real).fdiv(other).real.should == real.fdiv(other) - end - end - end - - it "sets the imaginary part to 0.0" do - @numbers.each do |real| - @numbers.each do |other| - Complex(real).fdiv(other).imaginary.should == 0.0 - end - end - end -end - -describe "Complex#fdiv with an imaginary part" do - before :each do - @numbers = [1, 5.43, 10, bignum_value, 99872.2918710].map{|n| [n,-n]}.flatten - end - - it "returns a Complex number" do - @numbers.each do |real| - @numbers.each_with_index do |other,idx| - Complex( - real,@numbers[idx == 0 ? -1 : idx-1] - ).fdiv(other).should be_an_instance_of(Complex) - end - end - end - - it "sets the real part to self's real part fdiv'd with the argument" do - @numbers.each do |real| - @numbers.each_with_index do |other,idx| - Complex( - real,@numbers[idx == 0 ? -1 : idx-1] - ).fdiv(other).real.should == real.fdiv(other) - end - end - end - - it "sets the imaginary part to the imaginary part fdiv'd with the argument" do - @numbers.each do |real| - @numbers.each_with_index do |other,idx| - im = @numbers[idx == 0 ? -1 : idx-1] - Complex(real, im).fdiv(other).imag.should == im.fdiv(other) - end - end - end -end diff --git a/spec/rubyspec/core/complex/hash_spec.rb b/spec/rubyspec/core/complex/hash_spec.rb deleted file mode 100644 index db4b3590df..0000000000 --- a/spec/rubyspec/core/complex/hash_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../../shared/complex/hash', __FILE__) - -describe "Complex#hash" do - it_behaves_like(:complex_hash, :hash) -end diff --git a/spec/rubyspec/core/complex/imag_spec.rb b/spec/rubyspec/core/complex/imag_spec.rb deleted file mode 100644 index 6aa8803f5d..0000000000 --- a/spec/rubyspec/core/complex/imag_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/image', __FILE__) - -describe "Complex#imag" do - it_behaves_like(:complex_image, :imag) -end diff --git a/spec/rubyspec/core/complex/imaginary_spec.rb b/spec/rubyspec/core/complex/imaginary_spec.rb deleted file mode 100644 index ecae19283b..0000000000 --- a/spec/rubyspec/core/complex/imaginary_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/image', __FILE__) - -describe "Complex#imaginary" do - it_behaves_like :complex_image, :imaginary -end diff --git a/spec/rubyspec/core/complex/inspect_spec.rb b/spec/rubyspec/core/complex/inspect_spec.rb deleted file mode 100644 index b766e7f730..0000000000 --- a/spec/rubyspec/core/complex/inspect_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/inspect', __FILE__) - -describe "Complex#inspect" do - it_behaves_like(:complex_inspect, :inspect) -end diff --git a/spec/rubyspec/core/complex/integer_spec.rb b/spec/rubyspec/core/complex/integer_spec.rb deleted file mode 100644 index 54b420e62c..0000000000 --- a/spec/rubyspec/core/complex/integer_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -describe "Complex#integer?" do - it "returns false for a Complex with no imaginary part" do - Complex(20).integer?.should be_false - end - - it "returns false for a Complex with an imaginary part" do - Complex(20,3).integer?.should be_false - end -end diff --git a/spec/rubyspec/core/complex/magnitude_spec.rb b/spec/rubyspec/core/complex/magnitude_spec.rb deleted file mode 100644 index e9175d763e..0000000000 --- a/spec/rubyspec/core/complex/magnitude_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/abs', __FILE__) - -describe "Complex#magnitude" do - it_behaves_like(:complex_abs, :magnitude) -end diff --git a/spec/rubyspec/core/complex/marshal_dump_spec.rb b/spec/rubyspec/core/complex/marshal_dump_spec.rb deleted file mode 100644 index 8d37929f54..0000000000 --- a/spec/rubyspec/core/complex/marshal_dump_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#marshal_dump" do - it "is a private method" do - Complex.should have_private_instance_method(:marshal_dump, false) - end - - it "dumps real and imaginary parts" do - Complex(1, 2).send(:marshal_dump).should == [1, 2] - end -end diff --git a/spec/rubyspec/core/complex/minus_spec.rb b/spec/rubyspec/core/complex/minus_spec.rb deleted file mode 100644 index 2b7b8bb270..0000000000 --- a/spec/rubyspec/core/complex/minus_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/minus', __FILE__) - -describe "Complex#-" do - it_behaves_like :complex_minus, :- -end diff --git a/spec/rubyspec/core/complex/multiply_spec.rb b/spec/rubyspec/core/complex/multiply_spec.rb deleted file mode 100644 index 7f600fc1ab..0000000000 --- a/spec/rubyspec/core/complex/multiply_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/multiply', __FILE__) - -describe "Complex#*" do - it_behaves_like :complex_multiply, :* -end diff --git a/spec/rubyspec/core/complex/negative_spec.rb b/spec/rubyspec/core/complex/negative_spec.rb deleted file mode 100644 index 5b51933106..0000000000 --- a/spec/rubyspec/core/complex/negative_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -describe "Complex#negative?" do - it "is undefined" do - c = Complex(1) - - c.methods.should_not include(:negative?) - - lambda { - c.negative? - }.should raise_error(NoMethodError) - end -end diff --git a/spec/rubyspec/core/complex/numerator_spec.rb b/spec/rubyspec/core/complex/numerator_spec.rb deleted file mode 100644 index 8c0e8761bd..0000000000 --- a/spec/rubyspec/core/complex/numerator_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/numerator', __FILE__) - -describe "Complex#numerator" do - it_behaves_like(:complex_numerator, :numerator) -end diff --git a/spec/rubyspec/core/complex/phase_spec.rb b/spec/rubyspec/core/complex/phase_spec.rb deleted file mode 100644 index c17f922c7f..0000000000 --- a/spec/rubyspec/core/complex/phase_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../../shared/complex/arg', __FILE__) - -describe "Complex#phase" do - it_behaves_like :complex_arg, :phase -end diff --git a/spec/rubyspec/core/complex/plus_spec.rb b/spec/rubyspec/core/complex/plus_spec.rb deleted file mode 100644 index 076582681f..0000000000 --- a/spec/rubyspec/core/complex/plus_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/plus', __FILE__) - -describe "Complex#+" do - it_behaves_like :complex_plus, :+ -end diff --git a/spec/rubyspec/core/complex/polar_spec.rb b/spec/rubyspec/core/complex/polar_spec.rb deleted file mode 100644 index d847e916ff..0000000000 --- a/spec/rubyspec/core/complex/polar_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.expand_path('../../../shared/complex/polar', __FILE__) - -describe "Complex.polar" do - it_behaves_like(:complex_polar_class, :polar) - - it "raises a TypeError when given non real arguments" do - lambda{ Complex.polar(nil) }.should raise_error(TypeError) - lambda{ Complex.polar(nil, nil) }.should raise_error(TypeError) - end -end - -describe "Complex#polar" do - it_behaves_like(:complex_polar, :polar) -end diff --git a/spec/rubyspec/core/complex/positive_spec.rb b/spec/rubyspec/core/complex/positive_spec.rb deleted file mode 100644 index 88898d31cf..0000000000 --- a/spec/rubyspec/core/complex/positive_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -describe "Complex#positive?" do - it "is undefined" do - c = Complex(1) - - c.methods.should_not include(:positive?) - - lambda { - c.positive? - }.should raise_error(NoMethodError) - end -end diff --git a/spec/rubyspec/core/complex/quo_spec.rb b/spec/rubyspec/core/complex/quo_spec.rb deleted file mode 100644 index cb3f1203b4..0000000000 --- a/spec/rubyspec/core/complex/quo_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/divide', __FILE__) - -describe "Complex#quo" do - it_behaves_like :complex_divide, :quo -end diff --git a/spec/rubyspec/core/complex/rationalize_spec.rb b/spec/rubyspec/core/complex/rationalize_spec.rb deleted file mode 100644 index 2dd1e9b122..0000000000 --- a/spec/rubyspec/core/complex/rationalize_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -describe "Complex#rationalize" do - it "raises RangeError if self has non-zero imaginary part" do - lambda { Complex(1,5).rationalize }.should raise_error(RangeError) - end - - it "raises RangeError if self has 0.0 imaginary part" do - lambda { Complex(1,0.0).rationalize }.should raise_error(RangeError) - end - - it "returns a Rational if self has zero imaginary part" do - Complex(1,0).rationalize.should == Rational(1,1) - Complex(2<<63+5).rationalize.should == Rational(2<<63+5,1) - end - - it "sends #rationalize to the real part" do - real = mock_numeric('real') - real.should_receive(:rationalize).with(0.1).and_return(:result) - Complex(real, 0).rationalize(0.1).should == :result - end - - it "ignores a single argument" do - Complex(1,0).rationalize(0.1).should == Rational(1,1) - end - - it "raises ArgumentError when passed more than one argument" do - lambda { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - lambda { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) - end -end diff --git a/spec/rubyspec/core/complex/real_spec.rb b/spec/rubyspec/core/complex/real_spec.rb deleted file mode 100644 index 1293e02d3c..0000000000 --- a/spec/rubyspec/core/complex/real_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.expand_path('../../../shared/complex/real', __FILE__) - -describe "Complex#real" do - it_behaves_like(:complex_real, :real) -end - -describe "Complex#real?" do - it "returns false if there is an imaginary part" do - Complex(2,3).real?.should be_false - end - - it "returns false if there is not an imaginary part" do - Complex(2).real?.should be_false - end - - it "returns false if the real part is Infinity" do - Complex(infinity_value).real?.should be_false - end - - it "returns false if the real part is NaN" do - Complex(nan_value).real?.should be_false - end -end diff --git a/spec/rubyspec/core/complex/rect_spec.rb b/spec/rubyspec/core/complex/rect_spec.rb deleted file mode 100644 index cf2ff9e83b..0000000000 --- a/spec/rubyspec/core/complex/rect_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require File.expand_path('../../../shared/complex/rect', __FILE__) - -describe "Complex#rect" do - it_behaves_like(:complex_rect, :rect) -end - -describe "Complex.rect" do - it_behaves_like(:complex_rect_class, :rect) -end diff --git a/spec/rubyspec/core/complex/rectangular_spec.rb b/spec/rubyspec/core/complex/rectangular_spec.rb deleted file mode 100644 index 0eb29c3500..0000000000 --- a/spec/rubyspec/core/complex/rectangular_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require File.expand_path('../../../shared/complex/rect', __FILE__) - -describe "Complex#rectangular" do - it_behaves_like(:complex_rect, :rectangular) -end - -describe "Complex.rectangular" do - it_behaves_like(:complex_rect_class, :rectangular) -end diff --git a/spec/rubyspec/core/complex/to_f_spec.rb b/spec/rubyspec/core/complex/to_f_spec.rb deleted file mode 100644 index 33342e61cc..0000000000 --- a/spec/rubyspec/core/complex/to_f_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#to_f" do - describe "when the imaginary part is Fixnum 0" do - it "returns the result of sending #to_f to the real part" do - real = mock_numeric('real') - real.should_receive(:to_f).and_return(:f) - Complex(real, 0).to_f.should == :f - end - end - - describe "when the imaginary part is Rational 0" do - it "returns the result of sending #to_f to the real part" do - real = mock_numeric('real') - real.should_receive(:to_f).and_return(:f) - Complex(real, Rational(0)).to_f.should == :f - end - end - - describe "when the imaginary part responds to #== 0 with true" do - it "returns the result of sending #to_f to the real part" do - real = mock_numeric('real') - real.should_receive(:to_f).and_return(:f) - imag = mock_numeric('imag') - imag.should_receive(:==).with(0).any_number_of_times.and_return(true) - Complex(real, imag).to_f.should == :f - end - end - - describe "when the imaginary part is non-zero" do - it "raises RangeError" do - lambda { Complex(0, 1).to_f }.should raise_error(RangeError) - end - end - - describe "when the imaginary part is Float 0.0" do - it "raises RangeError" do - lambda { Complex(0, 0.0).to_f }.should raise_error(RangeError) - end - end -end diff --git a/spec/rubyspec/core/complex/to_i_spec.rb b/spec/rubyspec/core/complex/to_i_spec.rb deleted file mode 100644 index ea8b199b2e..0000000000 --- a/spec/rubyspec/core/complex/to_i_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#to_i" do - describe "when the imaginary part is Fixnum 0" do - it "returns the result of sending #to_i to the real part" do - real = mock_numeric('real') - real.should_receive(:to_i).and_return(:i) - Complex(real, 0).to_i.should == :i - end - end - - describe "when the imaginary part is Rational 0" do - it "returns the result of sending #to_i to the real part" do - real = mock_numeric('real') - real.should_receive(:to_i).and_return(:i) - Complex(real, Rational(0)).to_i.should == :i - end - end - - describe "when the imaginary part responds to #== 0 with true" do - it "returns the result of sending #to_i to the real part" do - real = mock_numeric('real') - real.should_receive(:to_i).and_return(:i) - imag = mock_numeric('imag') - imag.should_receive(:==).with(0).any_number_of_times.and_return(true) - Complex(real, imag).to_i.should == :i - end - end - - describe "when the imaginary part is non-zero" do - it "raises RangeError" do - lambda { Complex(0, 1).to_i }.should raise_error(RangeError) - end - end - - describe "when the imaginary part is Float 0.0" do - it "raises RangeError" do - lambda { Complex(0, 0.0).to_i }.should raise_error(RangeError) - end - end -end diff --git a/spec/rubyspec/core/complex/to_r_spec.rb b/spec/rubyspec/core/complex/to_r_spec.rb deleted file mode 100644 index 92fcdd3862..0000000000 --- a/spec/rubyspec/core/complex/to_r_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#to_r" do - describe "when the imaginary part is Fixnum 0" do - it "returns the result of sending #to_r to the real part" do - real = mock_numeric('real') - real.should_receive(:to_r).and_return(:r) - Complex(real, 0).to_r.should == :r - end - end - - describe "when the imaginary part is Rational 0" do - it "returns the result of sending #to_r to the real part" do - real = mock_numeric('real') - real.should_receive(:to_r).and_return(:r) - Complex(real, Rational(0)).to_r.should == :r - end - end - - describe "when the imaginary part responds to #== 0 with true" do - it "returns the result of sending #to_r to the real part" do - real = mock_numeric('real') - real.should_receive(:to_r).and_return(:r) - imag = mock_numeric('imag') - imag.should_receive(:==).with(0).any_number_of_times.and_return(true) - Complex(real, imag).to_r.should == :r - end - end - - describe "when the imaginary part is non-zero" do - it "raises RangeError" do - lambda { Complex(0, 1).to_r }.should raise_error(RangeError) - end - end - - describe "when the imaginary part is Float 0.0" do - it "raises RangeError" do - lambda { Complex(0, 0.0).to_r }.should raise_error(RangeError) - end - end -end diff --git a/spec/rubyspec/core/complex/to_s_spec.rb b/spec/rubyspec/core/complex/to_s_spec.rb deleted file mode 100644 index c398bb000e..0000000000 --- a/spec/rubyspec/core/complex/to_s_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../shared/complex/to_s', __FILE__) - -describe "Complex#to_s" do - it_behaves_like(:complex_to_s, :to_s) -end diff --git a/spec/rubyspec/core/complex/uminus_spec.rb b/spec/rubyspec/core/complex/uminus_spec.rb deleted file mode 100644 index 1bf56e770b..0000000000 --- a/spec/rubyspec/core/complex/uminus_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "Complex#-@" do - it "sends #-@ to the real and imaginary parts and returns a Complex with the resulting respective parts" do - real = mock_numeric('real') - imag = mock_numeric('imag') - real.should_receive(:-@).and_return(-1) - imag.should_receive(:-@).and_return(-2) - Complex(real, imag).send(:-@).should == Complex(-1, -2) - end -end |