use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class WizardUtilsTests method testGetProjectOfModuleDecl.
@Test
public void testGetProjectOfModuleDecl() {
AbsNature natureMock = mock(AbsNature.class);
IProject project = mock(IProject.class);
when(project.getName()).thenReturn("");
when(natureMock.getProject()).thenReturn(project);
ModuleDecl moduleMock = mock(ModuleDecl.class);
InternalASTNode<ModuleDecl> node = new InternalASTNode<ModuleDecl>(moduleMock, natureMock);
assertSame(node.getProject(), project);
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class WizardUtilsTests method testValidateClass.
@Test
public void testValidateClass() {
ModuleDecl mockDecl = mock(ModuleDecl.class);
List<Decl> list = new List<Decl>();
ClassDecl m1 = mock(ClassDecl.class);
ClassDecl m2 = mock(ClassDecl.class);
when(m1.getName()).thenReturn("Class1");
when(m2.getName()).thenReturn("Class2");
list.add(m1);
list.add(m2);
when(mockDecl.getDecls()).thenReturn(list);
String valid1 = "A";
String valid2 = "Abc3";
String valid3 = "ABC3";
String invalid1 = "";
String invalid2 = "a";
String invalid3 = "a.b";
String invalid4 = ";";
String invalid5 = "module";
String invalid6 = "Class1";
String invalid7 = "Class2";
assertTrue(validateClass(valid1, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateClass(valid2, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateClass(valid3, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateClass(invalid1, mockDecl).equals(ErrorType.ERROR_NO_NAME));
assertTrue(validateClass(invalid2, mockDecl).equals(ErrorType.ERROR_NO_UPPER_CASE));
assertTrue(validateClass(invalid3, mockDecl).equals(ErrorType.ERROR_NO_UPPER_CASE));
assertTrue(validateClass(invalid4, mockDecl).equals(ErrorType.ERROR_INVALID_NAME));
assertTrue(validateClass(invalid5, mockDecl).equals(ErrorType.ERROR_KEYWORD));
assertTrue(validateClass(invalid6, mockDecl).equals(ErrorType.ERROR_DUPLICATE_NAME));
assertTrue(validateClass(invalid7, mockDecl).equals(ErrorType.ERROR_DUPLICATE_NAME));
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ParFnAppTest method sameAnonTwiceTwoExpansions.
@Test
public void sameAnonTwiceTwoExpansions() {
Model m = testExpand(parse("apply((Int i) => i)(1);" + "apply((Int i) => i)(1);", applyFunction()));
ModuleDecl module = m.lookupModule("UnitTest");
int foundExpansions = 0;
for (Decl decl : module.getDecls()) {
if (decl instanceof FunctionDecl) {
FunctionDecl fun = (FunctionDecl) decl;
if (fun.getName().startsWith("Apply_")) {
++foundExpansions;
}
}
}
assertEquals(2, foundExpansions);
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ABSUnitTestCaseTranslator method validateOutput.
private void validateOutput() {
CompilationUnit unit = new CompilationUnit();
ModuleDecl cm = module.treeCopyNoTransform();
unit.addModuleDecl(cm);
for (DeltaWrapper d : deltas) {
unit.addDeltaDecl(d.getDelta().treeCopyNoTransform());
}
unit.setProductLine(productline.treeCopyNoTransform());
unit.addProductDecl(product.treeCopyNoTransform());
Model copy = model.treeCopyNoTransform();
copy.addCompilationUnit(unit);
validateOutput(copy.treeCopyNoTransform(), null);
validateOutput(copy.treeCopyNoTransform(), module.getName().concat(".").concat(PRODUCT_NAME));
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class JavaJob method findModulesWithMain.
/**
* searches a compilation unit for modules with a main block
* @param unit
* @return a list of all modules which have a main block
*/
private List<ModuleDecl> findModulesWithMain(CompilationUnit unit) {
List<ModuleDecl> result = new LinkedList<ModuleDecl>();
if (unit != null) {
int countModules = unit.getNumModuleDecl();
int i = 0;
while (i < countModules) {
ModuleDecl module = unit.getModuleDecl(i);
if (module.hasBlock()) {
result.add(module);
}
// go to next module
i++;
}
}
return result;
}
Aggregations