#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"
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 DCAST | ( | VAR_NAME, | |||
CAST_TYPE, | |||||
EXPR | ) |
Value:
CAST_TYPE VAR_NAME = dynamic_cast<CAST_TYPE>(EXPR); \ CPPUNIT_ASSERT(VAR_NAME != NULL)
Definition at line 54 of file CParserTest.cpp.
Referenced by CParserTest::testAddNameAndTypeArray(), CParserTest::testAddNameAndTypeComposition(), CParserTest::testAddNameAndTypeEnum(), CParserTest::testAddNameAndTypeFunction(), CParserTest::testAddNameAndTypePointer(), CParserTest::testAddNameAndTypeStructUnion(), CParserTest::testTypeExpr(), and CParserTest::testTypeInitializer().
#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().
CPPUNIT_TEST_SUITE_REGISTRATION | ( | CParserTest | ) |