kernel_methods.diff

Joshua Ballanco, 12/06/2012 06:17 AM

Download (2.97 KB)

View differences:

complex.c
487 487
static VALUE
488 488
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
489 489
{
490
    if (argc == 1 && CLASS_OF(argv[0]) == rb_cComplex)
491
      return argv[0];
490 492
    return rb_funcall2(rb_cComplex, id_convert, argc, argv);
491 493
}
492 494

  
ext/bigdecimal/bigdecimal.c
2409 2409
static VALUE
2410 2410
BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
2411 2411
{
2412
    if (argc == 1 && CLASS_OF(argv[0]) == rb_cBigDecimal)
2413
      return argv[0];
2412 2414
    Real *pv = BigDecimal_new(argc, argv);
2413 2415
    if (ToValue(pv)) pv = VpCopy(NULL, pv);
2414 2416
    pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
ext/pathname/pathname.c
1110 1110
 * Creates a new Pathname object.
1111 1111
 */
1112 1112
static VALUE
1113
path_f_pathname(VALUE self, VALUE str)
1113
path_f_pathname(VALUE self, VALUE arg)
1114 1114
{
1115
    return rb_class_new_instance(1, &str, rb_cPathname);
1115
    if (CLASS_OF(arg) == rb_cPathname)
1116
      return arg;
1117
    return rb_class_new_instance(1, &arg, rb_cPathname);
1116 1118
}
1117 1119

  
1118 1120
/*
test/bigdecimal/test_bigdecimal.rb
51 51
  def test_global_new
52 52
    assert_equal(1, BigDecimal("1"))
53 53
    assert_equal(1, BigDecimal("1", 1))
54
    bd = BigDecimal.new("1", 1)
55
    assert(bd.equal?(BigDecimal(bd)))
54 56
    assert_raise(ArgumentError) { BigDecimal("1", -1) }
55 57
    assert_raise(ArgumentError) { BigDecimal(4.2) }
56 58
    begin
test/pathname/test_pathname.rb
437 437
    assert_raise(ArgumentError) { Pathname.new("a\0") }
438 438
  end
439 439

  
440
  def test_global_constructor
441
    p = Pathname.new('a')
442
    assert_equal(p, Pathname('a'))
443
    assert(p.equal?(Pathname(p)))
444
  end
445

  
440 446
  class AnotherStringLike # :nodoc:
441 447
    def initialize(s) @s = s end
442 448
    def to_str() @s end
test/ruby/test_complex.rb
140 140
    assert_raise(TypeError){Complex(Object.new)}
141 141
    assert_raise(ArgumentError){Complex()}
142 142
    assert_raise(ArgumentError){Complex(1,2,3)}
143
    c = Complex(1,0)
144
    assert(c.equal?(Complex(c)))
143 145

  
144 146
    if (0.0/0).nan?
145 147
      assert_nothing_raised{Complex(0.0/0)}