diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2019-11-29 18:08:07 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2019-12-04 12:17:34 +0000 |
commit | db73deb3bdede559bb7639bf3d0a07a32a17c6d8 (patch) | |
tree | ce68307cb3f43578e9713976712412d603079d5e /test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-or.js | |
parent | 6b0c42c63c2492bd0a7a96d3179d122b5f71793f (diff) | |
download | qtdeclarative-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-or.js')
-rw-r--r-- | test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-or.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-or.js b/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-or.js new file mode 100644 index 000000000..240613205 --- /dev/null +++ b/test/language/expressions/coalesce/chainable-if-parenthesis-covered-logical-or.js @@ -0,0 +1,61 @@ +// 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 LogicalORExpression 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 ?? 42) || 43; +assert.sameValue(x, 42, '(null ?? 42) || 43'); + +x = undefined; +x = null ?? (42 || 43); +assert.sameValue(x, 42, 'null ?? (42 || 43)`'); + +x = undefined; +x = (null || 42) ?? 43; +assert.sameValue(x, 42, '(null || 42) ?? 43'); + +x = undefined; +x = null || (42 ?? 43); +assert.sameValue(x, 42, 'null || (42 ?? 43)`'); + +x = undefined; +x = (42 || 43) ?? null; +assert.sameValue(x, 42, '(42 || 43) ?? null'); + +x = undefined; +x = 42 || (null ?? 43); +assert.sameValue(x, 42, '42 || (null ?? 43)'); |