mirror of
https://github.com/ruby/ruby.git
synced 2025-09-19 10:33:58 +02:00
merges r23718 from trunk into ruby_1_9_1.
-- * complex.c (nucomp_coerce): accepts Complex instances. * rational.c (nurat_coerce): accepts Rational instances. [ruby-core:23859] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7eb5dcf325
commit
c2d571c37f
6 changed files with 26 additions and 1 deletions
|
@ -505,6 +505,14 @@ class Complex_Test < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_coerce
|
||||
assert_equal([Complex(2),Complex(1)], Complex(1).coerce(2))
|
||||
assert_equal([Complex(2.2),Complex(1)], Complex(1).coerce(2.2))
|
||||
assert_equal([Complex(Rational(2)),Complex(1)],
|
||||
Complex(1).coerce(Rational(2)))
|
||||
assert_equal([Complex(2),Complex(1)], Complex(1).coerce(Complex(2)))
|
||||
end
|
||||
|
||||
def test_unify
|
||||
if @unify
|
||||
assert_instance_of(Fixnum, Complex(1,2) + Complex(-1,-2))
|
||||
|
|
|
@ -704,6 +704,12 @@ class Rational_Test < Test::Unit::TestCase
|
|||
assert_equal(false, Rational(1) == '')
|
||||
end
|
||||
|
||||
def test_coerce
|
||||
assert_equal([Rational(2),Rational(1)], Rational(1).coerce(2))
|
||||
assert_equal([Rational(2.2),Rational(1)], Rational(1).coerce(2.2))
|
||||
assert_equal([Rational(2),Rational(1)], Rational(1).coerce(Rational(2)))
|
||||
end
|
||||
|
||||
def test_unify
|
||||
if @unify
|
||||
assert_instance_of(Fixnum, Rational(1,2) + Rational(1,2))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue