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

* complex.c (nucomp_s_canonicalize_internal): does no apply

canonicalization rule anymore.

	* rational.c (nurat_s_canonicalize_internal(_no_reduce)?): ditto.

	* complex.c: removed class method new! and new.

	* rational.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-09-23 10:33:27 +00:00
parent 455fbd2373
commit 8b54d5812c
5 changed files with 76 additions and 268 deletions

View file

@ -1,3 +1,14 @@
Tue Sep 23 19:21:03 2008 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (nucomp_s_canonicalize_internal): does no apply
canonicalization rule anymore.
* rational.c (nurat_s_canonicalize_internal(_no_reduce)?): ditto.
* complex.c: removed class method new! and new.
* rational.c: ditto.
Tue Sep 23 18:24:34 2008 Tanaka Akira <akr@fsij.org>
* hash.c (rb_obj_is_proc): declaration moved for rdoc.

View file

@ -21,7 +21,7 @@
VALUE rb_cComplex;
static ID id_Unify, id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert,
static ID id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert,
id_denominator, id_divmod, id_equal_p, id_expt, id_floor, id_hash,
id_idiv, id_inspect, id_negate, id_numerator, id_polar, id_quo,
id_real_p, id_to_f, id_to_i, id_to_r, id_to_s;
@ -281,6 +281,7 @@ nucomp_s_alloc(VALUE klass)
return nucomp_s_new_internal(klass, ZERO, ZERO);
}
#if 0
static VALUE
nucomp_s_new_bang(int argc, VALUE *argv, VALUE klass)
{
@ -302,6 +303,7 @@ nucomp_s_new_bang(int argc, VALUE *argv, VALUE klass)
return nucomp_s_new_internal(klass, real, imag);
}
#endif
inline static VALUE
f_complex_new_bang1(VALUE klass, VALUE x)
@ -338,6 +340,7 @@ nucomp_real_check(VALUE num)
inline static VALUE
nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
{
#ifdef CANON
#define CL_CANON
#ifdef CL_CANON
if (f_zero_p(imag) && k_exact_p(imag) && f_unify_p(klass))
@ -346,7 +349,8 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
if (f_zero_p(imag) && f_unify_p(klass))
return real;
#endif
else if (f_real_p(real) && f_real_p(imag))
#endif
if (f_real_p(real) && f_real_p(imag))
return nucomp_s_new_internal(klass, real, imag);
else if (f_real_p(real)) {
get_dat1(imag);
@ -371,27 +375,6 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
}
}
#if 0
static VALUE
nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
{
VALUE real, imag;
switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
case 1:
nucomp_real_check(real);
imag = ZERO;
break;
default:
nucomp_real_check(real);
nucomp_real_check(imag);
break;
}
return nucomp_s_canonicalize_internal(klass, real, imag);
}
#endif
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
{
@ -1361,7 +1344,6 @@ Init_Complex(void)
assert(fprintf(stderr, "assert() is now active\n"));
id_Unify = rb_intern("Unify");
id_abs = rb_intern("abs");
id_abs2 = rb_intern("abs2");
id_arg = rb_intern("arg");
@ -1392,6 +1374,7 @@ Init_Complex(void)
rb_funcall(rb_cComplex, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("allocate")));
#if 0
rb_define_singleton_method(rb_cComplex, "new!", nucomp_s_new_bang, -1);
rb_funcall(rb_cComplex, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("new!")));
@ -1399,6 +1382,9 @@ Init_Complex(void)
rb_define_singleton_method(rb_cComplex, "new", nucomp_s_new, -1);
rb_funcall(rb_cComplex, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("new")));
#else
rb_undef_method(CLASS_OF(rb_cComplex), "new");
#endif
rb_define_singleton_method(rb_cComplex, "rectangular", nucomp_s_new, -1);
rb_define_singleton_method(rb_cComplex, "rect", nucomp_s_new, -1);

View file

