[MacRuby-devel] [MacRuby] #709: Different behaviour when including a module into Class in MacRuby vs Ruby 1.9.2
MacRuby
ruby-noreply at macosforge.org
Thu May 13 03:49:24 PDT 2010
#709: Different behaviour when including a module into Class in MacRuby vs Ruby
1.9.2
----------------------------------+-----------------------------------------
Reporter: james@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords: mocha class module include
----------------------------------+-----------------------------------------
I'm seeing different behaviour when including a module into Class in
MacRuby vs Ruby 1.9.2. This is a simplification of a problem I'm seeing
running Mocha [1] tests in MacRuby. I seems to be specific to including
the module into the Class class and not a user-defined class. It also
doesn't seem to matter whether the class has already been defined or not.
{{{
$ rvm macruby
$ irb
macruby-0.6 > module X; def x; "x"; end; end
=> nil
macruby-0.6 > class Class; include X; end
=> Class
macruby-0.6 > Class.new.x
NoMethodError: undefined method `x' for #<Class:0x20020f960>
from /Users/jamesmead/Code/mocha/(irb):3:in `<main>'
}}}
{{{
$ rvm 1.9.2
$ irb
ruby-1.9.2-preview1 > module X; def x; "x"; end; end
=> nil
ruby-1.9.2-preview1 > class Class; include X; end
=> Class
ruby-1.9.2-preview1 > Class.new.x
=> "x"
}}}
{{{
$ rvm macruby
$ irb
macruby-0.6 > module X; def x; "x"; end; end
=> nil
macruby-0.6 > class Y; include X; end
=> Y
macruby-0.6 > Y.new.x
=> "x"
}}}
{{{
$ rvm macruby
$ irb
macruby-0.6 > module X; def x; "x"; end; end
=> nil
macruby-0.6 > class Y; end
=> nil
macruby-0.6 > class Y; include X; end
=> Y
macruby-0.6 > Y.new.x
=> "x"
}}}
[1] http://github.com/floehopper/mocha/tree/macruby
--
Ticket URL: <http://www.macruby.org/trac/ticket/709>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list