aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2019-11-29 16:52:16 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2019-12-05 14:28:47 +0100
commit8fadf5d374936e50b8bce5adb1f10da2f66eac2b (patch)
tree9fa8808718e47673413980aa4448fe8d11dde0c7 /tests
parent79166592d17135309a070065e7cb947ffa293828 (diff)
qml/parser: Implement nullish coalescing
Implements the '??' operator as specified in https://github.com/tc39/proposal-nullish-coalescing. Also adds a few tests. Task-number: QTBUG-77926 Change-Id: I3993450c192d11bf1ade0662d945c1553b4c6976 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
m---------tests/auto/qml/ecmascripttests/test2620
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp5
10 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262
-Subproject 6b0c42c63c2492bd0a7a96d3179d122b5f71793
+Subproject db73deb3bdede559bb7639bf3d0a07a32a17c6d
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.errors.txt b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.errors.txt
new file mode 100644
index 0000000000..d4f3eb3ecf
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.errors.txt
@@ -0,0 +1 @@
+6:29:Left-hand side may not contain || or &&
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml
new file mode 100644
index 0000000000..ce6aa9a532
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+Component {
+ Component.onCompleted: {
+ // Should cause an error since having either || or && on any side of the coalescing operator is banned by the specification
+ var bad_lhs_and = 3 && 4 ?? 0;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.errors.txt b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.errors.txt
new file mode 100644
index 0000000000..f2f1719acd
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.errors.txt
@@ -0,0 +1 @@
+6:28:Left-hand side may not contain || or &&
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.qml b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.qml
new file mode 100644
index 0000000000..8864524d0d
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+Component {
+ Component.onCompleted: {
+ // Should cause an error since having either || or && on any side of the coalescing operator is banned by the specification
+ var bad_lhs_or = 3 || 4 ?? 0;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.errors.txt b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.errors.txt
new file mode 100644
index 0000000000..0ff61be687
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.errors.txt
@@ -0,0 +1 @@
+6:34:Right-hand side may not contain || or &&
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.qml b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.qml
new file mode 100644
index 0000000000..97898f055a
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+Component {
+ Component.onCompleted: {
+ // Should cause an error since having either || or && on any side of the coalescing operator is banned by the specification
+ var bad_rhs_and = 0 ?? 3 && 4;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.errors.txt b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.errors.txt
new file mode 100644
index 0000000000..4b2784ac0a
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.errors.txt
@@ -0,0 +1 @@
+6:33:Right-hand side may not contain || or &&
diff --git a/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml
new file mode 100644
index 0000000000..f172755e91
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+Component {
+ Component.onCompleted: {
+ // Should cause an error since having either || or && on any side of the coalescing operator is banned by the specification
+ var bad_rhs_or = 0 ?? 3 || 4;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 7fff982cde..c36e707ff8 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -477,6 +477,11 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+ QTest::newRow("nullishCoalescing_LHS_Or") << "nullishCoalescing_LHS_Or.qml" << "nullishCoalescing_LHS_Or.errors.txt" << false;
+ QTest::newRow("nullishCoalescing_LHS_And") << "nullishCoalescing_LHS_And.qml" << "nullishCoalescing_LHS_And.errors.txt" << false;
+ QTest::newRow("nullishCoalescing_RHS_Or") << "nullishCoalescing_RHS_Or.qml" << "nullishCoalescing_RHS_Or.errors.txt" << false;
+ QTest::newRow("nullishCoalescing_RHS_And") << "nullishCoalescing_RHS_And.qml" << "nullishCoalescing_RHS_And.errors.txt" << false;
+
QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;