Skip to content
Snippets Groups Projects
Commit 4337b396 authored by André Bargull's avatar André Bargull Committed by Rick Waldron
Browse files

Add separate test files for property attributes of Intl properties

parent 513a3056
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 43 deletions
......@@ -11,12 +11,10 @@ description: |
* @param {Object} obj the object to be tested.
* @param {boolean} isFunction whether the specification describes obj as a function.
* @param {boolean} isConstructor whether the specification describes obj as a constructor.
* @param {String[]} properties an array with the names of the built-in properties of obj,
* excluding length, prototype, or properties with non-default attributes.
* @author Norbert Lindenberg
*/
function testBuiltInObject(obj, isFunction, isConstructor, properties) {
function testBuiltInObject(obj, isFunction, isConstructor) {
if (obj === undefined) {
$ERROR("Object being tested is undefined.");
......@@ -47,34 +45,6 @@ function testBuiltInObject(obj, isFunction, isConstructor, properties) {
$ERROR("Built-in prototype objects must have Object.prototype as their prototype.");
}
// verification of the absence of the [[Construct]] internal property has
// been moved to the end of the test
// verification of the absence of the prototype property has
// been moved to the end of the test
properties.forEach(function(prop) {
var desc = Object.getOwnPropertyDescriptor(obj, prop);
if (desc === undefined) {
$ERROR("Missing property " + prop + ".");
}
// accessor properties don't have writable attribute
if (desc.hasOwnProperty("writable") && !desc.writable) {
$ERROR("The " + prop + " property of this built-in object must be writable.");
}
if (desc.enumerable) {
$ERROR("The " + prop + " property of this built-in object must not be enumerable.");
}
if (!desc.configurable) {
$ERROR("The " + prop + " property of this built-in object must be configurable.");
}
});
// The remaining sections have been moved to the end of the test because
// unbound non-constructor functions written in JavaScript cannot possibly
// pass them, and we still want to test JavaScript implementations as much
// as possible.
var exception;
if (isFunction && !isConstructor) {
// this is not a complete test for the presence of [[Construct]]:
......
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator, true, true, ["supportedLocalesOf"]);
testBuiltInObject(Intl.Collator, true, true);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.collator-intro
description: >
"Collator" property of Intl.
info: |
Intl.Collator (...)
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl, "Collator");
verifyWritable(Intl, "Collator");
verifyConfigurable(Intl, "Collator");
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.prototype, false, false, ["constructor", "compare", "resolvedOptions"]);
testBuiltInObject(Intl.Collator.prototype, false, false);
......@@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(new Intl.Collator().compare, true, false, []);
testBuiltInObject(new Intl.Collator().compare, true, false);
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true, false, []);
testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true, false);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.collator.prototype.resolvedoptions
description: >
"compare" property of Intl.Collator.prototype.
info: |
get Intl.Collator.prototype.compare
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
17 ECMAScript Standard Built-in Objects:
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the
attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
If only a get accessor function is described, the set accessor function is the default
value, undefined. If only a set accessor is described the get accessor is the default
value, undefined.
includes: [propertyHelper.js]
---*/
var desc = Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare");
assert.sameValue(desc.set, undefined);
assert.sameValue(typeof desc.get, "function");
verifyNotEnumerable(Intl.Collator.prototype, "compare");
verifyConfigurable(Intl.Collator.prototype, "compare");
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.collator.prototype.constructor
description: >
"constructor" property of Intl.Collator.prototype.
info: |
Intl.Collator.prototype.constructor
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl.Collator.prototype, "constructor");
verifyWritable(Intl.Collator.prototype, "constructor");
verifyConfigurable(Intl.Collator.prototype, "constructor");
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true, false, []);
testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true, false);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.collator.prototype.resolvedoptions
description: >
"resolvedOptions" property of Intl.Collator.prototype.
info: |
Intl.Collator.prototype.resolvedOptions ()
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl.Collator.prototype, "resolvedOptions");
verifyWritable(Intl.Collator.prototype, "resolvedOptions");
verifyConfigurable(Intl.Collator.prototype, "resolvedOptions");
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.Collator.supportedLocalesOf, true, false, []);
testBuiltInObject(Intl.Collator.supportedLocalesOf, true, false);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.collator.supportedlocalesof
description: >
"supportedLocalesOf" property of Intl.Collator.
info: |
Intl.Collator.supportedLocalesOf ( locales [ , options ] )
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl.Collator, "supportedLocalesOf");
verifyWritable(Intl.Collator, "supportedLocalesOf");
verifyConfigurable(Intl.Collator, "supportedLocalesOf");
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleDateString, true, false, []);
testBuiltInObject(Date.prototype.toLocaleDateString, true, false);
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleString, true, false, []);
testBuiltInObject(Date.prototype.toLocaleString, true, false);
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Date.prototype.toLocaleTimeString, true, false, []);
testBuiltInObject(Date.prototype.toLocaleTimeString, true, false);
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat, true, true, ["supportedLocalesOf"]);
testBuiltInObject(Intl.DateTimeFormat, true, true);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.datetimeformat-intro
description: >
"DateTimeFormat" property of Intl.
info: |
Intl.DateTimeFormat (...)
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl, "DateTimeFormat");
verifyWritable(Intl, "DateTimeFormat");
verifyConfigurable(Intl, "DateTimeFormat");
......@@ -11,4 +11,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(Intl.DateTimeFormat.prototype, false, false, ["constructor", "format", "resolvedOptions"]);
testBuiltInObject(Intl.DateTimeFormat.prototype, false, false);
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.datetimeformat.prototype.constructor
description: >
"constructor" property of Intl.DateTimeFormat.prototype.
info: |
Intl.DateTimeFormat.prototype.constructor
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
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]
---*/
verifyNotEnumerable(Intl.DateTimeFormat.prototype, "constructor");
verifyWritable(Intl.DateTimeFormat.prototype, "constructor");
verifyConfigurable(Intl.DateTimeFormat.prototype, "constructor");
......@@ -12,4 +12,4 @@ author: Norbert Lindenberg
includes: [testBuiltInObject.js]
---*/
testBuiltInObject(new Intl.DateTimeFormat().format, true, false, []);
testBuiltInObject(new Intl.DateTimeFormat().format, true, false);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment