summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-06-27 14:30:54 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-06-27 14:30:54 +0200
commite5964e26fef818390694ecdd91e7fd1cad60b210 (patch)
tree937bf29334e4dee5e8af2424ca90c7ce4d456cce /test/files/run
parent44f10291622058d11d75dc8f3ad35b582247799c (diff)
parent299594e63a925c3e6042c6fd920de2f359417cbd (diff)
downloadscala-e5964e26fef818390694ecdd91e7fd1cad60b210.tar.gz
scala-e5964e26fef818390694ecdd91e7fd1cad60b210.tar.bz2
scala-e5964e26fef818390694ecdd91e7fd1cad60b210.zip
Merge pull request #3832 from jrudolph/w/fix-tailrec
SI-8657 don't miss tailrec defs in more positions
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/tailcalls.check8
-rw-r--r--test/files/run/tailcalls.scala35
2 files changed, 41 insertions, 2 deletions
diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check
index 7607921856..92d4f8a3c8 100644
--- a/test/files/run/tailcalls.check
+++ b/test/files/run/tailcalls.check
@@ -50,6 +50,10 @@ test NonTailCall.f2
test TailCall.b1 was successful
test TailCall.b2 was successful
test FancyTailCalls.tcTryLocal was successful
+test FancyTailCalls.tcInBooleanExprFirstOp was successful
+test FancyTailCalls.tcInBooleanExprSecondOp was successful
+test FancyTailCalls.tcInIfCond was successful
+test FancyTailCalls.tcInPatternGuard was successful
test FancyTailCalls.differentInstance was successful
test PolyObject.tramp was successful
#partest avian
@@ -104,5 +108,9 @@ test NonTailCall.f2
test TailCall.b1 was successful
test TailCall.b2 was successful
test FancyTailCalls.tcTryLocal was successful
+test FancyTailCalls.tcInBooleanExprFirstOp was successful
+test FancyTailCalls.tcInBooleanExprSecondOp was successful
+test FancyTailCalls.tcInIfCond was successful
+test FancyTailCalls.tcInPatternGuard was successful
test FancyTailCalls.differentInstance was successful
test PolyObject.tramp was successful
diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala
index 1653b14de9..8df2dcfcb6 100644
--- a/test/files/run/tailcalls.scala
+++ b/test/files/run/tailcalls.scala
@@ -213,6 +213,33 @@ class FancyTailCalls {
} finally {}
}
+ def tcInBooleanExprFirstOp(x: Int, v: Int): Boolean = {
+ {
+ def loop(n: Int): Int = if (n == 0) v else loop(n - 1)
+ loop(x)
+ } == v && true
+ }
+ def tcInBooleanExprSecondOp(x: Int, v: Int): Boolean = {
+ true && {
+ def loop(n: Int): Int = if (n == 0) v else loop(n - 1)
+ loop(x)
+ } == v
+ }
+ def tcInIfCond(x: Int, v: Int): Boolean = {
+ if ({
+ def loop(n: Int): Int = if (n == 0) v else loop(n - 1)
+ loop(x)
+ } == v) true else false
+ }
+ def tcInPatternGuard(x: Int, v: Int): Boolean =
+ v match {
+ case _ if
+ {
+ def loop(n: Int): Int = if (n == 0) v else loop(n - 1)
+ loop(x) == v
+ } => true
+ }
+
import FancyTailCalls._
final def differentInstance(n: Int, v: Int): Int = {
if (n == 0) v
@@ -376,8 +403,12 @@ object Test {
check_success_b("TailCall.b2", TailCall.b2(max), true)
val FancyTailCalls = new FancyTailCalls;
- check_success("FancyTailCalls.tcTryLocal", FancyTailCalls.tcTryLocal(max, max), max)
- check_success("FancyTailCalls.differentInstance", FancyTailCalls.differentInstance(max, 42), 42)
+ check_success("FancyTailCalls.tcTryLocal", FancyTailCalls.tcTryLocal(max, max), max)
+ check_success_b("FancyTailCalls.tcInBooleanExprFirstOp", FancyTailCalls.tcInBooleanExprFirstOp(max, max), true)
+ check_success_b("FancyTailCalls.tcInBooleanExprSecondOp", FancyTailCalls.tcInBooleanExprSecondOp(max, max), true)
+ check_success_b("FancyTailCalls.tcInIfCond", FancyTailCalls.tcInIfCond(max, max), true)
+ check_success_b("FancyTailCalls.tcInPatternGuard", FancyTailCalls.tcInPatternGuard(max, max), true)
+ check_success("FancyTailCalls.differentInstance", FancyTailCalls.differentInstance(max, 42), 42)
check_success("PolyObject.tramp", PolyObject.tramp[Int](max), 0)
}