Projects

Ticket #189 (new defect)

Opened 3 years ago

Last modified 14 months ago

Bugs with: Class#dup & Object#dup

Reported by: eloy.de.enige@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby Later
Component: MacRuby Keywords:
Cc:

Description

Added test cases for these issues to known_bugs.rb:  http://www.macruby.org/trac/changeset/770/MacRuby

Object#dup apparently tries to use NSObject#copyWithZone internally which fails because Object doesn't implement it.

Class#dup simply returns a pointer to the original class instance. Using #clone does work though.

Change History

Changed 16 months ago by watson1978@…

require 'stringio'

def assert_equal(x, y)
  if x == y
    puts "ok"
  else
    puts "ng : x = #{x.inspect} : y = #{y.inspect}"
  end
end

f1 = StringIO.new("1234")
assert_equal("1", f1.getc)
f2 = f1.dup

assert_equal("2", f2.getc)
assert_equal("3", f1.getc)
assert_equal("4", f2.getc)
assert_equal(nil, f1.getc)
assert_equal(true, f2.eof?)
f1.close
assert_equal(true, f2.closed?)

Result:

$ ruby19 -v test_stringio.rb
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
ok
ok
ok
ok
ok
ok
ok

$ macruby -v test_stringio.rb
MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64]
ok
ok
ng : x = "3" : y = "2"
ng : x = "4" : y = "3"
ng : x = nil : y = "3"
ng : x = true : y = false
ng : x = true : y = false

Changed 16 months ago by lsansonetti@…

Aren't those unrelated? I think a new bug should be opened for the new one.

Changed 16 months ago by watson1978@…

Sorry X(

It seems to be a issue of StringIO#dup.

Changed 14 months ago by lsansonetti@…

  • milestone set to MacRuby Later

Object#dup works in trunk since a long time I think, but Class#dup is still returning self, apparently.

$ ./miniruby -e "class Foo; end; p Foo.object_id,Foo.dup.object_id"
17183086272
17183086272

I am not certain this functionality is needed for 1.0, though, so moving to Later.

Note: See TracTickets for help on using tickets.