Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv1782/src/rftaparser
Modified Files:
CPPParserTest.cpp CPPParserTest.h
DeclarationListParserTest.cpp DeclarationListParserTest.h
UnparsedDeclarationMutatorTest.cpp
UnparsedDeclarationMutatorTest.h
Log Message:
* added test for unnamed enum & enum body parsing bug.
Index: CPPParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/CPPParserTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CPPParserTest.cpp 29 Apr 2003 22:04:28 -0000 1.1
--- CPPParserTest.cpp 3 May 2003 17:43:12 -0000 1.2
***************
*** 108,110 ****
--- 108,122 ----
+ void
+ CPPParserTest::testParseAllEnumDeclaration()
+ {
+ const std::string source(
+ "enum X {\n"
+ " FirstID = 7000\n"
+ "};" );
+
+ CPPParser parser( source );
+ parser.parseAll();
+ }
+
} // namespace Refactoring
Index: CPPParserTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/CPPParserTest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CPPParserTest.h 29 Apr 2003 22:04:29 -0000 1.1
--- CPPParserTest.h 3 May 2003 17:43:12 -0000 1.2
***************
*** 22,25 ****
--- 22,26 ----
CPPUNIT_TEST( testParseFunctionInNestedNamespace );
CPPUNIT_TEST( testParseFunctionInClassDeclaration );
+ CPPUNIT_TEST( testParseAllEnumDeclaration );
CPPUNIT_TEST_SUITE_END();
***************
*** 39,42 ****
--- 40,45 ----
void testParseFunctionInNestedNamespace();
void testParseFunctionInClassDeclaration();
+
+ void testParseAllEnumDeclaration();
private:
Index: DeclarationListParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationListParserTest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DeclarationListParserTest.cpp 15 Apr 2003 19:05:16 -0000 1.3
--- DeclarationListParserTest.cpp 3 May 2003 17:43:12 -0000 1.4
***************
*** 9,12 ****
--- 9,13 ----
#include <rfta/parser/ASTNodes.h>
#include <rfta/parser/DeclarationListParser.h>
+ #include "KeyedString.h"
***************
*** 66,69 ****
--- 67,90 ----
endIndex+1,
6 );
+ }
+
+
+ void
+ DeclarationListParserTest::testUnamedEnumDeclaration()
+ {
+ const std::string source(
+ " enum { a, b, c = 3 }; " );
+ int startIndex = 2;
+ int endIndex = source.length()-1;
+
+ SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationListParser,
+ source,
+ source.length() );
+ RFTA_ASSERT_EQUAL( 1, sourceAST->getChildCount() );
+ RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
+ ASTNodeTypes::unparsedDeclaration,
+ startIndex,
+ endIndex-startIndex );
+
}
Index: DeclarationListParserTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationListParserTest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DeclarationListParserTest.h 12 Apr 2003 19:08:40 -0000 1.1
--- DeclarationListParserTest.h 3 May 2003 17:43:12 -0000 1.2
***************
*** 19,22 ****
--- 19,23 ----
CPPUNIT_TEST_SUITE( DeclarationListParserTest );
CPPUNIT_TEST( testTemplateFuntionFollowedByDecl );
+ CPPUNIT_TEST( testUnamedEnumDeclaration );
CPPUNIT_TEST_SUITE_END();
***************
*** 33,36 ****
--- 34,38 ----
void testTemplateFuntionFollowedByDecl();
+ void testUnamedEnumDeclaration();
private:
Index: UnparsedDeclarationMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** UnparsedDeclarationMutatorTest.cpp 1 May 2003 21:54:40 -0000 1.8
--- UnparsedDeclarationMutatorTest.cpp 3 May 2003 17:43:12 -0000 1.9
***************
*** 285,290 ****
--- 285,312 ----
ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty );
RFTA_ASSERT_NODE_TYPE( specifierList->getChildAt(0), ASTNodeTypes::enumSpecifier );
+ }
+
+
+ void
+ UnparsedDeclarationMutatorTest::testUnamedEnumDeclaration()
+ {
+ Testing::KeyedString source;
+ source.addKeyed(SPECIFIER , "enum { a = 0, b, c }" ) << ";";
+
+ SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source );
+ ASTNodePtr node = sourceAST->getChildAt(0);
+ // check AST:
+ RFTA_ASSERT_DECLARATION( source, sourceAST );
+
+ // check specifier types:
+ ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty );
+ ASTNodePtr enumSpecifier = specifierList->getChildAt(0);
+ RFTA_ASSERT_NODE_TYPE( enumSpecifier, ASTNodeTypes::enumSpecifier );
+ RFTA_ASSERT_NODE_HAS( enumSpecifier, ASTNodeTypes::enumSpecifier,
+ source.getKeyedIndex(SPECIFIER,0),
+ source.getKeyedLen(SPECIFIER,0) );
}
+
void
Index: UnparsedDeclarationMutatorTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** UnparsedDeclarationMutatorTest.h 1 May 2003 21:54:40 -0000 1.5
--- UnparsedDeclarationMutatorTest.h 3 May 2003 17:43:13 -0000 1.6
***************
*** 25,28 ****
--- 25,29 ----
CPPUNIT_TEST( testClassForwardDeclaration );
CPPUNIT_TEST( testEnumDeclaration );
+ CPPUNIT_TEST( testUnamedEnumDeclaration );
CPPUNIT_TEST( testPointerDecl );
CPPUNIT_TEST( testFctPointer );
***************
*** 69,72 ****
--- 70,74 ----
void testClassForwardDeclaration();
void testEnumDeclaration();
+ void testUnamedEnumDeclaration();
void testPointerDecl();
void testFctPointer();
|