Missing tests added
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
tailRecursive fun Int.test(x : Int) : Int {
|
||||
if (this > 1) {
|
||||
return (this - 1) test x
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun box() : String = if (1000000.test(1000000) == 1) "OK" else "FAIL"
|
||||
@@ -0,0 +1,12 @@
|
||||
tailRecursive fun test(x : Int) : Int {
|
||||
return if (x == 1) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
1 + <!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
} else if (x > 0) {
|
||||
test(x - 1)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
|
||||
@@ -0,0 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
return 1.foo(2)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
return 1 foo 2
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun foo()<!> {
|
||||
run {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun run(a: Any) {}
|
||||
@@ -0,0 +1,5 @@
|
||||
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun foo()<!> {
|
||||
fun bar() {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
tailRecursive fun foo() {
|
||||
(return foo())
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
tailRecursive fun foo() {
|
||||
return if (true) {
|
||||
(foo())
|
||||
}
|
||||
else Unit.VALUE
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
tailRecursive fun foo() {
|
||||
return (foo())
|
||||
}
|
||||
@@ -6462,6 +6462,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/tailCalls"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/extensionTailCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionWithNoTails.kt")
|
||||
public void testFunctionWithNoTails() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/functionWithNoTails.kt");
|
||||
@@ -6477,6 +6482,36 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/functionWithoutAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("infixRecursiveCall.kt")
|
||||
public void testInfixRecursiveCall() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/infixRecursiveCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveCallInLambda.kt")
|
||||
public void testRecursiveCallInLambda() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/recursiveCallInLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveCallInLocalFunction.kt")
|
||||
public void testRecursiveCallInLocalFunction() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/recursiveCallInLocalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInParentheses.kt")
|
||||
public void testReturnInParentheses() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/returnInParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tailCallInBlockInParentheses.kt")
|
||||
public void testTailCallInBlockInParentheses() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/tailCallInBlockInParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tailCallInParentheses.kt")
|
||||
public void testTailCallInParentheses() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/tailCallInParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tailRecursionInFinally.kt")
|
||||
public void testTailRecursionInFinally() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/tailCalls/tailRecursionInFinally.kt");
|
||||
|
||||
@@ -41,6 +41,11 @@ public class TailRecursionDetectorTestGenerated extends AbstractTailRecursionTes
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("infixCall.kt")
|
||||
public void testInfixCall() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/infixCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideElvis.kt")
|
||||
public void testInsideElvis() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/insideElvis.kt");
|
||||
@@ -81,6 +86,11 @@ public class TailRecursionDetectorTestGenerated extends AbstractTailRecursionTes
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/recursiveInnerFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIf.kt")
|
||||
public void testReturnIf() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/returnIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInCatch.kt")
|
||||
public void testReturnInCatch() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/returnInCatch.kt");
|
||||
|
||||
@@ -2634,6 +2634,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("infixCall.kt")
|
||||
public void testInfixCall() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/infixCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideElvis.kt")
|
||||
public void testInsideElvis() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/insideElvis.kt");
|
||||
@@ -2674,6 +2679,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/recursiveInnerFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIf.kt")
|
||||
public void testReturnIf() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/returnIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInCatch.kt")
|
||||
public void testReturnInCatch() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/functions/tailRecursion/returnInCatch.kt");
|
||||
|
||||
Reference in New Issue
Block a user