git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-03-22 17:31:08 +00:00
Родитель fa09f2ff02
Коммит 6e383d9fa2
5 изменённых файлов: 43 добавлений и 38 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Sun Mar 23 02:28:01 2008 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c: fixed. [ruby-dev:34109]
* rational.c: ditto.
Fri Mar 21 21:32:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_f_gets, rb_f_readline, rb_f_readlines): delegates to ARGF

Просмотреть файл

@ -70,12 +70,12 @@ f_add(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
if (FIX2INT(y) == 0)
if (FIX2LONG(y) == 0)
_r = x;
else
_r = rb_funcall(x, '+', 1, y);
} else if (FIXNUM_P(x)) {
if (FIX2INT(x) == 0)
if (FIX2LONG(x) == 0)
_r = y;
else
_r = rb_funcall(x, '+', 1, y);
@ -85,10 +85,10 @@ f_add(VALUE x, VALUE y)
}
inline static VALUE
f_div(x, y)
f_div(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y) && FIX2INT(y) == 1)
if (FIXNUM_P(y) && FIX2LONG(y) == 1)
_r = x;
else
_r = rb_funcall(x, '/', 1, y);
@ -100,7 +100,7 @@ f_gt_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) > FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) > FIX2LONG(y));
else
_r = rb_funcall(x, '>', 1, y);
return _r;
@ -111,7 +111,7 @@ f_lt_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) < FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) < FIX2LONG(y));
else
_r = rb_funcall(x, '<', 1, y);
return _r;
@ -124,7 +124,7 @@ f_mul(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
int _iy = FIX2INT(y);
long _iy = FIX2LONG(y);
if (_iy == 0) {
if (TYPE(x) == T_FLOAT)
_r = rb_float_new(0.0);
@ -135,7 +135,7 @@ f_mul(VALUE x, VALUE y)
else
_r = rb_funcall(x, '*', 1, y);
} else if (FIXNUM_P(x)) {
int _ix = FIX2INT(x);
long _ix = FIX2LONG(x);
if (_ix == 0) {
if (TYPE(y) == T_FLOAT)
_r = rb_float_new(0.0);
@ -155,7 +155,7 @@ f_sub(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
if (FIX2INT(y) == 0)
if (FIX2LONG(y) == 0)
_r = x;
else
_r = rb_funcall(x, '-', 1, y);
@ -189,7 +189,7 @@ f_cmp(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y)) {
int c = FIX2INT(x) - FIX2INT(y);
long c = FIX2LONG(x) - FIX2LONG(y);
if (c > 0)
c = 1;
else if (c < 0)
@ -208,7 +208,7 @@ f_equal_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) == FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) == FIX2LONG(y));
else
_r = rb_funcall(x, id_equal_p, 1, y);
return _r;
@ -223,7 +223,7 @@ f_negative_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) < 0);
_r = f_boolcast(FIX2LONG(x) < 0);
else
_r = rb_funcall(x, '<', 1, ZERO);
return _r;
@ -234,7 +234,7 @@ f_zero_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) == 0);
_r = f_boolcast(FIX2LONG(x) == 0);
else
_r = rb_funcall(x, id_equal_p, 1, ZERO);
return _r;
@ -245,7 +245,7 @@ f_one_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) == 1);
_r = f_boolcast(FIX2LONG(x) == 1);
else
_r = rb_funcall(x, id_equal_p, 1, ONE);
return _r;

Просмотреть файл

