1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

removed some lines which gain the score of coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-08-29 15:38:09 +00:00
parent a5bdf63afd
commit 2ccc4304cd
2 changed files with 0 additions and 230 deletions

View file

@ -1028,132 +1028,6 @@ class Complex_Test < Test::Unit::TestCase
end
=begin
def test_canonicalize
f = defined?(Complex::Unify)
Complex.const_set(:Unify, true) unless f
assert_same(1, Complex.instance_eval { new(1, 0) })
assert_not_same(1.0, Complex.instance_eval { new(1.0, 0) })
assert_equal(Complex(1.0, 0), Complex.instance_eval { new(1.0, 0) })
Complex.instance_eval { remove_const(:Unify) } unless f
end
def test_polar
c = Complex.polar(2, 2)
assert_in_delta(2*Math.cos(2), c.real , 0.001)
assert_in_delta(2*Math.sin(2), c.image, 0.001)
c = Complex.polar(1, Complex(0, 1))
assert_in_delta(1/Math::E, c.real , 0.001)
assert_in_delta( 0, c.image, 0.001)
end
def test_generic?
assert_equal(true, Complex.generic?(1))
assert_equal(true, Complex.generic?(2**100))
assert_equal(true, Complex.generic?(Rational(1, 2)))
assert_equal(true, Complex.generic?(1.0))
assert_equal(false, Complex.generic?(Complex(1, 1)))
end
def test_new_bang2
o = Object.new
def o.to_i; 1; end
assert_equal(Complex(1, 1), Complex.instance_eval { new!(o, o) })
end
def test_denominator
f = defined?(Complex::Unify)
unify_val = f && Complex::Unify
Complex.instance_eval { remove_const(:Unify) } if f
dummy_rational = Class.new(Rational)
o1 = dummy_rational.instance_eval { new(1, 1) }
o2 = dummy_rational.instance_eval { new(1, 1) }
d1 = d2 = nil
class << o1; self; end.instance_eval { define_method(:denominator) { d1 } rescue nil }
class << o2; self; end.instance_eval { define_method(:denominator) { d2 } rescue nil }
# o1.denominator returns d1 and o1.denominator returns d2
c = Complex(o1, o2)
d1 = d2 = 0
assert_equal(0, c.denominator)
d1 = d2 = -1
assert_equal(1, c.denominator)
d1 = d2 = 256
assert_equal(256, c.denominator)
d1, d2 = 512, 256
assert_equal(512, c.denominator)
d1, d2 = 256, 512
assert_equal(512, c.denominator)
d1, d2 = -(2**100), -(3**100)
assert_equal(6**100, c.denominator)
d1, d2 = 1, 2**100
assert_equal(2**100, c.denominator)
Complex.const_set(:Unify, unify_val) if f
end
def test_abs
b = 2**100
def b.*(x); self; end rescue nil
def b.+(x); -1; end rescue nil
assert_equal(Complex(0, 1), Complex(b, 1).abs)
def b.+(x); Complex(0, 1); end rescue nil
c = Complex(b, 1).abs
assert_in_delta(1/Math.sqrt(2), c.real , 0.001)
assert_in_delta(1/Math.sqrt(2), c.image, 0.001)
def b.+(x); Complex(0, -1); end rescue nil
c = Complex(b, 1).abs
assert_in_delta( 1/Math.sqrt(2), c.real , 0.001)
assert_in_delta(-1/Math.sqrt(2), c.image, 0.001)
inf = 1.0/0.0
nan = inf/inf
assert_raise(Errno::EDOM, Errno::ERANGE) { Complex(1, nan).abs }
end
def test_coerce
c = Complex(6, 3)
assert_equal(Complex(42, 0), c.coerce(42).first)
assert_raise(TypeError) { c.coerce(Object.new) }
o = Object.new
def o.coerce(x); [x.real, x.image]; end
assert_equal(9, c + o)
assert_equal(3, c - o)
assert_equal(18, c * o)
assert_equal(2, c / o)
assert_equal(216, c ** o)
end
def test_add2
assert_equal(Complex(2**100, 1), Complex(0, 1) + 2**100)
end
def test_mul2
assert_equal(Complex(0.0, 0.0), Complex(1.0, 1.0) * 0)
assert_equal(Complex(0, 0), Complex(0, 0) * (2**100))
end
def test_expt2
assert_equal(Complex(1, 0), Complex(2, 2) ** 0)
assert_equal(Complex(0, -1), Complex(0, 1) ** (2**100-1))
assert_equal(Complex(1, 0), Complex(1, 0) ** Rational(1, 2**100))
end
=end
def test_fixed_bug
if defined?(Rational) && !Rational.instance_variable_get('@RCS_ID')
assert_equal(Complex(1), 1 ** Complex(1))