summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-12-01 15:00:29 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-12-02 09:15:04 +0100
commit69d6a508d3d5f99ef706f5d73a5533681ef64096 (patch)
tree857f6ebcd8d7024d1e0ea0ebf938e92e1f700860 /tests
parent855e4eac4ff9ef779a715c49d972bb6b4f8098fe (diff)
downloadqt-creator-69d6a508d3d5f99ef706f5d73a5533681ef64096.tar.gz
QmlJS indenter: Fix braceless switch/try/with bindings.
Change-Id: Iee25f3f9ec38b1b7fc2697f390386c9a60cb8347 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp122
1 files changed, 107 insertions, 15 deletions
diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
index c3a0b35e0d..46c7b0ae68 100644
--- a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
+++ b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
@@ -61,6 +61,11 @@ private Q_SLOTS:
void ifBinding1();
void ifBinding2();
void ifBinding3();
+ void withBinding();
+ void tryBinding1();
+ void tryBinding2();
+ void tryBinding3();
+ void switchBinding();
void ifStatementWithoutBraces1();
void ifStatementWithoutBraces2();
void ifStatementWithoutBraces3();
@@ -98,7 +103,6 @@ private Q_SLOTS:
void labelledStatements3();
void json1();
void multilineTernaryInProperty();
- void bug1();
void multilineString();
void bug1();
};
@@ -538,6 +542,108 @@ void tst_QMLCodeFormatter::ifBinding3()
checkIndent(data);
}
+void tst_QMLCodeFormatter::withBinding()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" foo: with(pos) { x }")
+ << Line(" foo: with(pos) {")
+ << Line(" x")
+ << Line(" }")
+ << Line(" foo: 12")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
+void tst_QMLCodeFormatter::tryBinding1()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" foo: try { x } finally { y }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" } finally {")
+ << Line(" y")
+ << Line(" }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" }")
+ << Line(" finally {")
+ << Line(" y")
+ << Line(" }")
+ << Line(" foo: 12")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
+void tst_QMLCodeFormatter::tryBinding2()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" foo: try { x } catch (x) { y }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" } catch (e) {")
+ << Line(" e")
+ << Line(" }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" }")
+ << Line(" catch (e) {")
+ << Line(" e")
+ << Line(" }")
+ << Line(" foo: 12")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
+void tst_QMLCodeFormatter::tryBinding3()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" foo: try { x } catch (x) { y } finally { z }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" } catch (e) {")
+ << Line(" e")
+ << Line(" } finally {")
+ << Line(" z")
+ << Line(" }")
+ << Line(" foo: try {")
+ << Line(" x")
+ << Line(" }")
+ << Line(" catch (e) {")
+ << Line(" e")
+ << Line(" }")
+ << Line(" finally {")
+ << Line(" z")
+ << Line(" }")
+ << Line(" foo: 12")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
+void tst_QMLCodeFormatter::switchBinding()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" foo: switch (a) {")
+ << Line(" case 1:")
+ << Line(" x; break")
+ << Line(" case 2:")
+ << Line(" case 3:")
+ << Line(" return y")
+ << Line(" }")
+ << Line(" foo: 12")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
void tst_QMLCodeFormatter::ifStatementWithoutBraces1()
{
QList<Line> data;
@@ -1301,20 +1407,6 @@ void tst_QMLCodeFormatter::multilineTernaryInProperty()
checkIndent(data);
}
-void tst_QMLCodeFormatter::bug1()
-{
- QList<Line> data;
- data << Line("Item {")
- << Line(" x: {")
- << Line(" if (a==a) {}")
- << Line(" else (b==b) {}")
- << Line(" foo()")
- << Line(" }")
- << Line("}")
- ;
- checkIndent(data);
-}
-
void tst_QMLCodeFormatter::multilineString()
{
QList<Line> data;