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

Fix edge-case in indent on ruby 1.9.3 [Fixes #517]

This is not fixed on rbx — maybe we should consider using the data we've
collected in indent.rb to look for unbalanced open/close tokens too on
rbx as it's error messages often elide the "Expected }" part of the
message.
This commit is contained in:
Conrad Irwin 2012-04-08 18:45:52 -07:00
parent 37377c1c45
commit ab2f586e3c
2 changed files with 6 additions and 5 deletions

View file

@ -675,7 +675,7 @@ class Pry
case ex.message
when /unexpected (\$end|end-of-file|END_OF_FILE)/, # mri, jruby, ironruby
/unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby
/missing 'end' for/, /: expecting '[})\]]'$/, /can't find string ".*" anywhere before EOF/, /expecting keyword_end/ # rbx
/missing 'end' for/, /: expecting '[})\]]'$/, /can't find string ".*" anywhere before EOF/, /: expecting keyword_end/ # rbx
true
else
false

View file

@ -24,10 +24,11 @@ describe Pry do
["end"],
["puts )("],
["1 1"],
["puts :"],
# in this case the syntax error is "expecting ')'".
(Pry::Helpers::BaseHelpers.rbx? ? nil : ["def", "method(1"])
].compact.each do |foo|
["puts :"]
] + (Pry::Helpers::BaseHelpers.rbx? ? [] : [
["def", "method(1"], # in this case the syntax error is "expecting ')'".
["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
]).compact.each do |foo|
it "should raise an error on invalid syntax like #{foo.inspect}" do
output = StringIO.new
redirect_pry_io(InputTester.new(*foo), output) do