@ -26,9 +26,9 @@
VALUE rb_cRational;
static ID id_Unify, id_abs, id_cmp, id_convert, id_equal_p, id_expt,
id_floor, id_format, id_hash, id_idiv, id_inspect, id_integer_p,
id_negate, id_to_f, id_to_i, id_to_s, id_truncate;
static ID id_abs, id_cmp, id_convert, id_equal_p, id_expt, id_floor,
id_format, id_hash, id_idiv, id_inspect, id_integer_p, id_negate,
id_to_f, id_to_i, id_to_s, id_truncate;
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
@ -329,6 +329,7 @@ nurat_s_alloc(VALUE klass)
#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by zero")
#if 0
static VALUE
nurat_s_new_bang(int argc, VALUE *argv, VALUE klass)
{
@ -360,6 +361,7 @@ nurat_s_new_bang(int argc, VALUE *argv, VALUE klass)
return nurat_s_new_internal(klass, num, den);
}
#endif
inline static VALUE
f_rational_new_bang1(VALUE klass, VALUE x)
@ -418,8 +420,10 @@ nurat_s_canonicalize_internal(VALUE klass, VALUE num, VALUE den)
num = f_idiv(num, gcd);
den = f_idiv(den, gcd);
#ifdef CANON
if (f_one_p(den) && f_unify_p(klass))
return num;
#endif
return nurat_s_new_internal(klass, num, den);
}
@ -436,32 +440,13 @@ nurat_s_canonicalize_internal_no_reduce(VALUE klass, VALUE num, VALUE den)
break;
}
#ifdef CANON
if (f_one_p(den) && f_unify_p(klass))
return num;
#endif
return nurat_s_new_internal(klass, num, den);
}
#if 0
static VALUE
nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass)
{
VALUE num, den;
switch (rb_scan_args(argc, argv, "11", &num, &den)) {
case 1:
num = nurat_int_value(num);
den = ONE;
break;
default:
num = nurat_int_value(num);
den = nurat_int_value(den);
break;
}
return nurat_s_canonicalize_internal(klass, num, den);
}
#endif
static VALUE
nurat_s_new(int argc, VALUE *argv, VALUE klass)
{
@ -1481,7 +1466,6 @@ Init_Rational(void)
assert(fprintf(stderr, "assert() is now active\n"));
id_Unify = rb_intern("Unify");
id_abs = rb_intern("abs");
id_cmp = rb_intern("<=>");
id_convert = rb_intern("convert");
@ -1507,6 +1491,7 @@ Init_Rational(void)
rb_funcall(rb_cRational, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("allocate")));
#if 0
rb_define_singleton_method(rb_cRational, "new!", nurat_s_new_bang, -1);
rb_funcall(rb_cRational, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("new!")));
@ -1514,6 +1499,9 @@ Init_Rational(void)
rb_define_singleton_method(rb_cRational, "new", nurat_s_new, -1);
rb_funcall(rb_cRational, rb_intern("private_class_method"), 1,
ID2SYM(rb_intern("new")));
#else
rb_undef_method(CLASS_OF(rb_cRational), "new");
#endif
rb_define_global_function(RATIONAL_NAME, nurat_f_rational, -1);

View file

