|
From: <bl...@us...> - 2003-03-08 13:09:55
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv16819
Modified Files:
ReturnStatementParser.cpp rftaparser.dsp
Added Files:
ReturnStatementParserTest.cpp ReturnStatementParserTest.h
Log Message:
* fixed bug in return parser: value node source range included the ';'
--- NEW FILE: ReturnStatementParserTest.cpp ---
// //////////////////////////////////////////////////////////////////////////
// (c)Copyright 2002, Baptiste Lepilleur.
// Created: 2003/03/08
// //////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ReturnStatementParserTest.h"
#include "ReturnStatementParser.h"
#include <rfta/parser/ASTNodes.h>
#include <rfta/parser/ParseContext.h>
namespace Refactoring
{
RFTAPARSER_TEST_SUITE_REGISTRATION( ReturnStatementParserTest );
ReturnStatementParserTest::ReturnStatementParserTest()
{
}
ReturnStatementParserTest::~ReturnStatementParserTest()
{
}
void
ReturnStatementParserTest::setUp()
{
}
void
ReturnStatementParserTest::tearDown()
{
}
void
ReturnStatementParserTest::testReturnValue()
{
std::string source( "return " );
int valueIndex = source.length();
source += "1234";
int valueEnd = source.length();
source += ";";
int startIndex = 0;
int endIndex = source.length();
SourceASTNodePtr sourceNode = RFTA_ASSERT_KEYWORD_PARSER_PASS(
ReturnStatementParser,
source,
endIndex,
"return" );
RFTA_ASSERT_NODE_HAS( sourceNode->getChildAt(0),
ASTNodeTypes::returnStatement,
startIndex,
endIndex-startIndex );
RFTA_ASSERT_NODE_PROPERTY_HAS( sourceNode->getChildAt(0),
ASTNodeProperties::valueProperty,
ASTNodeTypes::valueExpression,
valueIndex,
valueEnd - valueIndex );
}
} // namespace Refactoring
--- NEW FILE: ReturnStatementParserTest.h ---
// //////////////////////////////////////////////////////////////////////////
// (c)Copyright 2002, Baptiste Lepilleur.
// Created: 2003/03/08
// //////////////////////////////////////////////////////////////////////////
#ifndef RFTA_RETURNSTATEMENTPARSERTEST_H
#define RFTA_RETURNSTATEMENTPARSERTEST_H
#include "ParserTesting.h"
namespace Refactoring
{
/// Unit tests for ReturnStatementParserTest
class ReturnStatementParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( ReturnStatementParserTest );
CPPUNIT_TEST( testReturnValue );
CPPUNIT_TEST_SUITE_END();
public:
/*! Constructs a ReturnStatementParserTest object.
*/
ReturnStatementParserTest();
/// Destructor.
virtual ~ReturnStatementParserTest();
void setUp();
void tearDown();
void testReturnValue();
private:
/// Prevents the use of the copy constructor.
ReturnStatementParserTest( const ReturnStatementParserTest &other );
/// Prevents the use of the copy operator.
void operator =( const ReturnStatementParserTest &other );
private:
};
// Inlines methods for ReturnStatementParserTest:
// ----------------------------------------------
} // namespace Refactoring
#endif // RFTA_RETURNSTATEMENTPARSERTEST_H
Index: ReturnStatementParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ReturnStatementParser.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ReturnStatementParser.cpp 20 Dec 2002 08:30:51 -0000 1.3
--- ReturnStatementParser.cpp 8 Mar 2003 13:09:52 -0000 1.4
***************
*** 38,42 ****
int expressionIndex = getCurrentIndex();
readUntilNext( ';' );
! int expressionLength = getCurrentIndex() - expressionIndex;
ASTNodePtr statement =
--- 38,42 ----
int expressionIndex = getCurrentIndex();
readUntilNext( ';' );
! int expressionLength = getCurrentIndex() - expressionIndex -1;
ASTNodePtr statement =
Index: rftaparser.dsp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** rftaparser.dsp 31 Jan 2003 21:37:03 -0000 1.28
--- rftaparser.dsp 8 Mar 2003 13:09:52 -0000 1.29
***************
*** 761,764 ****
--- 761,772 ----
# Begin Source File
+ SOURCE=.\ReturnStatementParserTest.cpp
+ # End Source File
+ # Begin Source File
+
+ SOURCE=.\ReturnStatementParserTest.h
+ # End Source File
+ # Begin Source File
+
SOURCE=.\RftaParserTest.cpp
|