test: add test for ?. [expression] edge cases (#2297)

This commit is contained in:
Benjamin E. Coe 2019-08-28 14:02:17 -04:00 committed by Leo Balter
parent 33cc1cdb6c
commit 854df2196f
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
// 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 bracket notation containing optional expresion
info: |
OptionalChain:
?. [OptionalExpression]
features: [optional-chaining]
---*/
const a = undefined;
const b = {e: 0};
const c = {};
c[undefined] = 11;
const d = [22];
assert.sameValue(undefined, a?.[a?.b]);
assert.sameValue(11, c?.[a?.b]);
assert.sameValue(22, d?.[b?.e]);