ctrump/parser/unit-test/CParserTest.cpp File Reference

#include "CParserTest.hpp"
#include "../CParser.hpp"
#include <iostream>
#include <string>
#include <sstream>
#include "../Type.hpp"
#include "../BasicType.hpp"
#include "../PointerType.hpp"
#include "../FunctionType.hpp"
#include "../ArrayType.hpp"
#include "TestUtil.hpp"

Include dependency graph for CParserTest.cpp:

Go to the source code of this file.

Defines

#define DCAST(VAR_NAME, CAST_TYPE, EXPR)
#define PREPARE_BASIC(NAME_POSTFIX, DECL_STR)
#define PREPARE(NAME_POSTFIX, DECL_STR, VAR_NAME_STR)
#define TEST_BASIC_TYPE(NAME_POSTFIX, DECL_STR, VAR_NAME_STR, BASIC_TYPE, QUAL_FLAGS)
#define PREP_RET_PARAM(DECL_STR, VAR_NAME_STR, RET_TYPE)
#define PREPARE_TAG(NAME_POSTFIX, DECL_STR, VAR_NAME_STR)
#define LOOKUP_NAME(NAME_POSTFIX, ENV, NAME_STR)
#define IS_ENUM_CONST_TYPE(TYP)
#define PREPARE_EXPR(NAME_POSTFIX, EXPR_STR)
#define NEXT_EXPR(snode, enode)
#define PREPARE_INITER(NAME_POSTFIX, EXPR_STR)

Functions

 CPPUNIT_TEST_SUITE_REGISTRATION (CParserTest)


Define Documentation

#define DCAST ( VAR_NAME,
CAST_TYPE,
EXPR   ) 

#define IS_ENUM_CONST_TYPE ( TYP   ) 

Value:

DCAST(b##TYP, const BasicType*, TYP);                           \
    CPPUNIT_ASSERT(b##TYP->getPrimitiveTag() == BasicType::SINT)

Referenced by CParserTest::testAddNameAndTypeEnum().

#define LOOKUP_NAME ( NAME_POSTFIX,
ENV,
NAME_STR   ) 

Value:

NameDescription* nd##NAME_POSTFIX = NULL;                           \
    Environment* foundEnv##NAME_POSTFIX = ENV->lookupOrdinaryName(NAME_STR, &nd##NAME_POSTFIX); \
    CPPUNIT_ASSERT(foundEnv##NAME_POSTFIX != NULL);                     \
    Type* t##NAME_POSTFIX = nd##NAME_POSTFIX->getType()

Referenced by CParserTest::testAddNameAndTypeEnum().

#define NEXT_EXPR ( snode,
enode   ) 

Value:

do {                                                         \
        for (; snode != NULL; snode = snode->getNextSibling()) { \
            if (snode->getType() == CTokenTypes::NExpression) {  \
                enode = snode->getFirstChild();                  \
                break;                                           \
            }                                                    \
        }                                                        \
        CPPUNIT_ASSERT(snode != NULL);                           \
        snode = snode->getNextSibling();                         \
    } while (0)

Referenced by CParserTest::testTypeExpr().

#define PREP_RET_PARAM ( DECL_STR,
VAR_NAME_STR,
RET_TYPE   ) 

Value:

PREPARE(f, DECL_STR, VAR_NAME_STR);                                 \
    DCAST(ff, FunctionType*, typef);                                    \
    DCAST(r, RET_TYPE, ff->getReturnType());                            \
    const ParameterTypes& pts = ff->getParameterTypes();                \
    ParameterTypes::const_iterator i = pts.begin()

Referenced by CParserTest::testAddNameAndTypeFunction().

#define PREPARE ( NAME_POSTFIX,
DECL_STR,
VAR_NAME_STR   ) 

Value:

PREPARE_BASIC(NAME_POSTFIX, DECL_STR);                              \
    parser##NAME_POSTFIX.declaration(NameDescription::TOPLEVEL);        \
    NameDescription* nd##NAME_POSTFIX;                                  \
    Environment* foundEnv##NAME_POSTFIX = analyzer##NAME_POSTFIX.getCurrentEnv()->lookupOrdinaryName(VAR_NAME_STR, &nd##NAME_POSTFIX); \
    CPPUNIT_ASSERT(foundEnv##NAME_POSTFIX != NULL);                     \
    Type* type##NAME_POSTFIX = nd##NAME_POSTFIX->getType()

Definition at line 72 of file CParserTest.cpp.

Referenced by CParserTest::testAddNameAndTypeArray(), CParserTest::testAddNameAndTypeComposition(), CParserTest::testAddNameAndTypePointer(), and CParserTest::testAddNameAndTypeStructUnion().

#define PREPARE_BASIC ( NAME_POSTFIX,
DECL_STR   ) 