@ -13,25 +13,21 @@ class Complex_Test < Test::Unit::TestCase
end
def test_compsub
c = ComplexSub.__send__(:new, 1)
cc = ComplexSub.__send__(:convert, 1)
c = ComplexSub.__send__(:convert, 1)
assert_kind_of(Numeric, c)
assert_kind_of(Numeric, cc)
if @unify
assert_instance_of(Fixnum, c)
assert_instance_of(Fixnum, cc)
else
assert_instance_of(ComplexSub, c)
assert_instance_of(ComplexSub, cc)
c2 = c + 1
assert_instance_of(ComplexSub, c2)
c2 = c - 1
assert_instance_of(ComplexSub, c2)
c3 = c - c2
c3 = c - c
assert_instance_of(ComplexSub, c3)
s = Marshal.dump(c)
@ -86,97 +82,43 @@ class Complex_Test < Test::Unit::TestCase
assert_instance_of(String, c.to_s)
end
def test_new_bang # no unify
assert_instance_of(Complex, Complex.__send__(:new!, 2,0))
assert_equal([2,0], Complex.__send__(:new!, 2,0).
instance_eval{[real, imag]})
assert_equal([2,4], Complex.__send__(:new!, 2,4).
instance_eval{[real, imag]})
assert_equal([-2,4], Complex.__send__(:new!, -2,4).
instance_eval{[real, imag]})
assert_equal([2,-4], Complex.__send__(:new!, 2,-4).
instance_eval{[real, imag]})
assert_equal([-2,-4], Complex.__send__(:new!, -2,-4).
instance_eval{[real, imag]})
assert_equal([2,0], Complex.__send__(:new!, Complex(2)).
instance_eval{[real, imag]})
assert_equal([2,3], Complex.__send__(:new!, Complex(2), Complex(3)).
instance_eval{[real, imag]})
assert_equal([2,3], Complex.__send__(:new!, 2, Complex(3)).
instance_eval{[real, imag]})
assert_equal([1.1,0], Complex.__send__(:new!, 1.1).
instance_eval{[real, imag]})
assert_equal([-1.1,0], Complex.__send__(:new!, -1.1).
instance_eval{[real, imag]})
assert_equal([1,0], Complex.__send__(:new!, '1').
instance_eval{[real, imag]})
assert_equal([0,0], Complex.__send__(:new!, nil).
instance_eval{[real, imag]})
end
def test_new
assert_instance_of(Complex, Complex.__send__(:new, 2,0.0))
if @unify
assert_instance_of(Fixnum, Complex.__send__(:new, 2,0))
else
assert_instance_of(Complex, Complex.__send__(:new, 2,0))
assert_equal([2,0], Complex.__send__(:new, 2,0). instance_eval{[real, imag]})
end
assert_equal([2,4], Complex.__send__(:new, 2,4).instance_eval{[real, imag]})
assert_equal([-2,4], Complex.__send__(:new, -2,4).instance_eval{[real, imag]})
assert_equal([2,-4], Complex.__send__(:new, 2,-4).instance_eval{[real, imag]})
assert_equal([-2,-4], Complex.__send__(:new, -2,-4).instance_eval{[real, imag]})
assert_raise(ArgumentError){Complex.__send__(:new, Complex(1,2),2)}
assert_raise(ArgumentError){Complex.__send__(:new, 2,Complex(1,2))}
assert_raise(ArgumentError){Complex.__send__(:new, Complex(1,2),Complex(1,2))}
assert_raise(ArgumentError){Complex.__send__(:new, '1')}
assert_raise(ArgumentError){Complex.__send__(:new, nil)}
=begin
assert_raise(ArgumentError){Complex.__send__(:new, Complex(1))}
=end
end
def test_conv
c = Complex(0,0)
assert_equal(Complex.__send__(:new, 0,0), c)
assert_equal(Complex(0,0), c)
c = Complex(2**32, 2**32)
assert_equal(Complex.__send__(:new, 2**32,2**32), c)
assert_equal(Complex(2**32,2**32), c)
assert_equal([2**32,2**32], [c.real,c.imag])
c = Complex(-2**32, 2**32)
assert_equal(Complex.__send__(:new, -2**32,2**32), c)
assert_equal(Complex(-2**32,2**32), c)
assert_equal([-2**32,2**32], [c.real,c.imag])
c = Complex(2**32, -2**32)
assert_equal(Complex.__send__(:new, 2**32,-2**32), c)
assert_equal(Complex(2**32,-2**32), c)
assert_equal([2**32,-2**32], [c.real,c.imag])
c = Complex(-2**32, -2**32)
assert_equal(Complex.__send__(:new, -2**32,-2**32), c)
assert_equal(Complex(-2**32,-2**32), c)
assert_equal([-2**32,-2**32], [c.real,c.imag])
c = Complex(Complex(1,2),2)
assert_equal(Complex.__send__(:new, 1,4), c)
assert_equal(Complex(1,4), c)
c = Complex(2,Complex(1,2))
assert_equal(Complex.__send__(:new, 0,1), c)
assert_equal(Complex(0,1), c)
c = Complex(Complex(1,2),Complex(1,2))
assert_equal(Complex.__send__(:new, -1,3), c)
assert_equal(Complex(-1,3), c)
c = Complex::I
assert_equal(Complex.__send__(:new, 0,1), c)
assert_equal(Complex(0,1), c)
assert_equal(Complex.__send__(:new, 1),Complex(1))
assert_equal(Complex.__send__(:new, 1),Complex('1'))
assert_equal(Complex.__send__(:new, 3.0,3.0),Complex('3.0','3.0'))
assert_equal(Complex(1),Complex(1))
assert_equal(Complex(1),Complex('1'))
assert_equal(Complex(3.0,3.0),Complex('3.0','3.0'))
if @rational && !@keiju
assert_equal(Complex.__send__(:new, 1,1),Complex('3/3','3/3'))
assert_equal(Complex(1,1),Complex('3/3','3/3'))
end
assert_raise(ArgumentError){Complex(nil)}
assert_raise(ArgumentError){Complex(Object.new)}
@ -202,39 +144,39 @@ class Complex_Test < Test::Unit::TestCase
assert_equal('-0.0', c.imag.to_s)
end
c = Complex.__send__(:new, 4)
c = Complex(4)
assert_equal(4, c.real)
assert_equal(0, c.imag)
assert_equal(c.imag, c.imaginary)
c = Complex.__send__(:new, 4,5)
c = Complex(4,5)
assert_equal(4, c.real)
assert_equal(5, c.imag)
assert_equal(c.imag, c.imaginary)
if -0.0.to_s == '-0.0'
c = Complex.__send__(:new, -0.0,-0.0)
c = Complex(-0.0,-0.0)
assert_equal('-0.0', c.real.to_s)
assert_equal('-0.0', c.imag.to_s)
assert_equal(c.imag.to_s, c.imaginary.to_s)
end
c = Complex.__send__(:new!, 4)
c = Complex(4)
assert_equal(4, c.real)
assert_equal(c.imag, c.imaginary)
assert_equal(0, c.imag)
c = Complex.__send__(:new!, 4,5)
c = Complex(4,5)
assert_equal(4, c.real)
assert_equal(5, c.imag)
assert_equal(c.imag, c.imaginary)
c = Complex.__send__(:new!, -0.0,-0.0)
c = Complex(-0.0,-0.0)
assert_equal('-0.0', c.real.to_s)
assert_equal('-0.0', c.imag.to_s)
@ -535,16 +477,7 @@ class Complex_Test < Test::Unit::TestCase
def test_equal
assert(Complex(1,0) == Complex(1))
assert(Complex(1,0) == Complex.__send__(:new, 1))
assert(Complex(1,0) == Complex.__send__(:new, 1,0))
assert(Complex(1,0) == Complex.__send__(:new!, 1))
assert(Complex(1,0) == Complex.__send__(:new!, 1,0))
assert(Complex(-1,0) == Complex(-1))
assert(Complex(-1,0) == Complex.__send__(:new, -1))
assert(Complex(-1,0) == Complex.__send__(:new, -1,0))
assert(Complex(-1,0) == Complex.__send__(:new!, -1))
assert(Complex(-1,0) == Complex.__send__(:new!, -1,0))
assert_equal(false, Complex(2,1) == Complex(1))
assert_equal(true, Complex(2,1) != Complex(1))

