generate constraint system tests

more tests added
This commit is contained in:
Svetlana Isakova
2014-01-24 21:09:51 +04:00
parent 791fa22abb
commit 9832676701
27 changed files with 593 additions and 27 deletions
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.inference.*;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
import org.jetbrains.jet.lang.types.TypeUtils;
@@ -376,7 +377,7 @@ public class Renderers {
typeBounds.add(constraintSystem.getTypeBounds(variable));
}
Function<TypeBounds, String> renderTypeBounds = rendererToFunction(RENDER_TYPE_BOUNDS);
return "type parameter bounds:\n" + StringUtil.join(typeBounds, renderTypeBounds, ";\n") + "\n" +
return "type parameter bounds:\n" + StringUtil.join(typeBounds, renderTypeBounds, "\n") + "\n" +
"status:\n" + ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus());
}
};
@@ -388,11 +389,15 @@ public class Renderers {
Function<TypeBoundsImpl.Bound, String> renderBound = new Function<TypeBoundsImpl.Bound, String>() {
@Override
public String fun(TypeBoundsImpl.Bound bound) {
String arrow = bound.kind == LOWER_BOUND ? "<: " : bound.kind == UPPER_BOUND ? ">: " : "= ";
return arrow + bound.type + '(' + bound.position + ')';
String arrow = bound.kind == LOWER_BOUND ? ">: " : bound.kind == UPPER_BOUND ? "<: " : ":= ";
return arrow + RENDER_TYPE.render(bound.type) + '(' + bound.position + ')';
}
};
return typeBounds.getTypeVariable().getName() + " " + StringUtil.join(typeBounds.getBounds(), renderBound, ", ");
Name typeVariableName = typeBounds.getTypeVariable().getName();
if (typeBounds.isEmpty()) {
return typeVariableName.asString();
}
return typeVariableName + " " + StringUtil.join(typeBounds.getBounds(), renderBound, ", ");
}
};
@@ -0,0 +1,18 @@
VARIABLES T
SUBTYPE T Int
SUPERTYPE T String
type parameter bounds:
T <: jet.Int(SPECIAL), >: jet.String(SPECIAL)
status:
-hasConflictingConstraints: true
-hasContradiction: true
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: false
result:
T=???
@@ -1,10 +1,10 @@
VARIABLES T
SUBTYPE T Int
SUPERTYPE T Int !
SUPERTYPE T Int
type parameter bounds:
T >: Int(SPECIAL), <: Int(SPECIAL)
T <: jet.Int(SPECIAL), >: jet.Int(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
@@ -15,4 +15,4 @@ status:
-isSuccessful: true
result:
T=Int
T=jet.Int
@@ -0,0 +1,17 @@
VARIABLES T
SUBTYPE List<T> Int
type parameter bounds:
T
status:
-hasConflictingConstraints: false
-hasContradiction: true
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: true
-hasUnknownParameters: true
-hasViolatedUpperBound: false
-isSuccessful: false
result:
T=???
@@ -0,0 +1,17 @@
VARIABLES T
SUBTYPE Any Any
type parameter bounds:
T
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: true
-hasViolatedUpperBound: false
-isSuccessful: false
result:
T=???
@@ -0,0 +1,18 @@
VARIABLES T
SUBTYPE T Int
SUBTYPE T String !
type parameter bounds:
T <: jet.Int(SPECIAL), <: jet.String(TYPE_BOUND_POSITION(0))
status:
-hasConflictingConstraints: true
-hasContradiction: true
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: true
-isSuccessful: false
result:
T=???
@@ -0,0 +1,18 @@
VARIABLES T
SUBTYPE T B
SUPERTYPE T A
type parameter bounds:
T <: B(SPECIAL), >: A(SPECIAL)
status:
-hasConflictingConstraints: true
-hasContradiction: true
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: false
result:
T=???
@@ -0,0 +1,18 @@
VARIABLES T
SUBTYPE T A
SUBTYPE T B
type parameter bounds:
T <: A(SPECIAL), <: B(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=B
@@ -0,0 +1,18 @@
VARIABLES T
SUBTYPE T A
SUPERTYPE T C
type parameter bounds:
T <: A(SPECIAL), >: C(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=C
@@ -0,0 +1,19 @@
VARIABLES T
SUBTYPE T A
SUPERTYPE T B
SUPERTYPE T C
type parameter bounds:
T <: A(SPECIAL), >: B(SPECIAL), >: C(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=B
@@ -1,4 +1,4 @@
fun foo<T, P, Q, R, S>() = 42
fun foo<T, P: T>() = 42
trait A
trait B : A
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1000)
SUBTYPE T Byte
type parameter bounds:
T >: IntegerValueType(1000)(SPECIAL), <: jet.Byte(SPECIAL)
status:
-hasConflictingConstraints: true
-hasContradiction: true
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: false
result:
T=???
@@ -0,0 +1,17 @@
VARIABLES T
SUPERTYPE T IntegerValueType(10000000000)
type parameter bounds:
T >: IntegerValueType(10000000000)(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Long
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
SUBTYPE T Any
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL), <: jet.Any(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Int
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
SUPERTYPE T String
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL), >: jet.String(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Comparable<out jet.Any?>
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
SUPERTYPE T IntegerValueType(1000)
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL), >: IntegerValueType(1000)(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Int
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
SUBTYPE T Byte
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL), <: jet.Byte(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Byte
@@ -0,0 +1,17 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Int
@@ -0,0 +1,18 @@
VARIABLES T
SUPERTYPE T IntegerValueType(1)
SUBTYPE T Short
type parameter bounds:
T >: IntegerValueType(1)(SPECIAL), <: jet.Short(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Short
@@ -0,0 +1,20 @@
VARIABLES T P
SUBTYPE T Int
type parameter bounds:
T <: jet.Int(SPECIAL)
P <: ???(TYPE_BOUND_POSITION(1)), <: jet.Int(COMPOUND_CONSTRAINT_POSITION)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=jet.Int
P=jet.Int
@@ -0,0 +1,17 @@
VARIABLES T
SUBTYPE Consumer<A> Consumer<T>
type parameter bounds:
T <: A(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=A
@@ -0,0 +1,17 @@
VARIABLES T
SUBTYPE My<T> My<A>
type parameter bounds:
T := A(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=A
@@ -0,0 +1,17 @@
VARIABLES T
SUBTYPE Producer<A> Producer<T>
type parameter bounds:
T >: A(SPECIAL)
status:
-hasConflictingConstraints: false
-hasContradiction: false
-hasErrorInConstrainingTypes: false
-hasTypeConstructorMismatch: false
-hasUnknownParameters: false
-hasViolatedUpperBound: false
-isSuccessful: true
result:
T=A
@@ -46,15 +46,16 @@ import java.util.Collections
import com.intellij.openapi.project.Project
import java.util.HashMap
import java.util.regex.Pattern
import org.jetbrains.jet.resolve.constraintSystem.ConstraintSystemTest.MyConstraintKind
import org.jetbrains.jet.resolve.constraintSystem.ConstraintSystemTest.MyConstraint
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest.MyConstraintKind
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest.MyConstraint
import java.util.ArrayList
import kotlin.test.assertEquals
import org.junit.Assert
import java.util.LinkedHashMap
public class ConstraintSystemTest() : JetLiteFixture() {
val constraintPattern = Pattern.compile("(SUBTYPE|SUPERTYPE|EQUALITY)\\s+(\\w+)\\s+(\\w+)", Pattern.MULTILINE)
abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
private val typePattern = """([\w|<|>|\(|\)]+)"""
val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE|EQUALITY)\s+${typePattern}\s+${typePattern}\s+(!)?""", Pattern.MULTILINE)
val variablesPattern = Pattern.compile("VARIABLES\\s+(.*)")
private var builtIns: KotlinBuiltIns? = null
@@ -92,10 +93,6 @@ public class ConstraintSystemTest() : JetLiteFixture() {
return MyDeclarations(bindingContext, getProject(), typeResolver!!)
}
public fun testSimpleSuccessful() {
doTest("compiler/testData/constraintSystem/simpleSuccessful.bounds")
}
public fun doTest(filePath: String) {
val file = File(filePath)
val fileText = JetTestUtils.doLoadFile(file)!!
@@ -103,7 +100,7 @@ public class ConstraintSystemTest() : JetLiteFixture() {
val constraintSystem = ConstraintSystemImpl()
val myDeclarations = analyzeDeclarations()
val typeParameterDescriptors = HashMap<TypeParameterDescriptor, Variance>()
val typeParameterDescriptors = LinkedHashMap<TypeParameterDescriptor, Variance>()
val variables = parseVariables(fileText)
for (variable in variables) {
typeParameterDescriptors.put(myDeclarations.getParameterDescriptor(variable), Variance.INVARIANT)
@@ -120,20 +117,18 @@ public class ConstraintSystemTest() : JetLiteFixture() {
MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(firstType, secondType, position)
}
}
constraintSystem.processDeclaredBoundConstraints()
val expectedStatus = parseStatus(fileText)
val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM.render(constraintSystem)
Assert.assertEquals("Constraint system status mismatch", expectedStatus, resultingStatus)
val resultingSubstitutor = constraintSystem.getResultingSubstitutor()
val result = StringBuilder() append "result:\n"
for ((typeParameter, variance) in typeParameterDescriptors) {
val resultForTypeParameter = resultingSubstitutor.substitute(myDeclarations.getType(typeParameter.getName().asString()), variance)
result append "${typeParameter.getName()}=${resultForTypeParameter}"
result append "${typeParameter.getName()}=${resultForTypeParameter?.let{ Renderers.RENDER_TYPE.render(it) }}\n"
}
val expectedResult = parseResult(fileText)
Assert.assertEquals("Constraint system substitution mismatch", expectedResult, result.toString())
JetTestUtils.assertEqualsToFile(file, "${getConstraintsText(fileText)}${resultingStatus}\n\n${result}\n")
}
class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String, val isWeak: Boolean)
@@ -164,9 +159,7 @@ public class ConstraintSystemTest() : JetLiteFixture() {
return constraints
}
private fun parseStatus(text: String) = text.substring(text.indexOf("type parameter bounds"), text.indexOf("result")).trim()
private fun parseResult(text: String) = text.substring(text.indexOf("result"), text.length())
private fun getConstraintsText(text: String) = text.substring(0, text.indexOf("type parameter bounds"))
}
@@ -0,0 +1,195 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.resolve.constraintSystem;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/constraintSystem")
@InnerTestClasses({ConstraintSystemTestGenerated.CheckStatus.class, ConstraintSystemTestGenerated.ComputeValues.class, ConstraintSystemTestGenerated.IntegerValueTypes.class, ConstraintSystemTestGenerated.SeveralVariables.class, ConstraintSystemTestGenerated.Variance.class})
public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest {
public void testAllFilesPresentInConstraintSystem() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("compiler/testData/constraintSystem/checkStatus")
public static class CheckStatus extends AbstractConstraintSystemTest {
public void testAllFilesPresentInCheckStatus() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem/checkStatus"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("conflictingConstraints.bounds")
public void testConflictingConstraints() throws Exception {
doTest("compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds");
}
@TestMetadata("successful.bounds")
public void testSuccessful() throws Exception {
doTest("compiler/testData/constraintSystem/checkStatus/successful.bounds");
}
@TestMetadata("typeConstructorMismatch.bounds")
public void testTypeConstructorMismatch() throws Exception {
doTest("compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds");
}
@TestMetadata("unknownParameters.bounds")
public void testUnknownParameters() throws Exception {
doTest("compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds");
}
@TestMetadata("violatedUpperBound.bounds")
public void testViolatedUpperBound() throws Exception {
doTest("compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds");
}
}
@TestMetadata("compiler/testData/constraintSystem/computeValues")
public static class ComputeValues extends AbstractConstraintSystemTest {
public void testAllFilesPresentInComputeValues() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem/computeValues"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("contradiction.bounds")
public void testContradiction() throws Exception {
doTest("compiler/testData/constraintSystem/computeValues/contradiction.bounds");
}
@TestMetadata("subTypeOfUpperBounds.bounds")
public void testSubTypeOfUpperBounds() throws Exception {
doTest("compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds");
}
@TestMetadata("superTypeOfLowerBounds1.bounds")
public void testSuperTypeOfLowerBounds1() throws Exception {
doTest("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds");
}
@TestMetadata("superTypeOfLowerBounds2.bounds")
public void testSuperTypeOfLowerBounds2() throws Exception {
doTest("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds");
}
}
@TestMetadata("compiler/testData/constraintSystem/integerValueTypes")
public static class IntegerValueTypes extends AbstractConstraintSystemTest {
public void testAllFilesPresentInIntegerValueTypes() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem/integerValueTypes"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("byteOverflow.bounds")
public void testByteOverflow() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds");
}
@TestMetadata("defaultLong.bounds")
public void testDefaultLong() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds");
}
@TestMetadata("numberAndAny.bounds")
public void testNumberAndAny() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds");
}
@TestMetadata("numberAndString.bounds")
public void testNumberAndString() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds");
}
@TestMetadata("severalNumbers.bounds")
public void testSeveralNumbers() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds");
}
@TestMetadata("simpleByte.bounds")
public void testSimpleByte() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds");
}
@TestMetadata("simpleInt.bounds")
public void testSimpleInt() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds");
}
@TestMetadata("simpleShort.bounds")
public void testSimpleShort() throws Exception {
doTest("compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds");
}
}
@TestMetadata("compiler/testData/constraintSystem/severalVariables")
public static class SeveralVariables extends AbstractConstraintSystemTest {
public void testAllFilesPresentInSeveralVariables() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem/severalVariables"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("simpleDependency.bounds")
public void testSimpleDependency() throws Exception {
doTest("compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds");
}
}
@TestMetadata("compiler/testData/constraintSystem/variance")
public static class Variance extends AbstractConstraintSystemTest {
public void testAllFilesPresentInVariance() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/constraintSystem/variance"), Pattern.compile("^(.+)\\.bounds$"), true);
}
@TestMetadata("consumer.bounds")
public void testConsumer() throws Exception {
doTest("compiler/testData/constraintSystem/variance/consumer.bounds");
}
@TestMetadata("invariant.bounds")
public void testInvariant() throws Exception {
doTest("compiler/testData/constraintSystem/variance/invariant.bounds");
}
@TestMetadata("producer.bounds")
public void testProducer() throws Exception {
doTest("compiler/testData/constraintSystem/variance/producer.bounds");
}
}
public static Test suite() {
TestSuite suite = new TestSuite("ConstraintSystemTestGenerated");
suite.addTestSuite(ConstraintSystemTestGenerated.class);
suite.addTestSuite(CheckStatus.class);
suite.addTestSuite(ComputeValues.class);
suite.addTestSuite(IntegerValueTypes.class);
suite.addTestSuite(SeveralVariables.class);
suite.addTestSuite(Variance.class);
return suite;
}
}
@@ -44,6 +44,9 @@ import java.io.File
import java.io.IOException
import java.util.Collections
import com.intellij.openapi.project.Project
import java.util.regex.Pattern
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstructor
import org.jetbrains.jet.lang.types.JetTypeImpl
public class MyDeclarations(
private val context: BindingContext,
@@ -70,7 +73,16 @@ public class MyDeclarations(
throw AssertionError("Unsupported type parameter name: " + name + ".")
}
fun getType(name: String) = typeResolver.resolveType(
fun getType(name: String): JetType {
val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name)
if (matcher.find()) {
val number = matcher.group(1)!!
return JetTypeImpl(IntegerValueTypeConstructor(number.toLong()), JetScope.EMPTY)
}
return typeResolver.resolveType(
scopeToResolveTypeParameters, JetPsiFactory.createType(project, name),
JetTestUtils.DUMMY_TRACE, true)
}
}
private val INTEGER_VALUE_TYPE_PATTERN = Pattern.compile("""IntegerValueType\((\d*)\)""")
@@ -87,6 +87,7 @@ import org.jetbrains.jet.completion.handlers.AbstractSmartCompletionHandlerTest
import org.jetbrains.jet.generators.tests.generator.TestGeneratorUtil
import org.jetbrains.jet.resolve.AbstractAdditionalLazyResolveDescriptorRendererTest
import org.jetbrains.jet.resolve.AbstractReferenceResolveInLibrarySourcesTest
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest
import org.jetbrains.jet.completion.AbstractCompiledKotlinInJavaCompletionTest
import org.jetbrains.jet.completion.AbstractKotlinSourceInJavaCompletionTest
import org.jetbrains.jet.plugin.intentions.AbstractIntentionTest
@@ -117,6 +118,10 @@ fun main(args: Array<String>) {
model("resolvedCalls")
}
testClass(javaClass<AbstractConstraintSystemTest>()) {
model("constraintSystem", extension = "bounds")
}
testClass(javaClass<AbstractJetParsingTest>()) {
model("psi", testMethod = "doParsingTest")
}