From 9f57733ed946c5a554c3a3edf3ecf89bc65464b2 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 19 Apr 2018 11:23:17 -0400 Subject: [PATCH] Test all no-construct no-call objects consistently (#1520) Related to https://github.com/tc39/ecma262/pull/1177 --- test/built-ins/Atomics/prop-desc.js | 26 +++++++++++------- test/built-ins/Atomics/proto.js | 4 +-- test/built-ins/JSON/prop-desc.js | 40 ++++++++++++++++++++++++++++ test/built-ins/Math/prop-desc.js | 27 ++++++++++++------- test/built-ins/Reflect/Reflect.js | 31 --------------------- test/built-ins/Reflect/prop-desc.js | 40 ++++++++++++++++++++++++++++ test/built-ins/Reflect/properties.js | 14 ---------- 7 files changed, 115 insertions(+), 67 deletions(-) create mode 100644 test/built-ins/JSON/prop-desc.js delete mode 100644 test/built-ins/Reflect/Reflect.js create mode 100644 test/built-ins/Reflect/prop-desc.js delete mode 100644 test/built-ins/Reflect/properties.js diff --git a/test/built-ins/Atomics/prop-desc.js b/test/built-ins/Atomics/prop-desc.js index 946bab41c0..57cfb2ecba 100644 --- a/test/built-ins/Atomics/prop-desc.js +++ b/test/built-ins/Atomics/prop-desc.js @@ -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 +}); diff --git a/test/built-ins/Atomics/proto.js b/test/built-ins/Atomics/proto.js index 1e7183f6d7..8072c47494 100644 --- a/test/built-ins/Atomics/proto.js +++ b/test/built-ins/Atomics/proto.js @@ -13,6 +13,4 @@ info: | features: [Atomics] ---*/ -var proto = Object.getPrototypeOf(Atomics); - -assert.sameValue(proto, Object.prototype); +assert.sameValue(Object.getPrototypeOf(Atomics), Object.prototype); diff --git a/test/built-ins/JSON/prop-desc.js b/test/built-ins/JSON/prop-desc.js new file mode 100644 index 0000000000..9c06000ebe --- /dev/null +++ b/test/built-ins/JSON/prop-desc.js @@ -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 +}); diff --git a/test/built-ins/Math/prop-desc.js b/test/built-ins/Math/prop-desc.js index b78c0bb938..682fc0bd33 100644 --- a/test/built-ins/Math/prop-desc.js +++ b/test/built-ins/Math/prop-desc.js @@ -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 +}); diff --git a/test/built-ins/Reflect/Reflect.js b/test/built-ins/Reflect/Reflect.js deleted file mode 100644 index 2500acb2b6..0000000000 --- a/test/built-ins/Reflect/Reflect.js +++ /dev/null @@ -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(); -}); diff --git a/test/built-ins/Reflect/prop-desc.js b/test/built-ins/Reflect/prop-desc.js new file mode 100644 index 0000000000..72fee3c151 --- /dev/null +++ b/test/built-ins/Reflect/prop-desc.js @@ -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 +}); diff --git a/test/built-ins/Reflect/properties.js b/test/built-ins/Reflect/properties.js deleted file mode 100644 index d39c350ba3..0000000000 --- a/test/built-ins/Reflect/properties.js +++ /dev/null @@ -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');