Skip to content

Commit

Permalink
Swap comparison of result object with the IGNORE_RESULT symbol. [Clos…
Browse files Browse the repository at this point in the history
…es #1046]
  • Loading branch information
alloy committed Mar 30, 2011
1 parent f8d2c85 commit 3f5f71b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb/context.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/context_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 3f5f71b

Please sign in to comment.