From 6c0f7d19ba97b0a2116004d830a2565c2c0836d4 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 21 Jun 2009 09:16:44 +0000 Subject: 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_complex.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby/test_complex.rb') diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 74d6d5dd8..39a02044f 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)) -- cgit