Project

General

Profile

Bug #7522 » kernel-pathname-bigdecimal-complex-return-arg-7522.patch

jeremyevans0 (Jeremy Evans), 08/07/2019 04:11 PM

View differences:

complex.c
}
if (!NIL_P(opts)) {
raise = rb_opts_exception_p(opts, raise);
} else if (argc == 1 && CLASS_OF(a1) == rb_cComplex) {
return a1;
}
return nucomp_convert(rb_cComplex, a1, a2, raise);
}
ext/bigdecimal/bigdecimal.c
Real *pv;
VALUE obj;
if (argc == 1 && CLASS_OF(argv[0]) == rb_cBigDecimal) return argv[0];
obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
pv = BigDecimal_new(argc, argv);
if (pv == NULL) return Qnil;
ext/pathname/pathname.c
static VALUE
path_f_pathname(VALUE self, VALUE str)
{
if (CLASS_OF(str) == rb_cPathname)
return str;
return rb_class_new_instance(1, &str, rb_cPathname);
}
test/bigdecimal/test_bigdecimal.rb
assert_equal(111, BigDecimal("1_1_1_"))
assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
bd = BigDecimal.new("1", 1)
assert_same(bd, BigDecimal(bd))
assert_raise(ArgumentError) { BigDecimal("1", -1) }
assert_raise_with_message(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") }
test/pathname/test_pathname.rb
assert_raise(ArgumentError) { Pathname.new("a\0") }
end
def test_global_constructor
p = Pathname.new('a')
assert_equal(p, Pathname('a'))
assert_same(p, Pathname(p))
end
class AnotherStringLike # :nodoc:
def initialize(s) @s = s end
def to_str() @s end
test/ruby/test_complex.rb
assert_raise(TypeError){Complex(Object.new)}
assert_raise(ArgumentError){Complex()}
assert_raise(ArgumentError){Complex(1,2,3)}
c = Complex(1,0)
assert_same(c, Complex(c))
if (0.0/0).nan?
assert_nothing_raised{Complex(0.0/0)}
(3-3/3)