Skip to content

Commit fd7dd86

Browse files
committed
fix ScalaParserTestOps.checkParseErrors
- normalise line separator - simplify errors check, just use `assertEquals` on Seq
1 parent 2e7508f commit fd7dd86

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

scala/scala-impl/test/org/jetbrains/plugins/scala/lang/parser/ScalaParserTestOps.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,12 @@ trait ScalaParserTestOps {
2121
s"[[Err($err)]]"
2222

2323
def checkParseErrors(text: String): ScalaFile = {
24-
val (code, expectedErrors) = extractExpectedErrors(text)
24+
val (code, expectedErrors) = extractExpectedErrors(text.withNormalizedSeparator)
2525

2626
val file = parseText(code)
2727
val errors = file.depthFirst().toSeq.filterByType[PsiErrorElement]
28-
if (expectedErrors.isEmpty) {
29-
assert(errors.isEmpty, "Expected no errors but found: " + errors.map(_.getErrorDescription).mkString(", "))
30-
} else {
31-
val errorsWithPos = errors.map(psi => psi.getTextOffset -> psi.getErrorDescription).toSet
32-
val notFoundErrors = (expectedErrors -- errorsWithPos).toSeq.sortBy(_._1).map(_._2)
33-
val unexpectedErrors = (errorsWithPos -- expectedErrors).toSeq.sortBy(_._1).map(_._2)
34-
assert(unexpectedErrors.isEmpty, "Found unexpected errors: " + unexpectedErrors.mkString(", "))
35-
assert(notFoundErrors.isEmpty, "Expected errors but didn't find: " + notFoundErrors.mkString(", "))
36-
}
28+
val errorsWithPos = errors.map(psi => psi.getTextOffset -> psi.getErrorDescription).toSet
29+
assertEquals("parse errors do not match", expectedErrors.toSeq.sorted, errorsWithPos.toSeq.sorted)
3730
file
3831
}
3932
}

0 commit comments

Comments
 (0)