summaryrefslogtreecommitdiff
path: root/test/files/run/unreachable.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/unreachable.scala')
-rw-r--r--test/files/run/unreachable.scala19
1 files changed, 11 insertions, 8 deletions
diff --git a/test/files/run/unreachable.scala b/test/files/run/unreachable.scala
index 50a8d88b7c..99ac730746 100644
--- a/test/files/run/unreachable.scala
+++ b/test/files/run/unreachable.scala
@@ -1,3 +1,6 @@
+import scala.util.Random.nextInt
+import scala.sys.error
+
object Test extends App {
def unreachableNormalExit: Int = {
return 42
@@ -6,14 +9,14 @@ object Test extends App {
def unreachableIf: Int = {
return 42
- if (util.Random.nextInt % 2 == 0)
+ if (nextInt % 2 == 0)
0
else
1
}
def unreachableIfBranches: Int = {
- if (util.Random.nextInt % 2 == 0)
+ if (nextInt % 2 == 0)
return 42
else
return 42
@@ -22,14 +25,14 @@ object Test extends App {
}
def unreachableOneLegIf: Int = {
- if (util.Random.nextInt % 2 == 0)
+ if (nextInt % 2 == 0)
return 42
return 42
}
def unreachableLeftBranch: Int = {
- val result = if (util.Random.nextInt % 2 == 0)
+ val result = if (nextInt % 2 == 0)
return 42
else
42
@@ -38,7 +41,7 @@ object Test extends App {
}
def unreachableRightBranch: Int = {
- val result = if (util.Random.nextInt % 2 == 0)
+ val result = if (nextInt % 2 == 0)
42
else
return 42
@@ -89,7 +92,7 @@ object Test extends App {
def unreachableSwitch: Int = {
return 42
- val x = util.Random.nextInt % 2
+ val x = nextInt % 2
x match {
case 0 => return 0
case 1 => return 1
@@ -99,7 +102,7 @@ object Test extends App {
}
def unreachableAfterSwitch: Int = {
- val x = util.Random.nextInt % 2
+ val x = nextInt % 2
x match {
case 0 => return 42
case 1 => return 41 + x
@@ -122,4 +125,4 @@ object Test extends App {
check(unreachableAfterFinally)
check(unreachableSwitch)
check(unreachableAfterSwitch)
-} \ No newline at end of file
+}