mirror of https://github.com/tc39/test262.git
Migrate test for ns
This commit is contained in:
parent
019322b114
commit
3968c2d831
|
@ -0,0 +1,114 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc
|
||||
desc: >
|
||||
The [[DefineOwnProperty]] internal method returns `true` if no change is
|
||||
requested, and `false` otherwise.
|
||||
features: [Symbol.iterator, Reflect, Symbol, Symbol.toStringTag]
|
||||
template: namespace
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var sym = Symbol('test262');
|
||||
|
||||
const exported = ['local1', 'renamed', 'indirect'];
|
||||
|
||||
//- import
|
||||
import('./define-own-property_FIXTURE.js')
|
||||
//- body
|
||||
// Non-existant properties.
|
||||
|
||||
for (const key of ['local2', 0, sym, Symbol.iterator]) {
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, key, {}),
|
||||
false,
|
||||
'Reflect.defineProperty: ' + key.toString()
|
||||
);
|
||||
assert.throws(TypeError, function() {
|
||||
Object.defineProperty(ns, key, {});
|
||||
}, 'Object.defineProperty: ' + key.toString());
|
||||
}
|
||||
|
||||
// Own properties. No change requested.
|
||||
|
||||
for (const key of ([...exported, Symbol.toStringTag])) {
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, key, {}),
|
||||
true,
|
||||
`No change requested, Reflect.defineProperty: ${key.toString()}`
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.defineProperty(ns, key, {}),
|
||||
ns,
|
||||
`No change requested, Object.defineProperty: ${key.toString()}`
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, 'indirect',
|
||||
{writable: true, enumerable: true, configurable: false}),
|
||||
true,
|
||||
'Reflect.defineProperty: indirect'
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.defineProperty(ns, 'indirect',
|
||||
{writable: true, enumerable: true, configurable: false}),
|
||||
ns,
|
||||
'Object.defineProperty: indirect'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, Symbol.toStringTag,
|
||||
{value: "Module", writable: false, enumerable: false,
|
||||
configurable: false}),
|
||||
true,
|
||||
'Reflect.defineProperty: Symbol.toStringTag'
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.defineProperty(ns, Symbol.toStringTag,
|
||||
{value: "Module", writable: false, enumerable: false,
|
||||
configurable: false}),
|
||||
ns,
|
||||
'Object.defineProperty: Symbol.toStringTag'
|
||||
);
|
||||
|
||||
|
||||
// Own properties. Change requested.
|
||||
|
||||
for (const key of ([...exported, Symbol.toStringTag])) {
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, key, {value: 123}),
|
||||
false,
|
||||
`Change requested, Reflect.defineProperty: ${key.toString()}`
|
||||
);
|
||||
assert.throws(TypeError, function() {
|
||||
Object.defineProperty(ns, key, {value: 123});
|
||||
}, `Change requested, Object.defineProperty: ${key.toString()}`);
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, 'indirect',
|
||||
{writable: true, enumerable: true, configurable: true}),
|
||||
false,
|
||||
'Reflect.defineProperty: indirect'
|
||||
);
|
||||
assert.throws(TypeError, function() {
|
||||
Object.defineProperty(ns, 'indirect',
|
||||
{writable: true, enumerable: true, configurable: true});
|
||||
}, 'Object.defineProperty: indirect');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(ns, Symbol.toStringTag,
|
||||
{value: "module", writable: false, enumerable: false,
|
||||
configurable: false}),
|
||||
false,
|
||||
'Reflect.defineProperty: Symbol.toStringTag'
|
||||
);
|
||||
assert.throws(TypeError, function() {
|
||||
Object.defineProperty(ns, Symbol.toStringTag,
|
||||
{value: "module", writable: false, enumerable: false,
|
||||
configurable: false});
|
||||
}, 'Object.defineProperty: Symbol.toStringTag');
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-module-namespace-exotic-objects-delete-p
|
||||
desc: >
|
||||
The [[Delete]] behavior for a key that describes an initialized exported
|
||||
binding on non strict mode
|
||||
info: |
|
||||
[...]
|
||||
2. If Type(P) is Symbol, then
|
||||
a. Return ? OrdinaryDelete(O, P).
|
||||
3. Let exports be O.[[Exports]].
|
||||
4. If P is an element of exports, return false.
|
||||
5. Return true.
|
||||
template: namespace
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./delete-exported-init_FIXTURE.js')
|
||||
//- body
|
||||
assert.sameValue(delete ns.local1, false, 'delete: local1');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1'
|
||||
);
|
||||
assert.sameValue(ns.local1, 333, 'binding unmodified: local1');
|
||||
|
||||
assert.sameValue(delete ns.renamed, false, 'delete: renamed');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed'
|
||||
);
|
||||
assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed');
|
||||
|
||||
assert.sameValue(delete ns.indirect, false, 'delete: indirect');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'indirect'),
|
||||
false,
|
||||
'Reflect.deleteProperty: indirect'
|
||||
);
|
||||
assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect');
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-module-namespace-exotic-objects-delete-p
|
||||
desc: >
|
||||
The [[Delete]] behavior for a key that describes an initialized exported
|
||||
binding on strict mode
|
||||
info: |
|
||||
[...]
|
||||
2. If Type(P) is Symbol, then
|
||||
a. Return ? OrdinaryDelete(O, P).
|
||||
3. Let exports be O.[[Exports]].
|
||||
4. If P is an element of exports, return false.
|
||||
5. Return true.
|
||||
template: namespace
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./delete-exported-init_FIXTURE.js')
|
||||
//- body
|
||||
assert.throws(TypeError, function() {
|
||||
delete ns.local1;
|
||||
}, 'delete: local1');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1'
|
||||
);
|
||||
assert.sameValue(ns.local1, 333, 'binding unmodified: local1');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
delete ns.renamed;
|
||||
}, 'delete: renamed');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed'
|
||||
);
|
||||
assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
delete ns.indirect;
|
||||
}, 'delete: indirect');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, 'indirect'),
|
||||
false,
|
||||
'Reflect.deleteProperty: indirect'
|
||||
);
|
||||
assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect');
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-module-namespace-exotic-objects-delete-p
|
||||
desc: >
|
||||
The [[Delete]] behavior for a key that does not describe an exported binding
|
||||
info: |
|
||||
[...]
|
||||
2. If Type(P) is Symbol, then
|
||||
a. Return ? OrdinaryDelete(O, P).
|
||||
3. Let exports be O.[[Exports]].
|
||||
4. If P is an element of exports, return false.
|
||||
5. Return true.
|
||||
template: namespace
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./empty_FIXTURE.js')
|
||||
//- body
|
||||
assert(delete ns.undef, 'delete: undef');
|
||||
assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef');
|
||||
|
||||
assert(delete ns.default, 'delete: default');
|
||||
assert(
|
||||
Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default'
|
||||
);
|
||||
|
||||
assert.sameValue(delete ns[Symbol.toStringTag], false, 'delete: Symbol.toStringTag');
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, Symbol.toStringTag), false,
|
||||
'Reflect.deleteProperty: Symbol.toStringTag'
|
||||
);
|
||||
|
||||
var sym = Symbol('test262');
|
||||
assert(delete ns[sym], 'delete: symbol');
|
||||
assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol');
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-module-namespace-exotic-objects-delete-p
|
||||
desc: >
|
||||
The [[Delete]] behavior for a key that does not describe an exported binding
|
||||
info: |
|
||||
[...]
|
||||
2. If Type(P) is Symbol, then
|
||||
a. Return ? OrdinaryDelete(O, P).
|
||||
3. Let exports be O.[[Exports]].
|
||||
4. If P is an element of exports, return false.
|
||||
5. Return true.
|
||||
template: namespace
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./empty_FIXTURE.js')
|
||||
//- body
|
||||
assert(delete ns.undef, 'delete: undef');
|
||||
assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef');
|
||||
|
||||
assert(delete ns.default, 'delete: default');
|
||||
assert(
|
||||
Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.deleteProperty(ns, Symbol.toStringTag), false,
|
||||
'Reflect.deleteProperty: Symbol.toStringTag'
|
||||
);
|
||||
assert.throws(TypeError, function() { delete ns[Symbol.toStringTag]; }, 'delete: Symbol.toStringTag');
|
||||
|
||||
var sym = Symbol('test262');
|
||||
assert(delete ns[sym], 'delete: symbol');
|
||||
assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol');
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export var local1;
|
||||
var local2;
|
||||
export { local2 as renamed };
|
||||
export { local1 as indirect } from './define-own-property_FIXTURE.js';
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export var local1 = 333;
|
||||
var local2 = 444;
|
||||
export { local2 as renamed };
|
||||
export { local1 as indirect } from './delete-exported-init_FIXTURE.js';
|
|
@ -0,0 +1,2 @@
|
|||
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
Loading…
Reference in New Issue