use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.
the class XnodeTest method hasBodyTest.
@Test
public void hasBodyTest() {
Context context = new TestContext();
List<Xcode> expectedNodeWithBody = new ArrayList<>(Arrays.asList(Xcode.ASSOCIATE_STATEMENT, Xcode.BLOCK_STATEMENT, Xcode.CRITICAL_STATEMENT, Xcode.ELSE, Xcode.F_CASE_LABEL, Xcode.F_DO_CONCURRENT_STATEMENT, Xcode.F_DO_STATEMENT, Xcode.F_DO_WHILE_STATEMENT, Xcode.F_FUNCTION_DEFINITION, Xcode.FOR_ALL_STATEMENT, Xcode.THEN, Xcode.TYPE_GUARD));
for (Xcode x : expectedNodeWithBody) {
assertTrue(x.hasBody());
}
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
for (Xcode opcode : Xcode.values()) {
Xnode n = xcodeml.createNode(opcode);
if (expectedNodeWithBody.contains(n.opcode())) {
assertTrue(n.opcode().hasBody());
assertTrue(n.hasBody());
} else {
assertFalse(n.opcode().hasBody());
assertFalse(n.hasBody());
}
}
}
use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.
the class XnodeTest method deletedTest.
@Test
public void deletedTest() {
Context context = new TestContext();
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
Xnode n1 = xcodeml.createNode(Xcode.F_BASIC_TYPE);
assertFalse(n1.isDeleted());
n1.delete();
assertTrue(n1.isDeleted());
}
use of claw.tatsu.common.Context 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 claw.tatsu.common.Context 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 claw.tatsu.common.Context 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));
}
Aggregations