1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Rework valid_expression? as complete_expression?

This commit is contained in:
Conrad Irwin 2011-12-03 20:47:26 -08:00
parent 05fbdaac3b
commit a04c5f488a
3 changed files with 7 additions and 7 deletions

View file

@ -113,7 +113,7 @@ class Pry
eval_string << Array(code.each_line.to_a[range]).join
end
run "show-input" if !_pry_.valid_expression?(eval_string)
run "show-input" if !_pry_.complete_expression?(eval_string)
end
command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|

View file

@ -259,7 +259,7 @@ class Pry
output.puts "Error: #{e.message}"
end
break if valid_expression?(eval_string)
break if complete_expression?(eval_string)
end
@suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty?
@ -544,9 +544,9 @@ class Pry
# @return [Boolean] Whether or not the code is a complete Ruby expression.
# @raise [SyntaxError] Any SyntaxError that does not represent incompleteness.
# @example
# valid_expression?("class Hello") #=> false
# valid_expression?("class Hello; end") #=> true
def valid_expression?(str)
# complete_expression?("class Hello") #=> false
# complete_expression?("class Hello; end") #=> true
def complete_expression?(str)
if defined?(Rubinius::Melbourne19) && RUBY_VERSION =~ /^1\.9/
Rubinius::Melbourne19.parse_string(str, Pry.eval_path)
elsif defined?(Rubinius::Melbourne)

View file

@ -216,11 +216,11 @@ describe Pry do
end
end
describe "valid_expression?" do
describe "complete_expression?" do
it "should not mutate the input!" do
clean = "puts <<-FOO\nhi\nFOO\n"
a = clean.dup
Pry.new.valid_expression?(a)
Pry.new.complete_expression?(a)
a.should == clean
end
end