diff options
Diffstat (limited to 'test/files/run/constant-optimization.scala')
-rw-r--r-- | test/files/run/constant-optimization.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/files/run/constant-optimization.scala b/test/files/run/constant-optimization.scala index 86f981e13f..5d13272f3b 100644 --- a/test/files/run/constant-optimization.scala +++ b/test/files/run/constant-optimization.scala @@ -13,6 +13,49 @@ object Test extends App { println(s"testOneReachable: $y") } + def testAllReachable() { + val i = util.Random.nextInt + val y = (i % 2) match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testAllReachable: $y") + } + + def testOneUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testOneUnreachable: $y") + } + + def testDefaultUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 1 => "good" + case 2 => "good" + case _ => "good" + } + println(s"testDefaultUnreachable: $y") + } + testBothReachable() testOneReachable() + testAllReachable() + testOneUnreachable() + testDefaultUnreachable() } |