Search in sources :

Example 6 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class DeltaOrderingTest method circularOrder1.

@Test(expected = DeltaModellingException.class)
public void circularOrder1() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParse("module M;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A;" + "delta D1 after D2 when A;" + "delta D2 after D1 when A;" + "product P(A);");
    model.evaluateAllProductDeclarations();
    model.flattenForProduct("P");
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 7 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class DeltaOrderingTest method properSorting9.

@Test
public void properSorting9() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParse("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "delta D4;" + "delta D5;" + "delta D6;" + "delta D7;" + "delta D8;" + "delta D9;" + "productline PL;" + "features A,B,C,D,E,F,G,H,I;" + "delta D1 after D2 when A;" + "delta D2 after D3 when B;" + "delta D3 after D4 when C;" + "delta D4 after D5 when D;" + "delta D5 after D6 when E;" + "delta D6 after D7 when F;" + "delta D7 after D8 when G;" + "delta D8 after D9 when H;" + "delta D9 when I;" + "product P1(A,B,C,D,E,F,G,H,I);" + "product P2(A,C,E,G,I);");
    model.evaluateAllProductDeclarations();
    ProductDecl prod = model.findProduct("P1");
    ProductLine pl = model.getProductLine();
    Set<String> deltaids = pl.findApplicableDeltas(prod.getProduct());
    List<String> sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D9", "D8", "D7", "D6", "D5", "D4", "D3", "D2", "D1" }, sorted_deltaids.toArray());
    prod = model.findProduct("P2");
    deltaids = pl.findApplicableDeltas(prod.getProduct());
    sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D9", "D7", "D5", "D3", "D1" }, sorted_deltaids.toArray());
    assertFalse(model.typeCheck().containsErrors());
}
Also used : ProductDecl(org.abs_models.frontend.ast.ProductDecl) Model(org.abs_models.frontend.ast.Model) ProductLine(org.abs_models.frontend.ast.ProductLine) Test(org.junit.Test)

Example 8 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class MaudeTests method getMaudeCode.

protected String getMaudeCode(String absCode, MaudeCompiler.SIMULATOR module) throws Exception {
    Model model = assertParse(absCode, Config.WITHOUT_MODULE_NAME, Config.TYPE_CHECK);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    // TODO: handle delta generation / testing / flattening
    model.generateMaude(new PrintStream(out), module, 100, 0);
    String res = out.toString();
    return res;
}
Also used : PrintStream(java.io.PrintStream) Model(org.abs_models.frontend.ast.Model) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 9 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class ASTBasedABSTestRunnerGeneratorTest method testABSTestRunnerGenerator.

@Test
public final void testABSTestRunnerGenerator() {
    Model model = new Model();
    ABSTestRunnerGenerator generator = new ASTBasedABSTestRunnerGenerator(model);
    assertMatches(model, nullValue(), nullValue(), nullValue(), nullValue(), equalTo(EMPTY_MAP), Boolean.TRUE, generator);
    try {
        model = ABSTest.parseString(ABS_UNIT);
        generator = new ASTBasedABSTestRunnerGenerator(model);
        assertMatches(model, notNullValue(), notNullValue(), notNullValue(), notNullValue(), equalTo(EMPTY_MAP), Boolean.TRUE, generator);
        model = ABSTest.parseString(ABS_UNIT + TEST_CODE);
        generator = new ASTBasedABSTestRunnerGenerator(model);
        assertMatches(model, notNullValue(), notNullValue(), notNullValue(), notNullValue(), both(everyItem(new TestClassMatcher())).and(new SizeMatcher(1)), Boolean.FALSE, generator);
    } catch (Exception e) {
        throw new IllegalStateException("Cannot parse test code", e);
    }
}
Also used : Model(org.abs_models.frontend.ast.Model) ABSTest(org.abs_models.ABSTest) Test(org.junit.Test)

Example 10 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class OriginalCallTest method targetedOriginalNotFound.

@Test(expected = DeltaModellingException.class)
public void targetedOriginalNotFound() throws DeltaModellingException {
    Model model = assertParse("module M;" + "class C { }" + "delta D1;" + "uses M;" + "modifies class C { modifies Unit m() { core.original(); } }");
    DeltaDecl d1 = findDelta(model, "D1");
    // Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(d1)));
    model.applyDeltas(new ArrayList<>(Arrays.asList(d1)));
}
Also used : Model(org.abs_models.frontend.ast.Model) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Aggregations

Model (org.abs_models.frontend.ast.Model)268 Test (org.junit.Test)227 FrontendTest (org.abs_models.frontend.FrontendTest)101 ClassDecl (org.abs_models.frontend.ast.ClassDecl)72 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)34 SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)29 ABSTest (org.abs_models.ABSTest)22 ProductDecl (org.abs_models.frontend.ast.ProductDecl)17 FunctionDecl (org.abs_models.frontend.ast.FunctionDecl)15 HashSet (java.util.HashSet)13 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)13 PrintStream (java.io.PrintStream)12 Product (org.abs_models.frontend.ast.Product)11 SkipStmt (org.abs_models.frontend.ast.SkipStmt)11 VarUse (org.abs_models.frontend.ast.VarUse)11 Feature (org.abs_models.frontend.ast.Feature)10 File (java.io.File)9 ExpFunctionDef (org.abs_models.frontend.ast.ExpFunctionDef)9 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)9 KindedName (org.abs_models.frontend.typechecker.KindedName)9