use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class XnodeTest method isConstantTest.
@Test
public void isConstantTest() {
Context context = new TestContext();
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
Xnode n1 = xcodeml.createNode(Xcode.F_BASIC_TYPE);
Xnode n2 = xcodeml.createNode(Xcode.F_REAL_CONSTANT);
Xnode n3 = xcodeml.createNode(Xcode.F_INT_CONSTANT);
Xnode n4 = xcodeml.createNode(Xcode.F_COMPLEX_CONSTANT);
Xnode n5 = xcodeml.createNode(Xcode.F_LOGICAL_CONSTANT);
Xnode n6 = xcodeml.createNode(Xcode.F_CHARACTER_CONSTANT);
assertFalse(n1.isConstant());
assertTrue(n2.isConstant());
assertTrue(n3.isConstant());
assertTrue(n4.isConstant());
assertTrue(n5.isConstant());
assertTrue(n6.isConstant());
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class XnodeTest method enhancedInfoTest.
@Test
public void enhancedInfoTest() {
Context context = new TestContext();
String filename = "dummy.f90";
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
Xnode n1 = xcodeml.createNode(Xcode.VAR_DECL);
n1.setLine(1);
n1.setFilename(filename);
assertEquals(1, n1.lineNo());
assertEquals(filename, n1.filename());
Xnode n2 = xcodeml.createNode(Xcode.VAR_DECL);
n1.copyEnhancedInfo(n2);
assertEquals(1, n2.lineNo());
assertEquals(filename, n2.filename());
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class XnodeTest method constructStringTest.
@Test
public void constructStringTest() {
Context context = new TestContext();
Xnode arg1Node = XmlHelper.createXnode(ARG_1);
assertNotNull(arg1Node);
assertEquals("q(:,1:60)", arg1Node.constructRepresentation(false, false));
assertEquals("q", arg1Node.constructRepresentation(false, true));
Xnode arg2Node = XmlHelper.createXnode(ARG_2);
assertNotNull(arg2Node);
assertEquals("p(:,:)", arg2Node.constructRepresentation(false, false));
assertEquals("p", arg2Node.constructRepresentation(false, true));
Xnode arg3Node = XmlHelper.createXnode(ARG_3);
assertNotNull(arg3Node);
assertEquals("ty%y(p,:)", arg3Node.constructRepresentation(false, false));
assertEquals("ty%y", arg3Node.constructRepresentation(false, true));
Xnode arg4Node = XmlHelper.createXnode(ARG_4);
assertNotNull(ARG_4);
assertEquals("nproma=nproma", arg4Node.constructRepresentation(true, false));
assertEquals("nproma", arg4Node.constructRepresentation(false, false));
Xnode arg5Node = XmlHelper.createXnode(ARG_5);
assertNotNull(arg5Node);
assertEquals("first%middle%end", arg5Node.constructRepresentation(false, false));
Xnode arg6Node = XmlHelper.createXnode(ARG_6);
assertNotNull(arg6Node);
assertEquals("first%middle%end(p,:)", arg6Node.constructRepresentation(false, false));
assertEquals("first%middle%end", arg6Node.constructRepresentation(false, true));
Xnode arg7Node = XmlHelper.createXnode(ARG_7);
assertNotNull(arg7Node);
assertEquals("tend(blockid)%t(jl,:)", arg7Node.constructRepresentation(false, false));
Xnode arg8Node = XmlHelper.createXnode(ARG_8);
assertNotNull(arg8Node);
assertEquals("tend(blockid)%t(jl,:,:)", arg8Node.constructRepresentation(false, false));
Xnode arg9Node = XmlHelper.createXnode(ARG_9);
assertNotNull(arg9Node);
assertEquals("q(:)", arg9Node.constructRepresentation(false, false));
Xnode arg10Node = XmlHelper.createXnode(ARG_10);
assertNotNull(arg10Node);
assertEquals("q", arg10Node.constructRepresentation(false, false));
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
Xnode n1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
assertEquals("", n1.constructRepresentation(false, false));
Xnode n2 = xcodeml.createNode(Xcode.F_DO_STATEMENT);
assertEquals("", n2.constructRepresentation(false, false));
assertEquals("", n2.constructRepresentation(false, true));
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class XnodeTest method matchAllAncestorTest.
@Test
public void matchAllAncestorTest() {
Context context = new TestContext();
XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_ASSIGN_STMT2, context);
assertNotNull(xcodeml);
List<Xnode> nodes = xcodeml.matchAll(Xcode.F_ASSIGN_STATEMENT);
assertEquals(4, nodes.size());
List<Xnode> matches1 = nodes.get(0).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
List<Xnode> matches2 = nodes.get(0).matchAllAncestor(Xcode.F_IF_STATEMENT);
assertEquals(2, matches1.size());
assertEquals(2, matches2.size());
matches1 = nodes.get(1).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
matches2 = nodes.get(1).matchAllAncestor(Xcode.F_IF_STATEMENT);
assertEquals(2, matches1.size());
assertEquals(2, matches2.size());
matches1 = nodes.get(3).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
matches2 = nodes.get(3).matchAllAncestor(Xcode.F_IF_STATEMENT);
assertEquals(0, matches1.size());
assertEquals(0, matches2.size());
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class FfunctionDefinitionTest method findContainingXmodTest.
@Test
public void findContainingXmodTest() {
Context context = new TestContext();
context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
assertTrue(Files.exists(TestConstant.TEST_DECLARATIONS));
XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_DECLARATIONS, context);
assertNotNull(xcodeml);
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
for (FfunctionDefinition fctDef : fctDefs) {
// Search paths is not set so module cannot be found.
assertNull(fctDef.findContainingXmod(context));
}
}
Aggregations