Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
fc285535
Commit
fc285535
authored
Dec 15, 2008
by
Roberto Raggi
Browse files
Initial work on a test suite for our C++ engine.
parent
dcb96227
Changes
5
Hide whitespace changes
Inline
Side-by-side
tests/auto/cplusplus/ast/ast.pro
0 → 100644
View file @
fc285535
load
(
qttest_p4
)
include
(..
/
shared
/
shared
.
pri
)
QT
=
core
SOURCES
+=
tst_ast
.
cpp
tests/auto/cplusplus/ast/tst_ast.cpp
0 → 100644
View file @
fc285535
#include
<QtTest>
#include
<QtDebug>
#include
<Control.h>
#include
<Parser.h>
#include
<AST.h>
CPLUSPLUS_USE_NAMESPACE
class
tst_AST
:
public
QObject
{
Q_OBJECT
Control
control
;
public:
TranslationUnit
*
parse
(
const
QByteArray
&
source
,
TranslationUnit
::
ParseMode
mode
)
{
StringLiteral
*
fileId
=
control
.
findOrInsertFileName
(
"<stdin>"
);
TranslationUnit
*
unit
=
new
TranslationUnit
(
&
control
,
fileId
);
unit
->
setSource
(
source
.
constData
(),
source
.
length
());
unit
->
parse
(
mode
);
return
unit
;
}
TranslationUnit
*
parseStatement
(
const
QByteArray
&
source
)
{
return
parse
(
source
,
TranslationUnit
::
ParseStatement
);
}
private
slots
:
void
if_statement
();
void
if_else_statement
();
};
void
tst_AST
::
if_statement
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseStatement
(
"if (a) b;"
));
AST
*
ast
=
unit
->
ast
();
QVERIFY
(
ast
!=
0
);
IfStatementAST
*
stmt
=
ast
->
asIfStatement
();
QVERIFY
(
stmt
!=
0
);
QCOMPARE
(
stmt
->
if_token
,
1U
);
QCOMPARE
(
stmt
->
lparen_token
,
2U
);
QVERIFY
(
stmt
->
condition
!=
0
);
QCOMPARE
(
stmt
->
rparen_token
,
4U
);
QVERIFY
(
stmt
->
statement
!=
0
);
QCOMPARE
(
stmt
->
else_token
,
0U
);
QVERIFY
(
stmt
->
else_statement
==
0
);
}
void
tst_AST
::
if_else_statement
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseStatement
(
"if (a) b; else c;"
));
AST
*
ast
=
unit
->
ast
();
QVERIFY
(
ast
!=
0
);
IfStatementAST
*
stmt
=
ast
->
asIfStatement
();
QVERIFY
(
stmt
!=
0
);
QCOMPARE
(
stmt
->
if_token
,
1U
);
QCOMPARE
(
stmt
->
lparen_token
,
2U
);
QVERIFY
(
stmt
->
condition
!=
0
);
QCOMPARE
(
stmt
->
rparen_token
,
4U
);
QVERIFY
(
stmt
->
statement
!=
0
);
QCOMPARE
(
stmt
->
else_token
,
7U
);
QVERIFY
(
stmt
->
else_statement
!=
0
);
}
QTEST_APPLESS_MAIN
(
tst_AST
)
#include
"tst_ast.moc"
tests/auto/cplusplus/cplusplus.pro
0 → 100644
View file @
fc285535
SUBDIRS
=
shared
ast
CONFIG
+=
ordered
tests/auto/cplusplus/shared/shared.pri
0 → 100644
View file @
fc285535
DEFINES += HAVE_QT CPLUSPLUS_WITH_NAMESPACE
INCLUDEPATH += $$PWD/../../../../shared/cplusplus
LIBS += -L$$PWD -lCPlusPlusTestSupport
tests/auto/cplusplus/shared/shared.pro
0 → 100644
View file @
fc285535
TEMPLATE
=
lib
TARGET
=
CPlusPlusTestSupport
CONFIG
+=
static
QT
=
core
DEFINES
+=
HAVE_QT
CPLUSPLUS_WITH_NAMESPACE
include
(
$$
PWD
/../../../../
shared
/
cplusplus
/
cplusplus
.
pri
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment