Search in sources :

Example 11 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaTrieTest method trieStructure2.

@Test
public void trieStructure2() {
    Model model = assertParse("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(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) ProductLine(org.abs_models.frontend.ast.ProductLine) Test(org.junit.Test)

Example 12 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaTrieTest method trieStructure1.

@Test
public void trieStructure1() {
    Model model = assertParse("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(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) ProductLine(org.abs_models.frontend.ast.ProductLine) Test(org.junit.Test)

Example 13 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class DeltaTrieTest method trieContent.

@Test
public void trieContent() {
    // TODO
    Model model = assertParse("module Test;" + "class Ccore{}" + "delta D1; uses Test; adds class C1 {Int f1 = 0; Unit m1() {}}" + "delta D2; uses Test; adds class C2 {Int f2 = 0; Unit m2() {}}" + "delta D3;" + // + " modifies class Test.C2 { adds Int f2a = 1; modifies Unit m2() {} adds Unit m2a() {} }"
    "" + "" + "" + "" + "productline PL;" + "features A,B;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D1,D2 when A && B;" + "root FM {" + " group [1 .. *] { A, B }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
// TODO: tests
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) ProductLine(org.abs_models.frontend.ast.ProductLine) Test(org.junit.Test)

Example 14 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class TypeCheckerTest method test_Movecogto1.

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

Example 15 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class NullCheckerTests method assertTypeErrors.

@Override
protected SemanticCondition assertTypeErrors(String absCode, Config... config) {
    Model m = assertParse(absCode, config);
    String msg = "";
    m.registerTypeSystemExtension(new NullCheckerExtension(m));
    SemanticConditionList l = m.typeCheck();
    if (l.containsErrors()) {
        msg = l.getFirstError().getMsgWithHint(absCode);
    } else if (l.containsWarnings() && isSet(EXPECT_WARNING, config)) {
        msg = l.getFirstWarning().getMsgWithHint(absCode);
    }
    assertEquals(msg, isSet(EXPECT_TYPE_ERROR, config), l.containsErrors());
    if (isSet(EXPECT_WARNING, config)) {
        assertEquals(msg, isSet(EXPECT_WARNING, config), l.containsWarnings());
    }
    return l.containsErrors() ? l.getFirstError() : null;
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) NullCheckerExtension(org.abs_models.frontend.typechecker.nullable.NullCheckerExtension)

Aggregations

SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)42 Model (org.abs_models.frontend.ast.Model)27 Test (org.junit.Test)27 ProductLine (org.abs_models.frontend.ast.ProductLine)7 SemanticCondition (org.abs_models.frontend.analyser.SemanticCondition)6 FrontendTest (org.abs_models.frontend.FrontendTest)5 ProductDecl (org.abs_models.frontend.ast.ProductDecl)3 ABSTest (org.abs_models.ABSTest)2 TypeError (org.abs_models.frontend.analyser.TypeError)2 Constraint (choco.kernel.model.constraints.Constraint)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 PrintWriter (java.io.PrintWriter)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 InternalBackendException (org.abs_models.backend.common.InternalBackendException)1 DefaultABSFormatter (org.abs_models.backend.prettyprint.DefaultABSFormatter)1