Test all no-construct no-call objects consistently (#1520)

Related to https://github.com/tc39/ecma262/pull/1177
This commit is contained in:
Rick Waldron 2018-04-19 11:23:17 -04:00 committed by Leo Balter
parent cd6305155b
commit 9f57733ed9
7 changed files with 115 additions and 67 deletions

View File

@ -8,11 +8,12 @@ description: >
info: |
The Atomics Object
[...]
The Atomics object is not a function object. It does not have a [[Construct]]
internal method; it is not possible to use the Atomics object as a constructor
with the new operator. The Atomics object also does not have a [[Call]] internal
method; it is not possible to invoke the Atomics object as a function.
...
The Atomics object does not have a [[Construct]] internal method;
it is not possible to use the Atomics object as a constructor with the new operator.
The Atomics object does not have a [[Call]] internal method;
it is not possible to invoke the Atomics object as a function.
17 ECMAScript Standard Built-in Objects:
@ -23,11 +24,18 @@ includes: [propertyHelper.js]
features: [Atomics]
---*/
assert.sameValue(typeof Atomics, "object", "no [[Call]]");
assert.sameValue(typeof Atomics, "object");
assert.throws(TypeError, function() {
Atomics();
}, "no [[Call]]");
assert.throws(TypeError, function() {
new Atomics();
}, "no [[Construct]]");
verifyNotEnumerable(this, "Atomics");
verifyWritable(this, "Atomics");
verifyConfigurable(this, "Atomics");
verifyProperty(this, "Atomics", {
enumerable: false,
writable: true,
configurable: true
});

View File

@ -13,6 +13,4 @@ info: |
features: [Atomics]
---*/
var proto = Object.getPrototypeOf(Atomics);
assert.sameValue(proto, Object.prototype);
assert.sameValue(Object.getPrototypeOf(Atomics), Object.prototype);

View File

@ -0,0 +1,40 @@
// 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-json-object
description: >
Property descriptor of JSON
info: |
The JSON Object
...
The JSON object does not have a [[Construct]] internal method;
it is not possible to use the JSON object as a constructor with the new operator.
The JSON object does not have a [[Call]] internal method;
it is not possible to invoke the JSON object as a function.
17 ECMAScript Standard Built-in Objects:
Every other data property described in clauses 18 through 26 and in Annex B.2
has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
assert.sameValue(typeof JSON, "object");
assert.throws(TypeError, function() {
JSON();
}, "no [[Call]]");
assert.throws(TypeError, function() {
new JSON();
}, "no [[Construct]]");
verifyProperty(this, "JSON", {
enumerable: false,
writable: true,
configurable: true
});

View File

@ -2,18 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.2
esid: sec-math-object
description: >
Property descriptor of Math
info: |
The Math Object
[...]
The Math object is not a function object. It does not have a [[Construct]]
internal method; it is not possible to use the Math object as a constructor
with the new operator. The Math object also does not have a [[Call]] internal
method; it is not possible to invoke the Math object as a function.
...
The Math object does not have a [[Construct]] internal method;
it is not possible to use the Math object as a constructor with the new operator.
The Math object does not have a [[Call]] internal method;
it is not possible to invoke the Math object as a function.
17 ECMAScript Standard Built-in Objects:
@ -23,11 +23,18 @@ info: |
includes: [propertyHelper.js]
---*/
assert.sameValue(typeof Math, "object", "no [[Call]]");
assert.sameValue(typeof Math, "object");
assert.throws(TypeError, function() {
Math();
}, "no [[Call]]");
assert.throws(TypeError, function() {
new Math();
}, "no [[Construct]]");
verifyNotEnumerable(this, "Math");
verifyWritable(this, "Math");
verifyConfigurable(this, "Math");
verifyProperty(this, "Math", {
enumerable: false,
writable: true,
configurable: true
});

View File

@ -1,31 +0,0 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1
description: >
The Reflect object is an ordinary object.
info: |
26.1 The Reflect Object
The Reflect object is the %Reflect% intrinsic object and the initial value of
the Reflect property of the global object. The Reflect object is an ordinary
object.
The Reflect object is not a function object. It does not have a [[Construct]]
internal method; it is not possible to use the Reflect object as a constructor
with the new operator. The Reflect object also does not have a [[Call]]
internal method; it is not possible to invoke the Reflect object as a
function.
---*/
assert.sameValue(typeof Reflect, 'object', '`typeof Reflect` is `"object"`');
// Reflect is not callable
assert.throws(TypeError, function() {
Reflect();
});
// Reflect doesn't have a constructor
assert.throws(TypeError, function() {
new Reflect();
});

View File

@ -0,0 +1,40 @@
// 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-math-object
description: >
Property descriptor of Reflect
info: |
The Reflect Object
...
The Reflect object does not have a [[Construct]] internal method;
it is not possible to use the Reflect object as a constructor with the new operator.
The Reflect object does not have a [[Call]] internal method;
it is not possible to invoke the Reflect object as a function.
17 ECMAScript Standard Built-in Objects:
Every other data property described in clauses 18 through 26 and in Annex B.2
has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
assert.sameValue(typeof Reflect, "object");
assert.throws(TypeError, function() {
Reflect();
}, "no [[Call]]");
assert.throws(TypeError, function() {
new Reflect();
}, "no [[Construct]]");
verifyProperty(this, "Reflect", {
enumerable: false,
writable: true,
configurable: true
});

View File

@ -1,14 +0,0 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1
description: >
Reflect is configurable, writable and not enumerable.
info: |
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
verifyNotEnumerable(this, 'Reflect');
verifyWritable(this, 'Reflect');
verifyConfigurable(this, 'Reflect');