diff options
author | Moonchild <moonchild@palemoon.org> | 2022-05-04 10:42:06 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-05-04 10:42:06 +0000 |
commit | 92b3def6a88f9ea15c9e51e22a57b667edea29c0 (patch) | |
tree | c7c0f507b8db88ef5b93b2e0e71d4481bec28a49 /js/src/tests/test262/language/optional-chaining/short-circuiting.js | |
parent | 0de24cc207b9fbb198d2eaf34e5bae21089d20bd (diff) | |
parent | 006b8f5c6e23a0bfb38d10c0f7c95b610b79c49d (diff) | |
download | uxp-92b3def6a88f9ea15c9e51e22a57b667edea29c0.tar.gz |
Merge pull request 'Implement optional chaining' (#1889) from FranklinDM/UXP-contrib:work_js-optional-chaining into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1889
Diffstat (limited to 'js/src/tests/test262/language/optional-chaining/short-circuiting.js')
-rw-r--r-- | js/src/tests/test262/language/optional-chaining/short-circuiting.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/optional-chaining/short-circuiting.js b/js/src/tests/test262/language/optional-chaining/short-circuiting.js new file mode 100644 index 0000000000..74295cb1ee --- /dev/null +++ b/js/src/tests/test262/language/optional-chaining/short-circuiting.js @@ -0,0 +1,24 @@ +// Copyright 2019 Google, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: prod-OptionalExpression +description: > + demonstrate syntax-based short-circuiting. +info: | + If the expression on the LHS of ?. evaluates to null/undefined, the RHS is + not evaluated +features: [optional-chaining] +---*/ + +const a = undefined; +let x = 1; + +a?.[++x] // short-circuiting. +a?.b.c(++x).d; // long short-circuiting. + +undefined?.[++x] // short-circuiting. +undefined?.b.c(++x).d; // long short-circuiting. + +assert.sameValue(1, x); + +reportCompare(0, 0); |