Value:

std::stringstream sstream##NAME_POSTFIX(DECL_STR);                  \
    cfront::CLexer lexer##NAME_POSTFIX(sstream##NAME_POSTFIX);          \
    cfront::CAnalyzer analyzer##NAME_POSTFIX;                           \
    analyzer##NAME_POSTFIX.initialize();                                \
    analyzer##NAME_POSTFIX.setTargetInfo(makeDefaultTargetInfo());      \
    cfront::CParser parser##NAME_POSTFIX(lexer##NAME_POSTFIX);          \
    antlr::ASTFactory astFactory##NAME_POSTFIX("ValueNode", ValueNode::factory); \
    parser##NAME_POSTFIX.initializeASTFactory(astFactory##NAME_POSTFIX); \
    analyzer##NAME_POSTFIX.setASTFactory(&astFactory##NAME_POSTFIX);    \
    parser##NAME_POSTFIX.setASTFactory(&astFactory##NAME_POSTFIX);      \
    parser##NAME_POSTFIX.setAnalyzer(&analyzer##NAME_POSTFIX);

Definition at line 58 of file CParserTest.cpp.

Referenced by CParserTest::testTypeExpr().

#define PREPARE_EXPR ( NAME_POSTFIX,
EXPR_STR   ) 

Value:

PREPARE_BASIC(NAME_POSTFIX, EXPR_STR);                              \
    parser##NAME_POSTFIX.expression();                                  \
    RefValueNode e##NAME_POSTFIX = RefValueNode(parser##NAME_POSTFIX.getAST()); \
    RefValueNode te##NAME_POSTFIX = analyzer##NAME_POSTFIX.typeExpr(e##NAME_POSTFIX); \
    const Type* t##NAME_POSTFIX = te##NAME_POSTFIX->getValueRef().type

Referenced by CParserTest::testTypeExpr().

#define PREPARE_INITER ( NAME_POSTFIX,
EXPR_STR   ) 

Value:

PREPARE_BASIC(NAME_POSTFIX, EXPR_STR);                              \
    parser##NAME_POSTFIX.declaration(NameDescription::TOPLEVEL);        \
    RefValueNode d##NAME_POSTFIX = RefValueNode(parser##NAME_POSTFIX.getAST()); \
    RefValueNode idl##NAME_POSTFIX = RefValueNode(d##NAME_POSTFIX->getFirstChild()->getNextSibling()); \
    RefValueNode id##NAME_POSTFIX = RefValueNode(idl##NAME_POSTFIX->getFirstChild()); \
    RefValueNode i##NAME_POSTFIX = RefValueNode(id##NAME_POSTFIX->getNextSibling())

Referenced by CParserTest::testTypeInitializer().

#define PREPARE_TAG ( NAME_POSTFIX,
DECL_STR,
VAR_NAME_STR   ) 

Value:

PREPARE_BASIC(NAME_POSTFIX, DECL_STR);                              \
    parser##NAME_POSTFIX.declaration(NameDescription::TOPLEVEL);        \
    Environment* env##NAME_POSTFIX = analyzer##NAME_POSTFIX.getCurrentEnv(); \
    NameDescription* nd##NAME_POSTFIX;                                  \
    Environment* foundEnv##NAME_POSTFIX = env##NAME_POSTFIX->lookupTagName(VAR_NAME_STR, &nd##NAME_POSTFIX); \
    CPPUNIT_ASSERT(foundEnv##NAME_POSTFIX != NULL);                     \
    Type* type##NAME_POSTFIX = nd##NAME_POSTFIX->getType()

Definition at line 467 of file CParserTest.cpp.

Referenced by CParserTest::testAddNameAndTypeEnum(), and CParserTest::testAddNameAndTypeStructUnion().

#define TEST_BASIC_TYPE ( NAME_POSTFIX,
DECL_STR,
VAR_NAME_STR,
BASIC_TYPE,
QUAL_FLAGS   ) 

Value:

PREPARE(NAME_POSTFIX, DECL_STR, VAR_NAME_STR);                      \
    BasicType* bt##NAME_POSTFIX = dynamic_cast<BasicType*>(type##NAME_POSTFIX); \
    CPPUNIT_ASSERT(bt##NAME_POSTFIX != NULL);                           \
    CPPUNIT_ASSERT(bt##NAME_POSTFIX->getPrimitiveTag() == BASIC_TYPE && \
                   bt##NAME_POSTFIX->getQualFlags() == QUAL_FLAGS)

Referenced by CParserTest::testAddNameAndTypeBasic().


Function Documentation

CPPUNIT_TEST_SUITE_REGISTRATION ( CParserTest   ) 


Generated on Tue Mar 31 20:19:25 2009 for ctrump by  doxygen 1.5.6