mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Don't show result of evaluating comments.
This commit is contained in:
parent
64b3703a54
commit
46b6825301
2 changed files with 24 additions and 1 deletions
|
@ -309,7 +309,9 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
@suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty?
|
||||
if eval_string =~ /;\Z/ || eval_string.empty? || eval_string =~ /\A *#.*\n\z/
|
||||
@suppress_output = true
|
||||
end
|
||||
|
||||
exec_hook :after_read, eval_string, self
|
||||
eval_string
|
||||
|
|
|
@ -38,4 +38,25 @@ describe Pry do
|
|||
mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /#<NastyClass:0x.*?>/
|
||||
end
|
||||
end
|
||||
|
||||
describe "output suppression" do
|
||||
before do
|
||||
@t = pry_tester
|
||||
end
|
||||
it "should normally output the result" do
|
||||
mock_pry("1 + 2").should == "=> 3\n\n"
|
||||
end
|
||||
|
||||
it "should not output anything if the input ends with a semicolon" do
|
||||
mock_pry("1 + 2;").should == "\n"
|
||||
end
|
||||
|
||||
it "should output something if the input ends with a comment" do
|
||||
mock_pry("1 + 2 # basic addition").should == "=> 3\n\n"
|
||||
end
|
||||
|
||||
it "should not output something if the input is only a comment" do
|
||||
mock_pry("# basic addition").should == "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue