tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

optional-chain-async-square-brackets.js (817B)


      1 // |reftest| async
      2 // Copyright 2019 Google, Inc.  All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 esid: prod-OptionalExpression
      6 description: >
      7  optional chain expansions in an async context
      8 info: |
      9  Left-Hand-Side Expressions
     10    OptionalExpression
     11      MemberExpression [PrimaryExpression Identifier] OptionalChain
     12        OptionalChain ?.[Expression]
     13 features: [optional-chaining]
     14 flags: [async]
     15 includes: [asyncHelpers.js]
     16 ---*/
     17 
     18 async function checkAssertions() {
     19  assert.sameValue(await [11]?.[0], 11);
     20  assert.sameValue([22, 33]?.[await Promise.resolve(1)], 33);
     21  assert.sameValue([44, await Promise.resolve(55)]?.[1], 55);
     22  assert.sameValue(undefined?.[
     23    await Promise.reject(new Error('unreachable'))
     24  ], undefined);
     25 }
     26 asyncTest(checkAssertions);