Skip to content

Commit 96e50d0

Browse files
committed
Make test Scala.js-compliant
1 parent 7d3597e commit 96e50d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/run/errorhandling/Test.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ def sumRoots(xs: List[String]) = // inferred: Result[Double, String]
5656

5757
def resultTest() =
5858
println("resultTest")
59+
def assertFail(value: Any, s: String) = value match
60+
case Err(msg: String) => assert(msg.contains(s))
5961
assert(sumRoots(List("1", "4", "9")) == Ok(6))
60-
assert(sumRoots(List("1", "-2", "4")) == Err(s"cannot take sqrt of negative -2.0"))
61-
assert(sumRoots(List()) == Err("list is empty"))
62-
assert(sumRoots(List("1", "3ab")) == Err("java.lang.NumberFormatException: For input string: \"3ab\""))
62+
assertFail(sumRoots(List("1", "-2", "4")), "cannot take sqrt of negative")
63+
assertFail(sumRoots(List()), "list is empty")
64+
assertFail(sumRoots(List("1", "3ab")), "NumberFormatException")
6365

6466
@main def Test =
6567
breakTest()

0 commit comments

Comments
 (0)