Skip to content

Commit 2561e18

Browse files
committed
Use same error message for parse error in ShouldCompileSpec test for dotty.
1 parent a1a92d4 commit 2561e18

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scalatest-test/src/test/scala/org/scalatest/ShouldCompileSpec.scala

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,22 @@ class ShouldCompileSpec extends FunSpec {
4242
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
4343
}
4444

45-
// SKIP-DOTTY-START
4645
it("should throw TestFailedException with correct message and stack depth when parse failed") {
46+
47+
// SKIP-DOTTY-START
48+
val errMsg = Resources.expectedNoErrorButGotParseError("", "")
49+
// SKIP-DOTTY-END
50+
//DOTTY-ONLY val errMsg = Resources.expectedNoErrorButGotTypeError("", "")
51+
4752
val e = intercept[TestFailedException] {
4853
"println(\"test)" should compile
4954
}
50-
val errMsg = Resources.expectedNoErrorButGotParseError("", "")
55+
5156
assert(e.message.get.startsWith(errMsg.substring(0, errMsg.indexOf(':'))))
5257
assert(e.message.get.indexOf("println(\"test)") >= 0)
5358
assert(e.failedCodeFileName === (Some(fileName)))
5459
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
5560
}
56-
// SKIP-DOTTY-END
5761

5862
}
5963

@@ -74,19 +78,23 @@ class ShouldCompileSpec extends FunSpec {
7478
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
7579
}
7680

77-
// SKIP-DOTTY-START
7881
it("should throw TestFailedException with correct message and stack depth when parse failed") {
82+
83+
// SKIP-DOTTY-START
84+
val errMsg = Resources.expectedNoErrorButGotParseError("", "")
85+
// SKIP-DOTTY-END
86+
//DOTTY-ONLY val errMsg = Resources.expectedNoErrorButGotTypeError("", "")
87+
7988
val e = intercept[TestFailedException] {
8089
"""println("test)""" should compile
8190
}
82-
val errMsg = Resources.expectedNoErrorButGotParseError("", "")
91+
8392
assert(e.message.get.startsWith(errMsg.substring(0, errMsg.indexOf(':'))))
8493
assert(e.message.get.indexOf("println(\"test)") >= 0)
8594
assert(e.failedCodeFileName === (Some(fileName)))
8695
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
8796
}
88-
// SKIP-DOTTY-END
89-
97+
9098
}
9199

92100
// SKIP-DOTTY-START

0 commit comments

Comments
 (0)