Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
61622796
Commit
61622796
authored
15 years ago
by
Erik Verbruggen
Browse files
Options
Downloads
Patches
Plain Diff
Added test for selector names.
parent
ee16a1e8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/auto/cplusplus/semantic/tst_semantic.cpp
+80
-0
80 additions, 0 deletions
tests/auto/cplusplus/semantic/tst_semantic.cpp
with
80 additions
and
0 deletions
tests/auto/cplusplus/semantic/tst_semantic.cpp
+
80
−
0
View file @
61622796
...
...
@@ -7,6 +7,7 @@
#include
<Control.h>
#include
<Parser.h>
#include
<AST.h>
#include
<ASTVisitor.h>
#include
<Semantic.h>
#include
<Scope.h>
#include
<Symbols.h>
...
...
@@ -17,6 +18,7 @@
#include
<GenTemplateInstance.h>
#include
<Overview.h>
#include
<ExpressionUnderCursor.h>
#include
<Names.h>
using
namespace
CPlusPlus
;
...
...
@@ -130,6 +132,8 @@ private slots:
void
bracketed_expression_under_cursor_8
();
void
objcClass_1
();
void
objcSelector_1
();
void
objcSelector_2
();
void
q_enum_1
();
};
...
...
@@ -625,6 +629,82 @@ void tst_Semantic::objcClass_1()
QVERIFY
(
!
deallocMethod
->
isStatic
());
}
void
tst_Semantic
::
objcSelector_1
()
{
QSharedPointer
<
Document
>
doc
=
document
(
"
\n
"
"@interface A {}
\n
"
"-(void)a:(int)a b:(int)b c:(int)c;
\n
"
"@end
\n
"
,
true
);
QCOMPARE
(
doc
->
errorCount
,
0U
);
QCOMPARE
(
doc
->
globals
->
symbolCount
(),
1U
);
ObjCClass
*
iface
=
doc
->
globals
->
symbolAt
(
0
)
->
asObjCClass
();
QVERIFY
(
iface
);
QVERIFY
(
iface
->
isInterface
());
QCOMPARE
(
iface
->
memberCount
(),
1U
);
Declaration
*
decl
=
iface
->
memberAt
(
0
)
->
asDeclaration
();
QVERIFY
(
decl
);
QVERIFY
(
decl
->
name
());
const
SelectorNameId
*
selId
=
decl
->
name
()
->
asSelectorNameId
();
QVERIFY
(
selId
);
QCOMPARE
(
selId
->
nameCount
(),
3U
);
QCOMPARE
(
selId
->
nameAt
(
0
)
->
identifier
()
->
chars
(),
"a"
);
QCOMPARE
(
selId
->
nameAt
(
1
)
->
identifier
()
->
chars
(),
"b"
);
QCOMPARE
(
selId
->
nameAt
(
2
)
->
identifier
()
->
chars
(),
"c"
);
}
class
CollectSelectors
:
public
ASTVisitor
{
public:
CollectSelectors
(
TranslationUnit
*
xUnit
)
:
ASTVisitor
(
xUnit
)
{}
QList
<
ObjCSelectorAST
*>
operator
()()
{
selectors
.
clear
();
accept
(
translationUnit
()
->
ast
());
return
selectors
;
}
virtual
bool
visit
(
ObjCSelectorWithArgumentsAST
*
ast
)
{
selectors
.
append
(
ast
);
return
false
;}
virtual
bool
visit
(
ObjCSelectorWithoutArgumentsAST
*
ast
)
{
selectors
.
append
(
ast
);
return
false
;}
private
:
QList
<
ObjCSelectorAST
*>
selectors
;
};
void
tst_Semantic
::
objcSelector_2
()
{
QSharedPointer
<
Document
>
doc
=
document
(
"
\n
"
"@implementation A {}
\n
"
"-(SEL)x {
\n
"
" return @selector(a:b:c:);
\n
"
"}
\n
"
"@end
\n
"
,
true
);
QCOMPARE
(
doc
->
errorCount
,
0U
);
QCOMPARE
(
doc
->
globals
->
symbolCount
(),
1U
);
ObjCClass
*
iface
=
doc
->
globals
->
symbolAt
(
0
)
->
asObjCClass
();
QVERIFY
(
iface
);
QCOMPARE
(
iface
->
memberCount
(),
1U
);
QList
<
ObjCSelectorAST
*>
selectors
=
CollectSelectors
(
doc
->
unit
)();
QCOMPARE
(
selectors
.
size
(),
2
);
ObjCSelectorWithArgumentsAST
*
sel
=
selectors
.
at
(
1
)
->
asObjCSelectorWithArguments
();
QVERIFY
(
sel
);
const
SelectorNameId
*
selId
=
sel
->
selector_name
->
asSelectorNameId
();
QVERIFY
(
selId
);
QCOMPARE
(
selId
->
nameCount
(),
3U
);
QCOMPARE
(
selId
->
nameAt
(
0
)
->
identifier
()
->
chars
(),
"a"
);
QCOMPARE
(
selId
->
nameAt
(
1
)
->
identifier
()
->
chars
(),
"b"
);
QCOMPARE
(
selId
->
nameAt
(
2
)
->
identifier
()
->
chars
(),
"c"
);
}
void
tst_Semantic
::
q_enum_1
()
{
QSharedPointer
<
Document
>
doc
=
document
(
"
\n
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment