Search in sources :

Example 1 with ConstructorPattern

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

the class VarResolutionTest method testNestedPatternVar.

@Test
public void testNestedPatternVar() {
    Model m = assertParse("data Foo = Bar(Bool); def Bool m(Foo f) = case f { Bar(y) => y; };");
    assertThat(getFirstCaseExpr(m), instanceOf(VarUse.class));
    ConstructorPattern p = (ConstructorPattern) getFirstCasePattern(m);
    PatternVarDecl decl = ((PatternVar) p.getParam(0)).getVar();
    assertEquals("y", decl.getName());
}
Also used : Model(org.abs_models.frontend.ast.Model) PatternVar(org.abs_models.frontend.ast.PatternVar) VarUse(org.abs_models.frontend.ast.VarUse) PatternVarDecl(org.abs_models.frontend.ast.PatternVarDecl) ConstructorPattern(org.abs_models.frontend.ast.ConstructorPattern) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

FrontendTest (org.abs_models.frontend.FrontendTest)1 ConstructorPattern (org.abs_models.frontend.ast.ConstructorPattern)1 Model (org.abs_models.frontend.ast.Model)1 PatternVar (org.abs_models.frontend.ast.PatternVar)1 PatternVarDecl (org.abs_models.frontend.ast.PatternVarDecl)1 VarUse (org.abs_models.frontend.ast.VarUse)1 Test (org.junit.Test)1