From 080d19e2fe847ccf10dba61d71ca3b38d808c4aa Mon Sep 17 00:00:00 2001 From: John Mair Date: Mon, 18 Apr 2011 16:47:35 +1200 Subject: [PATCH] Fixed failing test related to exception expressions not being suppressable. Changed rescue Exception to rescue EOFError in Pry#readline. --- lib/pry/pry_instance.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 8b2fbab2..9fc6de5b 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -144,7 +144,7 @@ class Pry target = Pry.binding_for(target) result = re(target) - show_result(result) if should_print?(result) + show_result(result) if should_print? end # Perform a read-eval @@ -301,27 +301,20 @@ class Pry else input.readline end - rescue Exception => ex + + rescue EOFError self.input = Readline "" - - # FIX ME!!! - # failing test is due to null_input?() being true for a - # command that doesn't return a value. This causes a EOFError - # exception for a 'rep' (as in test) as it makes the read loop - # redo and so it tries to read from a non-existent string - # binding.pry end end end # Whether the print proc should be invoked. - # Currently only invoked if the output is not suppressed OR the output + # Currently only invoked if the output is not suppressed OR the last result # is an exception regardless of suppression. - # @param [Object] result The result of evaluation stage of the REPL # @return [Boolean] Whether the print proc should be invoked. - def should_print?(result) - !@suppress_output || result.is_a?(Exception) + def should_print? + !@suppress_output || last_result_is_exception? end # Returns the appropriate prompt to use.