View file

@ -13,18 +13,14 @@ class Rational_Test < Test::Unit::TestCase
end
def test_ratsub
c = RationalSub.__send__(:new, 1)
cc = RationalSub.__send__(:convert, 1)
c = RationalSub.__send__(:convert, 1)
assert_kind_of(Numeric, c)
assert_kind_of(Numeric, cc)
if @unify
assert_instance_of(Fixnum, c)
assert_instance_of(Fixnum, cc)
else
assert_instance_of(RationalSub, c)
assert_instance_of(RationalSub, cc)
c2 = c + 1
assert_instance_of(RationalSub, c2)
@ -81,150 +77,53 @@ class Rational_Test < Test::Unit::TestCase
assert_instance_of(String, c.to_s)
end
def test_new_bang # no unify & no reduce
assert_instance_of(Rational, Rational.__send__(:new!, 2,1))
assert_equal([2,1], Rational.__send__(:new!, 2,1).
instance_eval{[numerator, denominator]})
assert_equal([2,4], Rational.__send__(:new!, 2,4).
instance_eval{[numerator, denominator]})
assert_equal([-2,4], Rational.__send__(:new!, -2,4).
instance_eval{[numerator, denominator]})
assert_equal([-2,4], Rational.__send__(:new!, 2,-4).
instance_eval{[numerator, denominator]})
assert_equal([2,4], Rational.__send__(:new!, -2,-4).
instance_eval{[numerator, denominator]})
# to_i
assert_equal([2,1], Rational.__send__(:new!, Rational(2)).
instance_eval{[numerator, denominator]})
assert_equal([2,3], Rational.__send__(:new!, Rational(2), Rational(3)).
instance_eval{[numerator, denominator]})
assert_equal([2,3], Rational.__send__(:new!, 2, Rational(3)).
instance_eval{[numerator, denominator]})
assert_equal([1,1], Rational.__send__(:new!, 1.1).
instance_eval{[numerator, denominator]})
assert_equal([-1,1], Rational.__send__(:new!, -1.1).
instance_eval{[numerator, denominator]})
assert_equal([1,1], Rational.__send__(:new!, '1').
instance_eval{[numerator, denominator]})
assert_equal([0,1], Rational.__send__(:new!, nil).
instance_eval{[numerator, denominator]})
assert_raise(ZeroDivisionError){Rational.__send__(:new!, 1, 0)}
end
=begin
def test_reduce
if @unify
assert_instance_of(Fixnum, Rational.__send__(:reduce, 2,1))
else
assert_instance_of(Rational, Rational.__send__(:reduce, 2,1))
assert_instance_of(Rational, Rational.__send__(:reduce, 2,1))
end
assert_equal([2,1], Rational.__send__(:reduce, 2,1).
instance_eval{[numerator, denominator]})
assert_equal([1,2], Rational.__send__(:reduce, 2,4).
instance_eval{[numerator, denominator]})
assert_equal([-1,2], Rational.__send__(:reduce, -2,4).
instance_eval{[numerator, denominator]})
assert_equal([-1,2], Rational.__send__(:reduce, 2,-4).
instance_eval{[numerator, denominator]})
assert_equal([1,2], Rational.__send__(:reduce, -2,-4).
instance_eval{[numerator, denominator]})
assert_raise(ArgumentError){Rational.__send__(:reduce, Rational(1,2),2)}
assert_raise(ArgumentError){Rational.__send__(:reduce, 2,Rational(1,2))}
assert_raise(ArgumentError){Rational.
__send__(:reduce, Rational(1,2),Rational(1,2))}
assert_raise(ArgumentError){Rational.__send__(:reduce, 1.1)}
assert_raise(ArgumentError){Rational.__send__(:reduce, -1.1)}
assert_raise(ArgumentError){Rational.__send__(:reduce, '1')}
assert_raise(ArgumentError){Rational.__send__(:reduce, nil)}
end
=end
def test_new
if @unify
assert_instance_of(Fixnum, Rational.__send__(:new, 2,1))
else
assert_instance_of(Rational, Rational.__send__(:new, 2,1))
assert_equal([2,1], Rational.__send__(:new, 2,1).
instance_eval{[numerator, denominator]})
end
assert_equal([1,2], Rational.__send__(:new, 2,4).
instance_eval{[numerator, denominator]})
assert_equal([-1,2], Rational.__send__(:new, -2,4).
instance_eval{[numerator, denominator]})
assert_equal([-1,2], Rational.__send__(:new, 2,-4).
instance_eval{[numerator, denominator]})
assert_equal([1,2], Rational.__send__(:new, -2,-4).
instance_eval{[numerator, denominator]})
assert_raise(ArgumentError){Rational.__send__(:new, Rational(1,2),2)}
assert_raise(ArgumentError){Rational.__send__(:new, 2,Rational(1,2))}
assert_raise(ArgumentError){Rational.__send__(:new, Rational(1,2),Rational(1,2))}
assert_raise(ArgumentError){Rational.__send__(:new, 1.1)}
assert_raise(ArgumentError){Rational.__send__(:new, -1.1)}
assert_raise(ArgumentError){Rational.__send__(:new, '1')}
assert_raise(ArgumentError){Rational.__send__(:new, nil)}
=begin
assert_raise(ArgumentError){Rational.__send__(:new, Rational(1))}
if @complex
assert_raise(ArgumentError){Rational.__send__(:new, Complex(1))}
end
=end
end
def test_conv
c = Rational(0,1)
assert_equal(Rational.__send__(:new, 0,1), c)
assert_equal(Rational(0,1), c)
c = Rational(2**32, 2**32)
assert_equal(Rational.__send__(:new, 2**32,2**32), c)
assert_equal(Rational(2**32,2**32), c)
assert_equal([1,1], [c.numerator,c.denominator])
c = Rational(-2**32, 2**32)
assert_equal(Rational.__send__(:new, -2**32,2**32), c)
assert_equal(Rational(-2**32,2**32), c)
assert_equal([-1,1], [c.numerator,c.denominator])
c = Rational(2**32, -2**32)
assert_equal(Rational.__send__(:new, 2**32,-2**32), c)
assert_equal(Rational(2**32,-2**32), c)
assert_equal([-1,1], [c.numerator,c.denominator])
c = Rational(-2**32, -2**32)
assert_equal(Rational.__send__(:new, -2**32,-2**32), c)
assert_equal(Rational(-2**32,-2**32), c)
assert_equal([1,1], [c.numerator,c.denominator])
c = Rational(Rational(1,2),2)
assert_equal(Rational.__send__(:new, 1,4), c)
assert_equal(Rational(1,4), c)
c = Rational(2,Rational(1,2))
assert_equal(Rational.__send__(:new, 4), c)
assert_equal(Rational(4), c)
c = Rational(Rational(1,2),Rational(1,2))
assert_equal(Rational.__send__(:new, 1), c)
assert_equal(Rational(1), c)
if @complex && !@keiju
c = Rational(Complex(1,2),2)
assert_equal(Complex.__send__(:new, Rational(1,2),1), c)
assert_equal(Complex(Rational(1,2),1), c)
c = Rational(2,Complex(1,2))
assert_equal(Complex.__send__(:new, Rational(2,5),Rational(-4,5)), c)
assert_equal(Complex(Rational(2,5),Rational(-4,5)), c)
c = Rational(Complex(1,2),Complex(1,2))
assert_equal(Rational.__send__(:new, 1), c)
assert_equal(Rational(1), c)
end
assert_equal(Rational.__send__(:new, 3),Rational(3))
assert_equal(Rational.__send__(:new, 1),Rational(3,3))
assert_equal(Rational(3),Rational(3))
assert_equal(Rational(1),Rational(3,3))
assert_equal(3.3.to_r,Rational(3.3))
assert_equal(1,Rational(3.3,3.3))
assert_equal(Rational.__send__(:new, 3),Rational('3'))
assert_equal(Rational.__send__(:new, 1),Rational('3.0','3.0'))
assert_equal(Rational.__send__(:new, 1),Rational('3/3','3/3'))
assert_equal(Rational(3),Rational('3'))
assert_equal(Rational(1),Rational('3.0','3.0'))
assert_equal(Rational(1),Rational('3/3','3/3'))
assert_raise(ArgumentError){Rational(nil)}
assert_raise(ArgumentError){Rational('')}
assert_raise(ArgumentError){Rational(Object.new)}
@ -243,22 +142,22 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(4, c.numerator)
assert_equal(5, c.denominator)
c = Rational.__send__(:new, 4)
c = Rational(4)
assert_equal(4, c.numerator)
assert_equal(1, c.denominator)
c = Rational.__send__(:new, 4,5)
c = Rational(4,5)
assert_equal(4, c.numerator)
assert_equal(5, c.denominator)
c = Rational.__send__(:new!, 4)
c = Rational(4)
assert_equal(4, c.numerator)
assert_equal(1, c.denominator)
c = Rational.__send__(:new!, 4,5)
c = Rational(4,5)
assert_equal(4, c.numerator)
assert_equal(5, c.denominator)
@ -790,16 +689,7 @@ class Rational_Test < Test::Unit::TestCase
def test_equal
assert(Rational(1,1) == Rational(1))
assert(Rational(1,1) == Rational.__send__(:new, 1))
assert(Rational(1,1) == Rational.__send__(:new, 1,1))
assert(Rational(1,1) == Rational.__send__(:new!, 1))
assert(Rational(1,1) == Rational.__send__(:new!, 1,1))
assert(Rational(-1,1) == Rational(-1))
assert(Rational(-1,1) == Rational.__send__(:new, -1))
assert(Rational(-1,1) == Rational.__send__(:new, -1,1))
assert(Rational(-1,1) == Rational.__send__(:new!, -1))
assert(Rational(-1,1) == Rational.__send__(:new!, -1,1))
assert_equal(false, Rational(2,1) == Rational(1))
assert_equal(true, Rational(2,1) != Rational(1))