@ -53,12 +53,12 @@ f_add(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
if (FIX2INT(y) == 0)
if (FIX2LONG(y) == 0)
_r = x;
else
_r = rb_funcall(x, '+', 1, y);
} else if (FIXNUM_P(x)) {
if (FIX2INT(x) == 0)
if (FIX2LONG(x) == 0)
_r = y;
else
_r = rb_funcall(x, '+', 1, y);
@ -68,10 +68,10 @@ f_add(VALUE x, VALUE y)
}
inline static VALUE
f_div(x, y)
f_div(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y) && FIX2INT(y) == 1)
if (FIXNUM_P(y) && FIX2LONG(y) == 1)
_r = x;
else
_r = rb_funcall(x, '/', 1, y);
@ -83,7 +83,7 @@ f_gt_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) > FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) > FIX2LONG(y));
else
_r = rb_funcall(x, '>', 1, y);
return _r;
@ -94,7 +94,7 @@ f_lt_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) < FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) < FIX2LONG(y));
else
_r = rb_funcall(x, '<', 1, y);
return _r;
@ -107,7 +107,7 @@ f_mul(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
int _iy = FIX2INT(y);
long _iy = FIX2LONG(y);
if (_iy == 0) {
if (TYPE(x) == T_FLOAT)
_r = rb_float_new(0.0);
@ -118,7 +118,7 @@ f_mul(VALUE x, VALUE y)
else
_r = rb_funcall(x, '*', 1, y);
} else if (FIXNUM_P(x)) {
int _ix = FIX2INT(x);
long _ix = FIX2LONG(x);
if (_ix == 0) {
if (TYPE(y) == T_FLOAT)
_r = rb_float_new(0.0);
@ -138,7 +138,7 @@ f_sub(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(y)) {
if (FIX2INT(y) == 0)
if (FIX2LONG(y) == 0)
_r = x;
else
_r = rb_funcall(x, '-', 1, y);
@ -162,7 +162,7 @@ f_cmp(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y)) {
int c = FIX2INT(x) - FIX2INT(y);
long c = FIX2LONG(x) - FIX2LONG(y);
if (c > 0)
c = 1;
else if (c < 0)
@ -180,7 +180,7 @@ f_equal_p(VALUE x, VALUE y)
{
VALUE _r;
if (FIXNUM_P(x) && FIXNUM_P(y))
_r = f_boolcast(FIX2INT(x) == FIX2INT(y));
_r = f_boolcast(FIX2LONG(x) == FIX2LONG(y));
else
_r = rb_funcall(x, id_equal_p, 1, y);
return _r;
@ -194,7 +194,7 @@ f_negative_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) < 0);
_r = f_boolcast(FIX2LONG(x) < 0);
else
_r = rb_funcall(x, '<', 1, ZERO);
return _r;
@ -205,7 +205,7 @@ f_zero_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) == 0);
_r = f_boolcast(FIX2LONG(x) == 0);
else
_r = rb_funcall(x, id_equal_p, 1, ZERO);
return _r;
@ -216,7 +216,7 @@ f_one_p(VALUE x)
{
VALUE _r;
if (FIXNUM_P(x))
_r = f_boolcast(FIX2INT(x) == 1);
_r = f_boolcast(FIX2LONG(x) == 1);
else
_r = rb_funcall(x, id_equal_p, 1, ONE);
return _r;
@ -319,7 +319,7 @@ f_gcd(VALUE x, VALUE y)
for (;;) {
if (FIXNUM_P(x)) {
if (FIX2INT(x) == 0)
if (FIX2LONG(x) == 0)
return y;
if (FIXNUM_P(y))
return LONG2NUM(i_gcd(FIX2LONG(x), FIX2LONG(y)));
@ -897,7 +897,7 @@ nurat_cmp(VALUE self, VALUE other)
{
get_dat1(self);
if (FIXNUM_P(dat->den) && FIX2INT(dat->den) == 1)
if (FIXNUM_P(dat->den) && FIX2LONG(dat->den) == 1)
return f_cmp(dat->num, other);
else
return f_cmp(self, f_rational_new_bang1(CLASS_OF(self), other));
@ -912,8 +912,8 @@ nurat_cmp(VALUE self, VALUE other)
if (FIXNUM_P(adat->num) && FIXNUM_P(adat->den) &&
FIXNUM_P(bdat->num) && FIXNUM_P(bdat->den)) {
num1 = f_imul(FIX2INT(adat->num), FIX2INT(bdat->den));
num2 = f_imul(FIX2INT(bdat->num), FIX2INT(adat->den));
num1 = f_imul(FIX2LONG(adat->num), FIX2LONG(bdat->den));
num2 = f_imul(FIX2LONG(bdat->num), FIX2LONG(adat->den));
} else {
num1 = f_mul(adat->num, bdat->den);
num2 = f_mul(bdat->num, adat->den);
@ -939,7 +939,7 @@ nurat_equal_p(VALUE self, VALUE other)
if (!FIXNUM_P(dat->den))
return Qfalse;
if (FIX2INT(dat->den) != 1)
if (FIX2LONG(dat->den) != 1)
return Qfalse;
if (f_equal_p(dat->num, other))
return Qtrue;

Просмотреть файл

@ -894,7 +894,7 @@ class Complex_Test < Test::Unit::TestCase
end
assert_equal(Complex(0.5,1.0), Complex(1,2).quo(2))
unless $".grep(/complex/).empty?
unless $".grep(/(\A|\/)complex/).empty?
assert_equal(Complex(0,2), Math.sqrt(-4.0))
# assert_equal(true, Math.sqrt(-4.0).inexact?)
assert_equal(Complex(0,2), Math.sqrt(-4))

Просмотреть файл

@ -959,13 +959,12 @@ class Rational_Test < Test::Unit::TestCase
if defined?(Rational::Unify)
assert_instance_of(Fixnum, Rational(1,2) ** 0) # mathn's bug
end
end
=begin
def test_known_bug
n = Float::MAX.to_i * 2
assert_equal(1.0, Rational(n + 2, n + 1).to_f, '[ruby-dev:33852]')
end
=end
def test_known_bug
end
end