Permalink
Browse files

Swap comparison of result object with the IGNORE_RESULT symbol. [Clos…

…es #1046]
  • Loading branch information...
1 parent f8d2c85 commit 3f5f71bae149bbf3c4ecfa5cd92a6e3fd7b441f2 @alloy alloy committed Mar 30, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/irb/context.rb
  2. +9 −0 spec/context_spec.rb
View
@@ -38,7 +38,7 @@ def to_s
def evaluate(source)
result = __evaluate__(source.to_s, '(irb)', @line - @source.buffer.size + 1)
- unless result == IGNORE_RESULT
+ unless IGNORE_RESULT == result
store_result(result)
output(formatter.result(result))
result
View
@@ -110,6 +110,15 @@ def o.to_s; "self"; end
@output.printed.should == "=> :bananas\n"
@context.evaluate("_").should == :bananas
end
+
+ describe "regression specs" do
+ it "does not try to convert an object to a string when checking if the evaluate result should be ignored" do
+ o = @context.__evaluate__("o = Object.new")
+ def o.==(other); raise "Ohnoes!"; end
+ lambda { @context.evaluate("o") }.should_not raise_error
+ @context.__evaluate__("exception").should == nil
+ end
+ end
end
describe "IRB::Context, when receiving input" do

0 comments on commit 3f5f71b

Please sign in to comment.