Skip to content

Commit 1aca083

Browse files
committed
Restore test check function
Vulpix only checks output if there is an existing check file. Note that partest pos tests used to accept an optional check file, but the confusing behavior is that if you delete the check file, it always passes, unlike a neg test which takes a missing check file as an empty one. In this case, a semantic merge conflict resulted in a neg test with println instead of assert, but with no check file. Happily, such a test can never fail. Sadly, sometimes our code is broken.
1 parent 38cb5e3 commit 1aca083

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

tests/run/literals.scala

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
// scalac: -deprecation
2-
//
3-
//############################################################################
4-
// Literals
5-
//############################################################################
61

7-
//############################################################################
2+
import scala.util.{Failure, Success, Try}
83

94
object Test {
105

11-
def check_success[A](name: String, closure: => A, expected: A): Unit = {
12-
val res: Option[String] =
13-
try {
14-
val actual: A = closure
15-
if (actual == expected) None //print(" was successful")
16-
else Some(s" failed: expected $expected, found $actual")
17-
} catch {
18-
case exception: Throwable => Some(s" raised exception $exception")
19-
}
20-
for (e <- res) println(s"test $name $e")
21-
}
6+
def check_success[A](name: String, closure: => A, expected: A): Unit =
7+
Try(closure) match {
8+
case Success(actual) => assert(actual == expected, s"test $name failed: expected $expected, found $actual")
9+
case Failure(error) => throw new AssertionError(s"test $name raised exception $error")
10+
}
2211

2312
def main(args: Array[String]): Unit = {
2413
// char
@@ -83,6 +72,7 @@ object Test {
8372
check_success("01.23f == 1.23f", 01.23f, 1.23f)
8473
check_success("3.14f == 3.14f", 3.14f, 3.14f)
8574
check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f)
75+
check_success("9f == 9.0f", 9f, 9.0f)
8676
check_success("09f == 9.0f", 09f, 9.0f)
8777
check_success("1.00000017881393421514957253748434595763683319091796875001f == 1.0000001f",
8878
1.00000017881393421514957253748434595763683319091796875001f,
@@ -114,5 +104,3 @@ object Test {
114104
check_success("\"\".length()", "\u001a".length(), 1)
115105
}
116106
}
117-
118-
//############################################################################

0 commit comments

Comments
 (0)