-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
117 additions
and
60 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
test/language/expressions/optional-chaining/call-expression-optional-chain.js
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
test/language/expressions/optional-chaining/call-expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
desc: > | ||
optional chain on call expression | ||
info: | | ||
Left-Hand-Side Expressions | ||
OptionalExpression: | ||
CallExpression OptionalChain | ||
features: [optional-chaining] | ||
---*/ | ||
|
||
function fn () { | ||
return {a: 33}; | ||
}; | ||
|
||
// CallExpression Arguments | ||
assert.sameValue(33, fn()?.a); | ||
assert.sameValue(undefined, fn()?.b); |
25 changes: 25 additions & 0 deletions
25
.../language/expressions/optional-chaining/early-errors-tail-position-template-string-esi.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2019 Google, Inc. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: prod-OptionalExpression | ||
desc: > | ||
template string passed to tail position of optional chain | ||
info: | | ||
Static Semantics: Early Errors | ||
OptionalChain: | ||
?.TemplateLiteral | ||
OptionalChain TemplateLiteral | ||
features: [optional-chaining] | ||
negative: | ||
type: SyntaxError | ||
phase: parse | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
const a = {fn() {}}; | ||
|
||
// This production exists in order to prevent automatic semicolon | ||
// insertion rules. | ||
a?.fn | ||
`hello` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
...ining/member-expression-optional-chain.js → ...ns/optional-chaining/member-expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
test/language/expressions/optional-chaining/optional-expression-optional-chain.js
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
test/language/expressions/optional-chaining/optional-expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2019 Google, Inc. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: prod-OptionalExpression | ||
desc: > | ||
optional chain on recursive optional expression | ||
info: | | ||
Left-Hand-Side Expressions | ||
OptionalExpression: | ||
OptionalExpression OptionalChain | ||
features: [optional-chaining] | ||
---*/ | ||
|
||
const obj = { | ||
a: { | ||
b: 22 | ||
} | ||
}; | ||
|
||
function fn () { | ||
return {}; | ||
} | ||
|
||
// MemberExpression | ||
assert.sameValue(22, (obj?.a)?.b); | ||
// CallExpression | ||
assert.sameValue(undefined, (fn()?.a)?.b); |
12 changes: 7 additions & 5 deletions
12
test/language/expressions/optional-chaining/punctuator-decimal-lookahead.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// Copyright 2019 Google, Inc. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
info: | | ||
esid: prod-OptionalExpression | ||
desc: > | ||
ternary operation with decimal does not evaluate as optional chain | ||
description: > | ||
info: | | ||
Punctuators | ||
OptionalChainingPunctuator:: | ||
?.[lookahead ∉ DecimalDigit] | ||
features: [optional-chaining] | ||
---*/ | ||
|
||
const value = true ?.30 : false | ||
assert.sameValue(.30, value) | ||
const value = true ?.30 : false; | ||
assert.sameValue(.30, value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
test/language/expressions/optional-chaining/short-circuiting.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
// Copyright 2019 Google, Inc. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
esid: prod-OptionalExpression | ||
desc: > | ||
demonstrate syntax-based short-circuiting. | ||
info: | | ||
If the expression on the LHS of ?. evaluates to null/undefined, the RHS is | ||
not evaluated | ||
description: > | ||
demonstrate syntax-based short-circuiting. | ||
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); |
9 changes: 6 additions & 3 deletions
9
test/language/expressions/optional-chaining/static-semantics-simple-assignment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters