[MacRuby] #1170: MacRuby does not call method_missing with Array#join.

MacRuby ruby-noreply at macosforge.org
Sat Feb 26 18:34:25 PST 2011


#1170: MacRuby does not call method_missing with Array#join.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  major                 |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 When Array#join handles object which does not have "to_str" method,
 MacRuby should call the method_missing.

 Test Script:
 {{{
 #!ruby
 require 'test/unit/assertions.rb'
 include Test::Unit::Assertions

 obj1 = Object.new
 def obj1.to_str
   "obj1:to_str"
 end
 def obj1.method_missing(m)
   if m == :to_str
     return "obj1:method_missing"
   end
 end

 obj2 = Object.new
 def obj2.method_missing(m)
   if m == :to_str
     return "obj2:method_missing"
   end
 end

 str = [1, 2, obj1, obj2].join(' | ')
 assert_equal("1 | 2 | obj1:to_str | obj2:method_missing", str)

 puts :ok
 }}}

 Result:
 {{{
 $ ruby19 -v t.rb
 ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
 ok

 $ macruby -v t.rb
 MacRuby 0.10 (ruby 1.9.2) [universal-darwin10.0, x86_64]
 /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/1.9.2/minitest/unit.rb:85:in
 `assert:': Expected "1 | 2 | obj1:to_str | obj2:method_missing", not "1 |
 2 | obj1:to_str | #<NSObject:0x20024a2c0>". (MiniTest::Assertion)
         from
 /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/1.9.2/minitest/unit.rb:114:in
 `assert_equal:'
         from /Users/watson/tmp/t.rb:22:in `<main>'

 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1170>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list