From 993d3a34693df57ed23245f77e8af4afeb550026 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 17 Nov 2012 18:30:22 +0400 Subject: [PATCH] added tests for resolve (to test performance issues) --- .../tests/resolve/resolveWithGenerics.kt | 20 ++++++++++++++++++ .../tests/resolve/resolveWithoutGenerics.kt | 19 +++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 21 ++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/resolveWithoutGenerics.kt diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt new file mode 100644 index 00000000000..30098eb16e2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt @@ -0,0 +1,20 @@ +package a + +class A { + val testVal : A = A() +} + +//inappropriate but participating in resolve functions +fun foo(a: T, b: T, i: Int) = a +fun foo(a: Any) = a +fun foo(a: T, b: String) = a +fun foo(a: T, b: T, s: String) = a +//appropriate function +fun foo(a: T, b: T) = a + +fun test(a: A) { + //the problem occurs if there are nested function invocations to resolve (resolve for them is repeated now) + //to copy this invocation many times (and to comment/uncomment inappropriate functions) to see the difference + foo(foo(a, foo(a, foo(a, a.testVal))), a) + +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithoutGenerics.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithoutGenerics.kt new file mode 100644 index 00000000000..cc31fa0e1c6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithoutGenerics.kt @@ -0,0 +1,19 @@ +package c + +class A { + val testVal : A = A() +} + +//inappropriate but participating in resolve functions +fun foo(a: A, b: A, i: Int) = a +fun foo(a: Any) = a +fun foo(a: A, b: Any) = a +fun foo(a: A, b: A, s: String) = a +//appropriate function +fun foo(a: A, b: A) = a + +fun test(a: A) { + //the problem occurs if there are nested function invocations to resolve (resolve for them is repeated now) + //to copy this invocation many times (and to comment/uncomment inappropriate functions) to see the difference + foo(foo(a, foo(a, foo(a, a.testVal))), a) +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index a829e237c45..086434a3b1b 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve; @InnerTestClasses({JetDiagnosticsTestGenerated.Tests.class, JetDiagnosticsTestGenerated.Script.class}) public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEagerResolve { @TestMetadata("compiler/testData/diagnostics/tests") - @InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Deparenthesize.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.ThisAndSuper.class, Tests.Tuples.class, Tests.Varargs.class}) + @InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Deparenthesize.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Resolve.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.ThisAndSuper.class, Tests.Tuples.class, Tests.Varargs.class}) public static class Tests extends AbstractDiagnosticsTestWithEagerResolve { @TestMetadata("Abstract.kt") public void testAbstract() throws Exception { @@ -3372,6 +3372,24 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage } + @TestMetadata("compiler/testData/diagnostics/tests/resolve") + public static class Resolve extends AbstractDiagnosticsTestWithEagerResolve { + public void testAllFilesPresentInResolve() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/resolve"), "kt", true); + } + + @TestMetadata("resolveWithGenerics.kt") + public void testResolveWithGenerics() throws Exception { + doTest("compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt"); + } + + @TestMetadata("resolveWithoutGenerics.kt") + public void testResolveWithoutGenerics() throws Exception { + doTest("compiler/testData/diagnostics/tests/resolve/resolveWithoutGenerics.kt"); + } + + } + @TestMetadata("compiler/testData/diagnostics/tests/scopes") public static class Scopes extends AbstractDiagnosticsTestWithEagerResolve { public void testAllFilesPresentInScopes() throws Exception { @@ -3858,6 +3876,7 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage suite.addTestSuite(Override.class); suite.addTestSuite(Redeclarations.class); suite.addTestSuite(Regressions.class); + suite.addTestSuite(Resolve.class); suite.addTestSuite(Scopes.class); suite.addTestSuite(SenselessComparison.class); suite.addTestSuite(Shadowing.class);