Search in sources :

Example 6 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class LocationTypeTests method testInferenceRetypeChecking.

@Test
public void testInferenceRetypeChecking() {
    String code = "interface I { Unit m(); } { [Far] I i; I j; i = j; j.m(); }";
    Model m = assertParseOkStdLib(code);
    LocationTypeExtension te = new LocationTypeExtension(m);
    m.registerTypeSystemExtension(te);
    SemanticConditionList e = m.typeCheck();
    m.typeCheck(new SemanticConditionList());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) LocationTypeExtension(abs.frontend.typechecker.locationtypes.LocationTypeExtension) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 7 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class TypeCheckerTest method test_Movecogto1.

@Test
public void test_Movecogto1() {
    Model m = assertParseOk("class C { Unit do() { movecogto 1; }}", Config.WITH_STD_LIB);
    SemanticConditionList errs = m.typeCheck();
    assertTrue(m.hasTypeErrors());
    assertEquals(ErrorMessage.EXPECTED_DC, errs.getFirstError().msg);
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest) ABSTest(abs.ABSTest)

Example 8 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaSamplesTest method test_P2P_P4.

/*   @Test
    public void test_P2P_P3() throws Exception {
        Model m = assertTypeCheckFileOk("tests/abssamples/deltas/PeerToPeer.abs", true);
        m.setNullPrintStream();
        thrown.expect(DeltaModellingWithNodeException.class);
        m.flattenForProduct("P3");
    }
*/
@Test
public void test_P2P_P4() throws Exception {
    Model m = assertParseFileOk("tests/abssamples/deltas/PeerToPeer.abs", true);
    m.setNullPrintStream();
    m.flattenForProduct("P4");
    m.flushCache();
    SemanticConditionList res = m.typeCheck();
    if (res.containsErrors())
        fail(res.getFirstError().getMessage());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 9 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaTrieTest method trieStructure1.

@Test
public void trieStructure1() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A,B;" + "delta D1 after D2 when A;" + "delta D2 when B;" + "root FM {" + " group [0..*] { A, B }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    // System.out.println(pfgt.toString());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertEquals(0, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D1").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 10 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaTrieTest method trieStructure2.

@Test
public void trieStructure2() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "productline PL;" + "features A,B,C;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D2 when C;" + "root FM {" + " group [0..*] { A, B, C }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(3, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D3").isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertEquals(0, pfgt.getRoot().getChildren().get("D3").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D3").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D3").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Aggregations

SemanticConditionList (abs.frontend.analyser.SemanticConditionList)51 Test (org.junit.Test)30 Model (abs.frontend.ast.Model)24 FrontendTest (abs.frontend.FrontendTest)7 SemanticCondition (abs.frontend.analyser.SemanticCondition)7 LocationTypeInferrerExtension (abs.frontend.typechecker.locationtypes.infer.LocationTypeInferrerExtension)7 LocationType (abs.frontend.typechecker.locationtypes.LocationType)5 LocationTypeExtension (abs.frontend.typechecker.locationtypes.LocationTypeExtension)4 WrongProgramArgumentException (abs.common.WrongProgramArgumentException)3 ProductLine (abs.frontend.ast.ProductLine)3 TypeError (abs.frontend.analyser.TypeError)2 CompilationUnit (abs.frontend.ast.CompilationUnit)2 DeltaModellingException (abs.frontend.delta.DeltaModellingException)2 Main (abs.frontend.parser.Main)2 ParserError (abs.frontend.parser.ParserError)2 File (java.io.File)2 ABSTest (abs.ABSTest)1 InternalBackendException (abs.backend.common.InternalBackendException)1 DefaultABSFormatter (abs.backend.prettyprint.DefaultABSFormatter)1 SemanticError (abs.frontend.analyser.SemanticError)1