summaryrefslogtreecommitdiff
path: root/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2019-11-29 18:08:07 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2019-12-04 12:17:34 +0000
commitdb73deb3bdede559bb7639bf3d0a07a32a17c6d8 (patch)
treece68307cb3f43578e9713976712412d603079d5e /test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js
parent6b0c42c63c2492bd0a7a96d3179d122b5f71793f (diff)
downloadqtdeclarative-testsuites-db73deb3bdede559bb7639bf3d0a07a32a17c6d8.tar.gz
test/language/expressions: Add nullish coalescing tests
Copies a few tests for nullish coalescing straight from the newest test262 master branch so that we can test https://codereview.qt-project.org/c/qt/qtdeclarative/+/283241 . Change-Id: I312e96c1e2934d2933421371d58bfce670f244ae Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js')
-rw-r--r--test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js b/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js
new file mode 100644
index 000000000..178789553
--- /dev/null
+++ b/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-and.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ CoalesceExpression is chainable with the LogicalANDExpression is any is covered.
+esid: sec-conditional-operator
+info: |
+ ConditionalExpression :
+ ShortCircuitExpression
+ ShortCircuitExpression ? AssignmentExpression : AssignmentExpression
+
+ ShortCircuitExpression :
+ LogicalORExpression
+ CoalesceExpression
+
+ CoalesceExpression :
+ CoalesceExpressionHead ?? BitwiseORExpression
+
+ CoalesceExpressionHead :
+ CoalesceExpression
+ BitwiseORExpression
+
+ Runtime Semantics: Evaluation
+
+ CoalesceExpression:CoalesceExpressionHead??BitwiseORExpression
+
+ 1. Let lref be the result of evaluating CoalesceExpressionHead.
+ 2. Let lval be ? GetValue(lref).
+ 3. If lval is undefined or null,
+ a. Let rref be the result of evaluating BitwiseORExpression.
+ b. Return ? GetValue(rref).
+ 4. Otherwise, return lval.
+features: [coalesce-expression]
+---*/
+
+var x;
+
+x = undefined;
+x = (null ?? 41) && 42;
+assert.sameValue(x, 42, '(null ?? 41) && 42');
+
+x = undefined;
+x = null ?? (41 && 42);
+assert.sameValue(x, 42, 'null ?? (41 && 42)`');
+
+x = undefined;
+x = (41 && 42) ?? null;
+assert.sameValue(x, 42, '(41 && 42) ?? null');
+
+x = undefined;
+x = 41 && (null ?? 42);
+assert.sameValue(x, 42, '41 && (null ?? 42)`');