mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Add ArrayBindingPattern destructuring tests
This commit is contained in:
parent
1d513c3a50
commit
4d9944e014
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
|
||||||
|
description: >
|
||||||
|
Destructuring initializer is not evaluated when value is an object
|
||||||
|
with [[IsHTMLDDA]] internal slot.
|
||||||
|
info: |
|
||||||
|
BindingPattern : ArrayBindingPattern
|
||||||
|
|
||||||
|
1. Let iteratorRecord be ? GetIterator(value).
|
||||||
|
2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments
|
||||||
|
iteratorRecord and environment.
|
||||||
|
3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
|
||||||
|
4. Return result.
|
||||||
|
|
||||||
|
Runtime Semantics: IteratorBindingInitialization
|
||||||
|
|
||||||
|
SingleNameBinding : BindingIdentifier Initializer[opt]
|
||||||
|
|
||||||
|
[...]
|
||||||
|
5. If Initializer is present and v is undefined, then
|
||||||
|
[...]
|
||||||
|
6. If environment is undefined, return ? PutValue(lhs, v).
|
||||||
|
features: [destructuring-binding, IsHTMLDDA]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var IsHTMLDDA = $262.IsHTMLDDA;
|
||||||
|
var initCount = 0;
|
||||||
|
var counter = function() {
|
||||||
|
initCount += 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
var x;
|
||||||
|
([x = counter()] = [IsHTMLDDA]);
|
||||||
|
|
||||||
|
assert.sameValue(x, IsHTMLDDA);
|
||||||
|
assert.sameValue(initCount, 0);
|
||||||
|
|
||||||
|
var base = {};
|
||||||
|
([base.y = counter()] = [IsHTMLDDA]);
|
||||||
|
|
||||||
|
assert.sameValue(base.y, IsHTMLDDA);
|
||||||
|
assert.sameValue(initCount, 0);
|
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
|
||||||
|
description: >
|
||||||
|
Destructuring initializer is not evaluated when value is an object
|
||||||
|
with [[IsHTMLDDA]] internal slot.
|
||||||
|
info: |
|
||||||
|
BindingPattern : ArrayBindingPattern
|
||||||
|
|
||||||
|
1. Let iteratorRecord be ? GetIterator(value).
|
||||||
|
2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments
|
||||||
|
iteratorRecord and environment.
|
||||||
|
3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
|
||||||
|
4. Return result.
|
||||||
|
|
||||||
|
Runtime Semantics: IteratorBindingInitialization
|
||||||
|
|
||||||
|
SingleNameBinding : BindingIdentifier Initializer[opt]
|
||||||
|
|
||||||
|
[...]
|
||||||
|
5. If Initializer is present and v is undefined, then
|
||||||
|
[...]
|
||||||
|
6. If environment is undefined, return ? PutValue(lhs, v).
|
||||||
|
features: [destructuring-binding, IsHTMLDDA]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let initCount = 0;
|
||||||
|
const counter = function() {
|
||||||
|
initCount += 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
const IsHTMLDDA = $262.IsHTMLDDA;
|
||||||
|
const [x = counter()] = [IsHTMLDDA];
|
||||||
|
|
||||||
|
assert.sameValue(x, IsHTMLDDA);
|
||||||
|
assert.sameValue(initCount, 0);
|
Loading…
x
Reference in New Issue
Block a user