Skip to content
Snippets Groups Projects
Unverified Commit 0200c633 authored by Caio Lima's avatar Caio Lima Committed by Leonardo Balter
Browse files

Implementing test cases for object rest deconstruction

Closes #867
Ref #865
parent da3898d7
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment and object rest desconstruction is allowed in that case.
template: default
esid: pending
includes: [propertyHelper.js]
---*/
//- elems
{a, b, ...{c, ...rest}}
//- vals
{a: 1, b: 2, c: 3, d: 4, e: 5}
//- body
assert.sameValue(a, 1);
assert.sameValue(b, 2);
assert.sameValue(c, 3);
assert.sameValue(rest.d, 4);
assert.sameValue(rest.e, 5);
verifyEnumerable(rest, "d");
verifyWritable(rest, "d");
verifyConfigurable(rest, "d");
verifyEnumerable(rest, "e");
verifyWritable(rest, "e");
verifyConfigurable(rest, "e");
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Rest object contains just soruce object's own properties
template: default
esid: pending
includes: [propertyHelper.js]
---*/
//- setup
var o = Object.create({ x: 1, y: 2 });
o.z = 3;
//- elems
{ x, ...{y , z} }
//- vals
o
//- body
assert.sameValue(x, 1);
assert.sameValue(y, undefined);
assert.sameValue(z, 3);
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Rest object doesn't contain non-enumerable properties
template: default
esid: pending
includes: [propertyHelper.js]
---*/
//- setup
var o = {a: 3, b: 4};
Object.defineProperty(o, "x", { value: 4, enumerable: false });
//- elems
{...rest}
//- vals
o
//- body
assert.sameValue(rest.a, 3);
assert.sameValue(rest.b, 4);
assert.sameValue(rest.x, undefined);
verifyEnumerable(rest, "a");
verifyWritable(rest, "a");
verifyConfigurable(rest, "a");
verifyEnumerable(rest, "b");
verifyWritable(rest, "b");
verifyConfigurable(rest, "b");
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Rest object contains just unextracted data
template: default
esid: pending
includes: [propertyHelper.js]
---*/
//- elems
{a, b, ...rest}
//- vals
{x: 1, y: 2, a: 5, b: 3}
//- body
assert.sameValue(rest.x, 1);
assert.sameValue(rest.y, 2);
assert.sameValue(rest.a, undefined);
assert.sameValue(rest.b, undefined);
verifyEnumerable(rest, "x");
verifyWritable(rest, "x");
verifyConfigurable(rest, "x");
verifyEnumerable(rest, "y");
verifyWritable(rest, "y");
verifyConfigurable(rest, "y");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment