Skip to content

Commit 7b5528e

Browse files
committed
Ensure the switch of Bug1955 is always a switch by adding more cases.
Under 4 cases, some versions of the compiler do not emit a switch match. That defeats the purpose of that test.
1 parent 8e69b34 commit 7b5528e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test-suite/shared/src/test/scala/org/scalajs/testsuite/compiler/RegressionTest.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,13 @@ class RegressionTest {
418418
@Test def switchMatchWithGuardAndResultTypeOfBoxedUnit_Issue1955(): Unit = {
419419
val bug = new Bug1955
420420
bug.bug(2, true)
421-
assertEquals(0, bug.result)
421+
assertEquals(22, bug.result)
422+
bug.bug(2, false)
423+
assertEquals(-1, bug.result)
422424
bug.bug(1, true)
423425
assertEquals(579, bug.result)
424-
assertThrows(classOf[MatchError], bug.bug(2, false))
426+
bug.bug(6, true)
427+
assertEquals(-1, bug.result)
425428
}
426429

427430
@Test def switchMatchWithGuardInStatementPosButWithNonUnitBranches_Issue4105(): Unit = {
@@ -987,9 +990,12 @@ object RegressionTest {
987990
}
988991

989992
def bug(x: Int, e: Boolean): Unit = {
990-
x match {
991-
case 1 => doSomething(123, 456, ())
992-
case 2 if e =>
993+
(x: @switch) match {
994+
case 1 => doSomething(123, 456, ())
995+
case 2 if e => result = 22
996+
case 3 => result = 33
997+
case 4 => result = 44
998+
case _ => result = -1
993999
}
9941000

9951001
if (false) ()

0 commit comments

Comments
 (0)