Skip to content

Commit

Permalink
Worked on error recovery tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Sep 1, 2024
1 parent bd2d1ee commit dec2b29
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/org/rascalmpl/library/ParseTree.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,11 @@ Tree findFirstError(Tree tree) {
fail;
}
@synopsis{Find the best error from a tree containing errors.}
Tree findBestError(Tree tree) {
return findFirstError(defaultErrorDisambiguationFilter(tree));
}
@synopsis{Get the symbol (sort) of the failing production}
Symbol getErrorSymbol(appl(error(Symbol sym, _, _), _)) = sym;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test bool abx() {

test bool axc() {
Tree t = parseS("a x c $", visualize=true);
return getErrorText(findFirstError(t)) != "x c";
return getErrorText(findFirstError(t)) == "x c";
}

test bool ax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ test bool toyRascalOk() {

test bool toyRascalMissingOpenParen() {
Tree t = parseToyRascal("f){}", visualize=true);
return hasErrors(t) && getErrorText(findFirstError(t)) == ")";
return hasErrors(t) && getErrorText(findBestError(t)) == ")";
}

test bool toyRascalMissingCloseParen() {
Tree t = parseToyRascal("f({}", visualize=true);
return hasErrors(t) && getErrorText(findFirstError(t)) == ")";
return hasErrors(t) && getErrorText(findBestError(t)) == "(";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

@RunWith(RascalJUnitTestRunner.class)
@RascalJUnitTestPrefix("lang::rascal::tests::recovery")
public class ErrorRecoveryModules {
public class RunRascalTestModules {

}

0 comments on commit dec2b29

Please sign in to comment.