aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-07-30 17:34:36 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-07-31 08:15:18 +0000
commit3f9427200bae1a84097b221839988d4d6c886fe7 (patch)
tree1836f64cd2460b1637f7ec49278d325649d7416a /tests/auto
parent537e2e23ff7fd1e9854d6ff8bdab44dcc0640e5a (diff)
CppTools: Fix formatting for lambdas with trailing return type
After the arrow, the state is still the same, as now a type is expected. Only after the opening brace does the actual function start. Fixes: QTCREATORBUG-18497 Change-Id: I7bf18fbd6907d36f8869af3a78ad617cf0ee9dbb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
index 0657e58786..a4887b8677 100644
--- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
+++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
@@ -127,6 +127,7 @@ private Q_SLOTS:
void strings();
void initializerWithinFunctionArg();
void shiftWithinInitializer();
+ void lambdaWithReturnType();
};
struct Line {
@@ -2196,6 +2197,18 @@ void tst_CodeFormatter::shiftWithinInitializer()
checkIndent(data);
}
+void tst_CodeFormatter::lambdaWithReturnType()
+{
+ QList<Line> data;
+ data << Line("int main() {")
+ << Line(" hello([]() -> void {")
+ << Line(" cout << \"world\";") // OK, same indentation/padding as above.
+ << Line(" });")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
QTEST_MAIN(tst_CodeFormatter)
#include "tst_codeformatter.moc"