Permalink
Browse files

. catching parse differently

  • Loading branch information...
1 parent 041a454 commit 58209d78685e968de1b09377291f50a484593a8a @kschiess committed Apr 17, 2012
Showing with 7 additions and 10 deletions.
  1. +3 −6 spec/acceptance/regression_spec.rb
  2. +2 −2 spec/parslet/atoms/entity_spec.rb
  3. +2 −2 spec/spec_helper.rb
@@ -129,8 +129,7 @@ def remove_indent(s)
end
it "should count lines correctly" do
- cause = nil
- begin
+ cause = catch_failed_parse {
subject.parse('
a
a a a
@@ -140,10 +139,8 @@ def remove_indent(s)
*/
b
')
- rescue Parslet::ParseFailed => ex
- cause = ex.cause
- end
- puts cause.ascii_tree
+ }
+
remove_indent(cause.ascii_tree).should == remove_indent(%q(
Don't know what to do with "b\n " at line 8 char 11.).strip)
end
@@ -45,8 +45,8 @@ class RecDefParser
parser.recdef.parse("(((a)))")
end
it "should not throw 'stack level too deep' when printing errors" do
- exception = catch_exception { parser.recdef.parse('(((a))') }
- exception.cause.ascii_tree
+ cause = catch_failed_parse { parser.recdef.parse('(((a))') }
+ cause.ascii_tree
end
end
end
View
@@ -15,10 +15,10 @@
}
end
-def catch_exception
+def catch_failed_parse
begin
yield
rescue Parslet::ParseFailed => exception
end
- exception
+ exception.cause
end

0 comments on commit 58209d7

Please sign in to comment.