mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* complex.c: undef-ed shome methods. [ruby-core:24110]
* complex.c (Numeric#arg): NaN for NaN. [ruby-core:24116] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6120338287
commit
b61ab11f49
3 changed files with 36 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
|||
Fri Jul 3 19:48:40 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c: undef-ed shome methods. [ruby-core:24110]
|
||||
|
||||
* complex.c (Numeric#arg): NaN for NaN. [ruby-core:24116]
|
||||
|
||||
Fri Jul 3 18:35:06 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_core.h (struct rb_iseq_struct): fixed types.
|
||||
|
|
29
complex.c
29
complex.c
|
@ -1690,9 +1690,9 @@ numeric_abs2(VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* num.arg -> float
|
||||
* num.angle -> float
|
||||
* num.phase -> float
|
||||
* num.arg -> 0 or float
|
||||
* num.angle -> 0 or float
|
||||
* num.phase -> 0 or float
|
||||
*
|
||||
* Returns 0 if the value is positive, pi otherwise.
|
||||
*/
|
||||
|
@ -1741,6 +1741,22 @@ numeric_conj(VALUE self)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* flo.arg -> 0 or float
|
||||
* flo.angle -> 0 or float
|
||||
* flo.phase -> 0 or float
|
||||
*
|
||||
* Returns 0 if the value is positive, pi otherwise.
|
||||
*/
|
||||
static VALUE
|
||||
float_arg(VALUE self)
|
||||
{
|
||||
if (isnan(RFLOAT_VALUE(self)))
|
||||
return self;
|
||||
return rb_call_super(0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* A complex number can be represented as a paired real number with
|
||||
* imaginary unit; a+bi. Where a is real part, b is imaginary part
|
||||
|
@ -1824,16 +1840,19 @@ Init_Complex(void)
|
|||
|
||||
rb_define_global_function("Complex", nucomp_f_complex, -1);
|
||||
|
||||
rb_undef_method(rb_cComplex, "%");
|
||||
rb_undef_method(rb_cComplex, "<");
|
||||
rb_undef_method(rb_cComplex, "<=");
|
||||
rb_undef_method(rb_cComplex, "<=>");
|
||||
rb_undef_method(rb_cComplex, ">");
|
||||
rb_undef_method(rb_cComplex, ">=");
|
||||
rb_undef_method(rb_cComplex, "between?");
|
||||
rb_undef_method(rb_cComplex, "div");
|
||||
rb_undef_method(rb_cComplex, "divmod");
|
||||
rb_undef_method(rb_cComplex, "floor");
|
||||
rb_undef_method(rb_cComplex, "ceil");
|
||||
rb_undef_method(rb_cComplex, "modulo");
|
||||
rb_undef_method(rb_cComplex, "remainder");
|
||||
rb_undef_method(rb_cComplex, "round");
|
||||
rb_undef_method(rb_cComplex, "step");
|
||||
rb_undef_method(rb_cComplex, "truncate");
|
||||
|
@ -1921,6 +1940,10 @@ Init_Complex(void)
|
|||
rb_define_method(rb_cNumeric, "conjugate", numeric_conj, 0);
|
||||
rb_define_method(rb_cNumeric, "conj", numeric_conj, 0);
|
||||
|
||||
rb_define_method(rb_cFloat, "arg", float_arg, 0);
|
||||
rb_define_method(rb_cFloat, "angle", float_arg, 0);
|
||||
rb_define_method(rb_cFloat, "phase", float_arg, 0);
|
||||
|
||||
rb_define_const(rb_cComplex, "I",
|
||||
f_complex_new_bang2(rb_cComplex, ZERO, ONE));
|
||||
}
|
||||
|
|
|
@ -519,7 +519,7 @@ class Complex_Test < Test::Unit::TestCase
|
|||
assert_instance_of(Fixnum, Complex(1,2) - Complex(1,2))
|
||||
assert_instance_of(Fixnum, Complex(1,2) * 0)
|
||||
assert_instance_of(Fixnum, Complex(1,2) / Complex(1,2))
|
||||
assert_instance_of(Fixnum, Complex(1,2).div(Complex(1,2)))
|
||||
# assert_instance_of(Fixnum, Complex(1,2).div(Complex(1,2)))
|
||||
assert_instance_of(Fixnum, Complex(1,2).quo(Complex(1,2)))
|
||||
# assert_instance_of(Fixnum, Complex(1,2) ** 0) # mathn's bug
|
||||
end
|
||||
|
@ -779,17 +779,19 @@ class Complex_Test < Test::Unit::TestCase
|
|||
|
||||
def test_respond
|
||||
c = Complex(1,1)
|
||||
assert_equal(false, c.respond_to?(:%))
|
||||
assert_equal(false, c.respond_to?(:<))
|
||||
assert_equal(false, c.respond_to?(:<=))
|
||||
assert_equal(false, c.respond_to?(:<=>))
|
||||
assert_equal(false, c.respond_to?(:>))
|
||||
assert_equal(false, c.respond_to?(:>=))
|
||||
assert_equal(false, c.respond_to?(:between?))
|
||||
# assert_equal(false, c.respond_to?(:div)) # ?
|
||||
assert_equal(false, c.respond_to?(:div))
|
||||
assert_equal(false, c.respond_to?(:divmod))
|
||||
assert_equal(false, c.respond_to?(:floor))
|
||||
assert_equal(false, c.respond_to?(:ceil))
|
||||
assert_equal(false, c.respond_to?(:modulo))
|
||||
assert_equal(false, c.respond_to?(:remainder))
|
||||
assert_equal(false, c.respond_to?(:round))
|
||||
assert_equal(false, c.respond_to?(:step))
|
||||
assert_equal(false, c.respond_to?(:tunrcate))
|
||||
|
|
Loading…
Reference in a new issue