Commit a232b62f authored by André Pacak's avatar André Pacak

automated test to check whether models are well or illtyped without dynamic changes to tests

parent c46cc481
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:ec651532-5c8d-4b2f-8038-8d287d9e0290(SumTypes_Checker.test.fail.arithmetic)">
<model ref="r:ec651532-5c8d-4b2f-8038-8d287d9e0290(SumTypes_Checker.test.fail_arithmetic)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:621e245e-6257-4f76-815c-cf1196b979d2(SumTypes_Checker.test.fail.case_right_shadow)">
<model ref="r:621e245e-6257-4f76-815c-cf1196b979d2(SumTypes_Checker.test.fail_case_right_shadow)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:c08eeb92-770b-4871-9ce9-e89a2e0399d7(SumTypes_Checker.test.fail.case_unequal_return_types)">
<model ref="r:c08eeb92-770b-4871-9ce9-e89a2e0399d7(SumTypes_Checker.test.fail_case_unequal_return_types)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:999b4f81-8f6e-460d-b975-70793e2b62e2(SumTypes_Checker.test.fail.inl)">
<model ref="r:999b4f81-8f6e-460d-b975-70793e2b62e2(SumTypes_Checker.test.fail_inl)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:f2e84883-9544-4c75-8019-c418d313cd46(SumTypes_Checker.test.fail.inr)">
<model ref="r:f2e84883-9544-4c75-8019-c418d313cd46(SumTypes_Checker.test.fail_inr)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:48182acc-6acf-4871-b0fe-a0e4333031e0(SumTypes_Checker.test.fail.lambda_no_anno)">
<model ref="r:48182acc-6acf-4871-b0fe-a0e4333031e0(SumTypes_Checker.test.fail_lambda_no_anno)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:11878a79-accb-4766-a9a9-f3606d6e7267(SumTypes_Checker.test.ok.anno)">
<model ref="r:11878a79-accb-4766-a9a9-f3606d6e7267(SumTypes_Checker.test.ok_anno)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:2c694cde-7229-4db6-aeb9-493fa1d2c215(SumTypes_Checker.test.ok.anno_in_let)">
<model ref="r:2c694cde-7229-4db6-aeb9-493fa1d2c215(SumTypes_Checker.test.ok_anno_in_let)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:264e7c2c-7e14-4148-b451-479afe8b2765(SumTypes_Checker.test.ok.app_lambda_anno)">
<model ref="r:264e7c2c-7e14-4148-b451-479afe8b2765(SumTypes_Checker.test.ok_app_lambda_anno)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:35c866ef-6de2-4f38-b90d-06764fe4e33f(SumTypes_Checker.test.ok.arithmetic)">
<model ref="r:35c866ef-6de2-4f38-b90d-06764fe4e33f(SumTypes_Checker.test.ok_arithmetic)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:df467971-2eb9-4bab-83a9-e57214a25281(SumTypes_Checker.test.ok.case_left)">
<model ref="r:df467971-2eb9-4bab-83a9-e57214a25281(SumTypes_Checker.test.ok_case_left)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:1affe70d-b8ba-4f62-8a29-b0a0ee7b2369(SumTypes_Checker.test.ok.case_left_shadow)">
<model ref="r:1affe70d-b8ba-4f62-8a29-b0a0ee7b2369(SumTypes_Checker.test.ok_case_left_shadow)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:4874477a-7d63-48bb-83c6-81457814a615(SumTypes_Checker.test.ok.case_right)">
<model ref="r:4874477a-7d63-48bb-83c6-81457814a615(SumTypes_Checker.test.ok_case_right)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:c63cc1d5-dea2-4fd8-878d-1cd3c127f487(SumTypes_Checker.test.ok.inl)">
<model ref="r:c63cc1d5-dea2-4fd8-878d-1cd3c127f487(SumTypes_Checker.test.ok_inl)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:d31d5b14-c99f-44e3-bf3c-bff6e95a4dfb(SumTypes_Checker.test.ok.inr)">
<model ref="r:d31d5b14-c99f-44e3-bf3c-bff6e95a4dfb(SumTypes_Checker.test.ok_inr)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:692440e8-e163-481a-960d-96f2c311ad24(SumTypes_Checker.test.ok.lambda_anno)">
<model ref="r:692440e8-e163-481a-960d-96f2c311ad24(SumTypes_Checker.test.ok_lambda_anno)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:1ed93750-b61e-450a-8a88-f766024e045a(SumTypes_Checker.test.ok.let_with_arithmetic)">
<model ref="r:1ed93750-b61e-450a-8a88-f766024e045a(SumTypes_Checker.test.ok_let_with_arithmetic)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:5827c534-5c77-4967-8b21-edfc31919f61(SumTypes_Checker.test.ok.succ)">
<model ref="r:5827c534-5c77-4967-8b21-edfc31919f61(SumTypes_Checker.test.ok_succ)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
<?xml version="1.0" encoding="UTF-8"?>
<model ref="r:1fffa720-7b65-48da-85f7-5c96d5357c11(SumTypes_Checker.test.ok.zero)">
<model ref="r:1fffa720-7b65-48da-85f7-5c96d5357c11(SumTypes_Checker.test.ok_zero)">
<persistence version="9" />
<languages>
<use id="08d23328-33fa-47ce-89df-daaa7554f251" name="SumTypes" version="0" />
......
......@@ -5,9 +5,9 @@
<classNode dependClassName="SumTypes_Checker.model.Typing_InferQuerySpecification" />
<classNode dependClassName="java.lang.Object" />
<classNode dependClassName="java.lang.String" />
<classNode dependClassName="java.lang.System" />
<classNode dependClassName="java.util.Map" />
<classNode dependClassName="java.util.Set" />
<classNode dependClassName="jetbrains.mps.internal.collections.runtime.IWhereFilter" />
<classNode dependClassName="jetbrains.mps.internal.collections.runtime.SetSequence" />
<classNode dependClassName="org.eclipse.viatra.query.runtime.api.IPatternMatch" />
<classNode dependClassName="org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher" />
......
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-2y8w4dw4jt3nido63a70c8fx5lb0k3e">
<product version="3" modelHash="-2nlixlnaqxvyojsou73f5s1iy8c4c84">
<files names="AnalysisResultAccess.java:ConstantDefinitions.java:LType.java:QuerySpecificationHints.java:Typing_AllvarsQuerySpecification.java:Typing_Allvars_0_switchCommonQuerySpecification.java:Typing_AsLTypeQuerySpecification.java:Typing_AsLType_0_switchCommonQuerySpecification.java:Typing_AsLType_WrappedBody0QuerySpecification.java:Typing_AsLType_WrappedBody1QuerySpecification.java:Typing_AsLType_WrappedBody2QuerySpecification.java:Typing_AsLType_WrappedBody3QuerySpecification.java:Typing_AsLType_WrappedQuerySpecification.java:Typing_CheckErrorQuerySpecification.java:Typing_CheckQuerySpecification.java:Typing_Check_0_switchCommonQuerySpecification.java:Typing_InferQuerySpecification.java:Typing_Infer_0_switchCommonQuerySpecification.java:Typing_Infer_WrappedBody0QuerySpecification.java:Typing_Infer_WrappedBody1QuerySpecification.java:Typing_Infer_WrappedBody2QuerySpecification.java:Typing_Infer_WrappedBody3QuerySpecification.java:Typing_Infer_WrappedBody4QuerySpecification.java:Typing_Infer_WrappedBody5QuerySpecification.java:Typing_Infer_WrappedBody6QuerySpecification.java:Typing_Infer_WrappedBody7QuerySpecification.java:Typing_Infer_WrappedBody8QuerySpecification.java:Typing_Infer_WrappedBody9QuerySpecification.java:Typing_Infer_WrappedQuerySpecification.java:Typing_LookupFailureQuerySpecification.java:Typing_LookupFailure_0_switchCommonQuerySpecification.java:Typing_LookupQuerySpecification.java:Typing_Lookup_0_switchCommonQuerySpecification.java:Typing_Lookup_WrappedBody0QuerySpecification.java:Typing_Lookup_WrappedBody10QuerySpecification.java:Typing_Lookup_WrappedBody11QuerySpecification.java:Typing_Lookup_WrappedBody12QuerySpecification.java:Typing_Lookup_WrappedBody13QuerySpecification.java:Typing_Lookup_WrappedBody14QuerySpecification.java:Typing_Lookup_WrappedBody15QuerySpecification.java:Typing_Lookup_WrappedBody16QuerySpecification.java:Typing_Lookup_WrappedBody17QuerySpecification.java:Typing_Lookup_WrappedBody18QuerySpecification.java:Typing_Lookup_WrappedBody19QuerySpecification.java:Typing_Lookup_WrappedBody1QuerySpecification.java:Typing_Lookup_WrappedBody20QuerySpecification.java:Typing_Lookup_WrappedBody2QuerySpecification.java:Typing_Lookup_WrappedBody3QuerySpecification.java:Typing_Lookup_WrappedBody4QuerySpecification.java:Typing_Lookup_WrappedBody5QuerySpecification.java:Typing_Lookup_WrappedBody6QuerySpecification.java:Typing_Lookup_WrappedBody7QuerySpecification.java:Typing_Lookup_WrappedBody8QuerySpecification.java:Typing_Lookup_WrappedBody9QuerySpecification.java:Typing_Lookup_WrappedQuerySpecification.java:Typing_MatchFunFailureQuerySpecification.java:Typing_MatchFunFailure_0_switchCommonQuerySpecification.java:Typing_MatchSumFailureQuerySpecification.java:Typing_MatchSumFailure_0_switchCommonQuerySpecification.java:Typing_RequiredQuerySpecification.java:Typing_Required_0_switchCommonQuerySpecification.java:Typing_Required_WrappedBody0QuerySpecification.java:Typing_Required_WrappedBody10QuerySpecification.java:Typing_Required_WrappedBody11QuerySpecification.java:Typing_Required_WrappedBody12QuerySpecification.java:Typing_Required_WrappedBody1QuerySpecification.java:Typing_Required_WrappedBody2QuerySpecification.java:Typing_Required_WrappedBody3QuerySpecification.java:Typing_Required_WrappedBody4QuerySpecification.java:Typing_Required_WrappedBody5QuerySpecification.java:Typing_Required_WrappedBody6QuerySpecification.java:Typing_Required_WrappedBody7QuerySpecification.java:Typing_Required_WrappedBody8QuerySpecification.java:Typing_Required_WrappedBody9QuerySpecification.java:Typing_Required_WrappedQuerySpecification.java" />
</product>
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-9klrq6yjvcaxybra1utvzpy2ipej0k6" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-bj3tghsv5f59mfa6jmaiu3zcm6c1rar" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="a2h21oox3acz46dgs0qqanlp1koqj3l" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="f2x6nro2wgh6ozm2ecw3zn0nn044m8" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="80m79e9462r11qlmzg54a2ucg1ml9ju" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="bbjw392j4sabs7cdwgsxsnq63r26dh1" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-vqy985yo21cvvhm32m8xbsvmxv9ywe" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="9k19b98ojynv0cyxzsnj5ap2h6g5qz1" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="b6e1jnisxs1xj3ylwwvpkeo8m7tof85" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-c98uc7yssswvq7q1m125x6pxg7yxx78" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-ammnyc5n94j9528fxssqclczz0fe61k" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-9o0o6mgweq6akvc9i2qmagdnzs57g26" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-d9gdj86ehdc4zke7d1gd6dauaplf634" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="e99yxpqjkkmg1n1pem1o220l253wd5q" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="1ffhscgif2nyudpizk8hagrt3fgad3f" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="dyn3qyhb44qc2v11l6erhh9xm8fqbda" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="e9z8gxhgxp36gnueu7ve931a7g9rslh" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="7bekqxggys1b6q17xlmiqtao5otvah" />
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="axr70m8n5tjsee71efzqbpgqjdlg20u" />
......@@ -12,6 +12,7 @@ import org.eclipse.viatra.query.runtime.rete.matcher.DRedReteBackendFactory;
import java.util.Set;
import org.inca.core.util.plugin.CodeGenerationHelper;
import jetbrains.mps.internal.collections.runtime.SetSequence;
import jetbrains.mps.internal.collections.runtime.IWhereFilter;
import java.util.Map;
import org.inca.data.runtime.plugin.SequenceMatcher;
import org.inca.data.runtime.plugin.WildCardMatcher;
......@@ -20,30 +21,141 @@ import org.inca.data.runtime.plugin.IDataMatcher;
import org.inca.data.runtime.plugin.CompositeMatcher;
public class AnalysisResultAccess {
public static String expectedType(final SNode term, final SModel scope) {
final ViatraQueryMatcher<IPatternMatch> evaluator = EnginePool.getMatcher(Typing_InferQuerySpecification.instance(), AbstractScope.from(scope), true, DRedReteBackendFactory.INSTANCE);
final IPatternMatch tup = evaluator.newMatch(term, null);
final Set<LType.LTypeElement> values = CodeGenerationHelper.getAllValues(evaluator, "out_1", tup);
return typeToString(SetSequence.fromSet(values).first());
}
public static boolean isChecked(final SNode term, final SModel scope) {
final ViatraQueryMatcher<IPatternMatch> evaluator = EnginePool.getMatcher(Typing_InferQuerySpecification.instance(), AbstractScope.from(scope), true, DRedReteBackendFactory.INSTANCE);
final IPatternMatch tup = evaluator.newMatch(term, null);
final Set<LType.LTypeElement> values = CodeGenerationHelper.getAllValues(evaluator, "out_1", tup);
System.out.println(values);
// when is something illtyped and when is it welltyped?
// Bot should not appear in values
// Any can appear as long as there is another wellformed type (not containing any)
boolean isBotAvailable = SetSequence.fromSet(values).any(new IWhereFilter<LType.LTypeElement>() {
public boolean accept(LType.LTypeElement it) {
{
final Object[] values_a0a0a0i0d = {it};
// declare the local variables for the case matchers
Map<String, Object> case_0_a0a0a0a8a3;
Map<String, Object> case_1_b0a0a0a8a3;
if ((case_0_a0a0a0a8a3 = new SequenceMatcher(matcher_a0a0a0a0i0d).match(values_a0a0a0i0d)) != null) {
return true;
} else if ((case_1_b0a0a0a8a3 = new SequenceMatcher(WildCardMatcher.INSTANCE).match(values_a0a0a0i0d)) != null) {
return false;
} else {
throw new PatternMatcherException(values_a0a0a0i0d);
}
}
}
});
if (isBotAvailable) {
return false;
}
final LType.LTypeElement nonBotAnyValue = SetSequence.fromSet(values).findFirst(new IWhereFilter<LType.LTypeElement>() {
public boolean accept(LType.LTypeElement it) {
{
final Object[] values_a0a0a0m0d = {it};
// declare the local variables for the case matchers
Map<String, Object> case_0_a0a0a0a21a3;
Map<String, Object> case_1_b0a0a0a21a3;
Map<String, Object> case_2_c0a0a0a21a3;
if ((case_0_a0a0a0a21a3 = new SequenceMatcher(matcher_a0a0a0a0m0d).match(values_a0a0a0m0d)) != null) {
return false;
} else if ((case_1_b0a0a0a21a3 = new SequenceMatcher(matcher_a1a0a0a0m0d).match(values_a0a0a0m0d)) != null) {
return false;
} else if ((case_2_c0a0a0a21a3 = new SequenceMatcher(WildCardMatcher.INSTANCE).match(values_a0a0a0m0d)) != null) {
return true;
} else {
throw new PatternMatcherException(values_a0a0a0m0d);
}
}
}
});
if (nonBotAnyValue != null) {
return isWellFormedType(nonBotAnyValue);
} else {
return false;
}
}
private static boolean isWellFormedType(LType.LTypeElement type) {
{
final Object[] values_e0a = {SetSequence.fromSet(values).first()};
final Object[] values_a0f = {type};
// declare the local variables for the case matchers
Map<String, Object> case_0_a4a0;
Map<String, Object> case_1_b4a0;
Map<String, Object> case_2_c4a0;
Map<String, Object> case_0_a0a5;
Map<String, Object> case_1_b0a5;
Map<String, Object> case_2_c0a5;
Map<String, Object> case_3_d0a5;
Map<String, Object> case_4_e0a5;
if ((case_0_a4a0 = new SequenceMatcher(matcher_a0e0a).match(values_e0a)) != null) {
if ((case_0_a0a5 = new SequenceMatcher(matcher_a0a0f).match(values_a0f)) != null) {
return true;
} else if ((case_1_b4a0 = new SequenceMatcher(matcher_a1e0a).match(values_e0a)) != null) {
} else if ((case_1_b0a5 = new SequenceMatcher(matcher_a1a0f).match(values_a0f)) != null) {
return isWellFormedType(LType.instance().funParamType(type)) && isWellFormedType(LType.instance().funResultType(type));
} else if ((case_2_c0a5 = new SequenceMatcher(matcher_a2a0f).match(values_a0f)) != null) {
return isWellFormedType(LType.instance().sumLeftType(type)) && isWellFormedType(LType.instance().sumRightType(type));
} else if ((case_3_d0a5 = new SequenceMatcher(matcher_a3a0f).match(values_a0f)) != null) {
return false;
} else if ((case_2_c4a0 = new SequenceMatcher(WildCardMatcher.INSTANCE).match(values_e0a)) != null) {
return true;
} else if ((case_4_e0a5 = new SequenceMatcher(matcher_a4a0f).match(values_a0f)) != null) {
return false;
} else {
throw new PatternMatcherException(values_a0f);
}
}
}
private static String typeToString(LType.LTypeElement type) {
{