[Ironruby-core] Code Review: Fix for File.print misbehavior

Shay Friedman lists at ruby-forum.com
Sat May 16 03:45:34 EDT 2009

I couldn't follow the code exactly but what I did find, was that this 
test never reached the code inside IOOps.Print.
The behavior is really strange, I tried to print the value on the screen 
and the value were really incorrect (the $\ delimiter is added after 
each argument) but the $stdout.print call inside the lambda expression 
got it correctly...

I did that:

  it "writes each obj.to_s to the stream and appends $\\ (if any) given 

objects" do
    o, o2 = Object.new, Object.new
    def o.to_s(); 'o'; end
    def o2.to_s(); 'o2'; end

    puts $stdout.print(o, o2)

    lambda { $stdout.print(o, o2) }.should 

And it wrote "o->o2->nil" on the screen... But when I changed the output 
it to "123" the test failed and told me:
  $stdout: "123"
  $stdout: "oo2->"

So I'm really confused... like I said, my breakpoint inside the print 
method never gets hit so I can't really tell which "print" method is 

Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list