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
7f83755f
Commit
7f83755f
authored
Dec 15, 2008
by
Roberto Raggi
Browse files
Test the `for' statement.
parent
b043d1d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/auto/cplusplus/ast/tst_ast.cpp
View file @
7f83755f
...
...
@@ -33,6 +33,7 @@ private slots:
void
if_else_statement
();
void
while_statement
();
void
while_condition_statement
();
void
for_statement
();
void
cpp_initializer_or_function_declaration
();
};
...
...
@@ -170,6 +171,30 @@ void tst_AST::while_condition_statement()
QCOMPARE
(
body_stmt
->
rbrace_token
,
9U
);
}
void
tst_AST
::
for_statement
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseStatement
(
"for (;;) {}"
));
AST
*
ast
=
unit
->
ast
();
QVERIFY
(
ast
!=
0
);
ForStatementAST
*
stmt
=
ast
->
asForStatement
();
QVERIFY
(
stmt
!=
0
);
QCOMPARE
(
stmt
->
for_token
,
1U
);
QCOMPARE
(
stmt
->
lparen_token
,
2U
);
QVERIFY
(
stmt
->
initializer
!=
0
);
QVERIFY
(
stmt
->
initializer
->
asExpressionStatement
()
!=
0
);
QCOMPARE
(
stmt
->
initializer
->
asExpressionStatement
()
->
semicolon_token
,
3U
);
QVERIFY
(
stmt
->
condition
==
0
);
QCOMPARE
(
stmt
->
semicolon_token
,
4U
);
QVERIFY
(
stmt
->
expression
==
0
);
QCOMPARE
(
stmt
->
rparen_token
,
5U
);
QVERIFY
(
stmt
->
statement
!=
0
);
QVERIFY
(
stmt
->
statement
->
asCompoundStatement
()
!=
0
);
QCOMPARE
(
stmt
->
statement
->
asCompoundStatement
()
->
lbrace_token
,
6U
);
QVERIFY
(
stmt
->
statement
->
asCompoundStatement
()
->
statements
==
0
);
QCOMPARE
(
stmt
->
statement
->
asCompoundStatement
()
->
rbrace_token
,
7U
);
}
void
tst_AST
::
cpp_initializer_or_function_declaration
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseStatement
(
"QFileInfo fileInfo(foo);"
));
...
...
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