use of abs.frontend.ast.ReturnStmt in project abstools by abstools.
the class OtherAnalysisTests method awaitRewriteModule1.
@Test
public void awaitRewriteModule1() {
Model.doAACrewrite = false;
Model m = assertParseOk("module A; export *; data X; module B; export *; data X; module C; import * from A; import B.X; class C { X m() { return await this!m();}}");
ClassDecl c = (ClassDecl) m.lookupModule("C").getDecl(0);
ReturnStmt ret = (ReturnStmt) c.getMethod(0).getBlock().getStmt(0);
assertThat(ret.getRetExp().getType(), instanceOf(DataTypeType.class));
assertEquals("A.X", ret.getRetExp().getType().getQualifiedName());
Model.doAACrewrite = true;
m = assertParseOk("module A; export *; data X; module B; export *; data X; module C; import * from A; import B.X; class C { X m() { return await this!m();}}", Config.WITH_STD_LIB);
c = (ClassDecl) m.lookupModule("C").getDecl(0);
Stmt s = c.getMethod(0).getBlock().getStmt(0);
VarDeclStmt b = (VarDeclStmt) s;
Type t = ((DataTypeType) b.getVarDecl().getType()).getTypeArg(0);
assertEquals("A.X", t.getQualifiedName());
}
use of abs.frontend.ast.ReturnStmt in project abstools by abstools.
the class TypingTest method testFieldUse.
@Test
public void testFieldUse() {
Model m = assertParseOkStdLib(" class C { Bool f; Bool m() { return this.f; } }");
ClassDecl d = (ClassDecl) m.lookup(new KindedName(Kind.CLASS, "UnitTest.C"));
FieldDecl f = d.getField(0);
ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
assertEquals(f.getType(), s.getRetExp().getType());
}
use of abs.frontend.ast.ReturnStmt in project abstools by abstools.
the class DeltaForGetSetFieldsBuilder method addGetter.
AddMethodModifier addGetter(Exp returnValue, String fieldName, Access returnType) {
MethodSig sig = new MethodSig(testCaseNameBuilder.getterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), returnType, new abs.frontend.ast.List<ParamDecl>());
Block block = new Block();
ReturnStmt rs = new ReturnStmt();
rs.setRetExp(new FieldUse(fieldName));
block.addStmtNoTransform(rs);
MethodImpl method = new MethodImpl(sig, block, false);
AddMethodModifier modifier = new AddMethodModifier(method);
return modifier;
}
Aggregations