summaryrefslogtreecommitdiff
path: root/test/language/expressions/optional-chaining/member-expression-async-identifier.js
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-04-09 15:03:20 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-04-13 11:45:16 +0000
commit4dad98d63c279b989fdb48006fbd1db8ee27bc7f (patch)
tree40bc5864e3df0edd9960b8acfdc769ff894a24ba /test/language/expressions/optional-chaining/member-expression-async-identifier.js
parent5a105134b9fdf9abc0dc12dc3e44027529634715 (diff)
downloadqtdeclarative-testsuites-4dad98d63c279b989fdb48006fbd1db8ee27bc7f.tar.gz
Add optional chaining testssnapshot-20180312-3c69133-based
Change-Id: Ia87313a2756dfbc3d90128ac77cd4dc6c8c137df Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 7d1cf05c547a636495b2731c4fc2842a01849064) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'test/language/expressions/optional-chaining/member-expression-async-identifier.js')
-rw-r--r--test/language/expressions/optional-chaining/member-expression-async-identifier.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/language/expressions/optional-chaining/member-expression-async-identifier.js b/test/language/expressions/optional-chaining/member-expression-async-identifier.js
new file mode 100644
index 000000000..19f9385eb
--- /dev/null
+++ b/test/language/expressions/optional-chaining/member-expression-async-identifier.js
@@ -0,0 +1,32 @@
+// Copyright 2019 Google, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: prod-OptionalExpression
+description: >
+ optional chain on member expression in async context
+info: |
+ Left-Hand-Side Expressions
+ OptionalExpression
+ MemberExpression [PrimaryExpression identifier] OptionalChain
+features: [optional-chaining]
+flags: [async]
+---*/
+
+const a = undefined;
+const c = {d: Promise.resolve(11)};
+async function checkAssertions() {
+ assert.sameValue(await a?.b, undefined);
+ assert.sameValue(await c?.d, 11);
+
+ Promise.prototype.x = 42;
+ var res = await Promise.resolve(undefined)?.x;
+ assert.sameValue(res, 42, 'await unwraps the evaluation of the whole optional chaining expression #1');
+
+ Promise.prototype.y = 43;
+ var res = await Promise.reject(undefined)?.y;
+ assert.sameValue(res, 43, 'await unwraps the evaluation of the whole optional chaining expression #2');
+
+ c.e = Promise.resolve(39);
+ assert.sameValue(await c?.e, 39, 'await unwraps the promise given after the evaluation of the OCE');
+}
+checkAssertions().then($DONE, $DONE);