Bug #7522 » kernel_methods.diff
complex.c | ||
---|---|---|
static VALUE
|
||
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
|
||
{
|
||
if (argc == 1 && CLASS_OF(argv[0]) == rb_cComplex)
|
||
return argv[0];
|
||
return rb_funcall2(rb_cComplex, id_convert, argc, argv);
|
||
}
|
||
ext/bigdecimal/bigdecimal.c | ||
---|---|---|
static VALUE
|
||
BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
|
||
{
|
||
if (argc == 1 && CLASS_OF(argv[0]) == rb_cBigDecimal)
|
||
return argv[0];
|
||
Real *pv = BigDecimal_new(argc, argv);
|
||
if (ToValue(pv)) pv = VpCopy(NULL, pv);
|
||
pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
|
ext/pathname/pathname.c | ||
---|---|---|
* Creates a new Pathname object.
|
||
*/
|
||
static VALUE
|
||
path_f_pathname(VALUE self, VALUE str)
|
||
path_f_pathname(VALUE self, VALUE arg)
|
||
{
|
||
return rb_class_new_instance(1, &str, rb_cPathname);
|
||
if (CLASS_OF(arg) == rb_cPathname)
|
||
return arg;
|
||
return rb_class_new_instance(1, &arg, rb_cPathname);
|
||
}
|
||
/*
|
test/bigdecimal/test_bigdecimal.rb | ||
---|---|---|
def test_global_new
|
||
assert_equal(1, BigDecimal("1"))
|
||
assert_equal(1, BigDecimal("1", 1))
|
||
bd = BigDecimal.new("1", 1)
|
||
assert(bd.equal?(BigDecimal(bd)))
|
||
assert_raise(ArgumentError) { BigDecimal("1", -1) }
|
||
assert_raise(ArgumentError) { BigDecimal(4.2) }
|
||
begin
|
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(p.equal?(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(c.equal?(Complex(c)))
|
||
if (0.0/0).nan?
|
||
assert_nothing_raised{Complex(0.0/0)}
|