diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-16 23:17:17 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-16 23:17:17 +0000 |
commit | ad522685814acd682765d4ca81e2e6fb35595471 (patch) | |
tree | c03667f6ee8f999e8a60b23453e7b12e043c9880 /test/ruby | |
parent | cde491005e3776b73c25cb7ec45e8750f7ade770 (diff) | |
download | ruby-ad522685814acd682765d4ca81e2e6fb35595471.tar.gz |
* 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/trunk@23718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_complex.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 74d6d5dd8a..39a02044fa 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -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)) diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index cb7b58b417..8cacab9a09 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -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)) |