ruby-changes:18240
From: yugui <ko1@a...>
Date: Mon, 20 Dec 2010 22:30:28 +0900 (JST)
Subject: [ruby-changes:18240] Ruby:r30263 (ruby_1_9_2): merges most of r29882 from trunk into ruby_1_9_2.
yugui 2010-12-20 22:22:56 +0900 (Mon, 20 Dec 2010) New Revision: 30263 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30263 Log: merges most of r29882 from trunk into ruby_1_9_2. -- added some tests. Modified files: branches/ruby_1_9_2/test/ruby/test_complex.rb branches/ruby_1_9_2/test/ruby/test_rational.rb branches/ruby_1_9_2/version.h Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 30262) +++ ruby_1_9_2/version.h (revision 30263) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 103 +#define RUBY_PATCHLEVEL 104 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/ruby/test_complex.rb =================================================================== --- ruby_1_9_2/test/ruby/test_complex.rb (revision 30262) +++ ruby_1_9_2/test/ruby/test_complex.rb (revision 30263) @@ -517,6 +517,23 @@ assert_equal([Complex(2),Complex(1)], Complex(1).coerce(Complex(2))) end + class ObjectX + def + (x) Rational(1) end + alias - + + alias * + + alias / + + alias quo + + alias ** + + def coerce(x) [x, Complex(1)] end + end + + def test_coerce2 + x = ObjectX.new + %w(+ - * / quo **).each do |op| + assert_kind_of(Numeric, Complex(1).__send__(op, x)) + end + end + def test_unify if @unify assert_instance_of(Fixnum, Complex(1,2) + Complex(-1,-2)) Index: ruby_1_9_2/test/ruby/test_rational.rb =================================================================== --- ruby_1_9_2/test/ruby/test_rational.rb (revision 30262) +++ ruby_1_9_2/test/ruby/test_rational.rb (revision 30263) @@ -718,6 +718,26 @@ assert_equal([Rational(2),Rational(1)], Rational(1).coerce(Rational(2))) end + class ObjectX + def + (x) Rational(1) end + alias - + + alias * + + alias / + + alias quo + + alias div + + alias % + + alias remainder + + alias ** + + def coerce(x) [x, Rational(1)] end + end + + def test_coerce2 + x = ObjectX.new + %w(+ - * / quo div % remainder **).each do |op| + assert_kind_of(Numeric, Rational(1).__send__(op, x)) + end + end + def test_unify if @unify assert_instance_of(Fixnum, Rational(1,2) + Rational(1,2)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/