Search in sources :

Example 16 with TestContext

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());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 17 with TestContext

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());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 18 with TestContext

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));
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 19 with TestContext

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());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 20 with TestContext

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));
    }
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Aggregations

TestContext (helper.Utils.TestContext)45 Context (claw.tatsu.common.Context)44 Test (org.junit.Test)43 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)22 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)20 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)9 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)4 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)2 XcodeML (claw.tatsu.xcodeml.xnode.common.XcodeML)2 TestConfiguration (helper.Utils.TestConfiguration)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 AnalyzedPragma (claw.shenron.translator.AnalyzedPragma)1 OpenAccConfiguration (claw.tatsu.directive.configuration.OpenAccConfiguration)1 OpenAcc (claw.tatsu.directive.generator.OpenAcc)1 FunctionCall (claw.tatsu.xcodeml.abstraction.FunctionCall)1 HoistedNestedDoStatement (claw.tatsu.xcodeml.abstraction.HoistedNestedDoStatement)1 FfunctionType (claw.tatsu.xcodeml.xnode.fortran.FfunctionType)1 FmoduleDefinition (claw.tatsu.xcodeml.xnode.fortran.FmoduleDefinition)1 Before (org.junit.Before)1