Inital commit for Intl.DisplayNames tests (#2404)

This commit is contained in:
Leo Balter 2019-10-17 10:32:00 -04:00 committed by GitHub
parent 4b6efea2c6
commit 21195de94c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 1592 additions and 0 deletions

View File

@ -149,6 +149,10 @@ regexp-match-indices
# https://github.com/tc39/proposal-nullish-coalescing
coalesce-expression
# Intl.DisplayNames
# https://github.com/tc39-transfer/proposal-intl-displaynames
Intl.DisplayNames
## Standard language features
#
# Language features that have been included in a published version of the

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt from Get Prototype from a custom NewTarget
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
...
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
...
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
3. Let proto be ? Get(constructor, "prototype").
4. If Type(proto) is not Object, then
a. Let realm be ? GetFunctionRealm(constructor).
b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
5. Return proto.
features: [Intl.DisplayNames, Reflect, Proxy]
---*/
var custom = new Proxy(new Function(), {
get(target, key) {
if (key === 'prototype') {
throw new Test262Error();
}
return target[key];
}
});
assert.throws(Test262Error, () => {
Reflect.construct(Intl.DisplayNames, [], custom);
});

View File

@ -0,0 +1,37 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Custom Prototype of the returned object based on the NewTarget
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
...
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
...
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
3. Let proto be ? Get(constructor, "prototype").
4. If Type(proto) is not Object, then
a. Let realm be ? GetFunctionRealm(constructor).
b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
5. Return proto.
features: [Intl.DisplayNames, Reflect]
---*/
var custom = new Function();
custom.prototype = {};
var obj = Reflect.construct(Intl.DisplayNames, [], custom);
assert.sameValue(Object.getPrototypeOf(obj), custom.prototype);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Prototype of the returned object is DisplayNames.prototype
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
27. Return displayNames.
features: [Intl.DisplayNames]
---*/
var obj = new Intl.DisplayNames();
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype);

View File

@ -0,0 +1,35 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Instance is extensible
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
...
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
3. Return ObjectCreate(proto, internalSlotsList).
ObjectCreate ( proto [ , internalSlotsList ] )
...
2. Let obj be a newly created object with an internal slot for each name in internalSlotsList.
3. Set obj's essential internal methods to the default ordinary object definitions specified in 9.1.
4. Set obj.[[Prototype]] to proto.
5. Set obj.[[Extensible]] to true.
6. Return obj.
features: [Intl.DisplayNames]
---*/
var obj = new Intl.DisplayNames();
assert(Object.isExtensible(obj));

View File

@ -0,0 +1,31 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Intl.DisplayNames.length is 0.
info: |
ECMAScript Standard Built-in Objects:
Every built-in function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which
are shown using the form «...name») are not included in the default
argument count.
Unless otherwise specified, the length property of a built-in function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames]
---*/
verifyProperty(Intl.DisplayNames, "length", {
value: 0,
enumerable: false,
writable: false,
configurable: true,
});

View File

@ -0,0 +1,32 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Throws TypeError if locales is not undefined, a string, or an array-like object.
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
...
CanonicalizeLocaleList ( locales )
1. If locales is undefined, then
a. Return a new empty List.
2. Let seen be a new empty List.
3. If Type(locales) is String, then
a. Let O be CreateArrayFromList(« locales »).
4. Else,
a. Let O be ? ToObject(locales).
5. Let len be ? ToLength(? Get(O, "length")).
features: [Intl.DisplayNames]
---*/
assert.throws(TypeError, () => {
new Intl.DisplayNames(null);
}, 'null');

View File

@ -0,0 +1,40 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from Get Locales length
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
...
CanonicalizeLocaleList ( locales )
1. If locales is undefined, then
a. Return a new empty List.
2. Let seen be a new empty List.
3. If Type(locales) is String, then
a. Let O be CreateArrayFromList(« locales »).
4. Else,
a. Let O be ? ToObject(locales).
5. Let len be ? ToLength(? Get(O, "length")).
features: [Intl.DisplayNames, Symbol]
---*/
var locales = {};
Object.defineProperty(locales, 'length', {
get() {
throw new Test262Error();
}
});
assert.throws(Test262Error, () => {
new Intl.DisplayNames(locales);
});

View File

@ -0,0 +1,73 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from Locales invalid length
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
...
CanonicalizeLocaleList ( locales )
1. If locales is undefined, then
a. Return a new empty List.
2. Let seen be a new empty List.
3. If Type(locales) is String, then
a. Let O be CreateArrayFromList(« locales »).
4. Else,
a. Let O be ? ToObject(locales).
5. Let len be ? ToLength(? Get(O, "length")).
ToLength ( argument )
1. Let len be ? ToInteger(argument).
...
features: [Intl.DisplayNames, Symbol, BigInt]
---*/
var locales = {
length: {
valueOf() {
throw new Test262Error();
}
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames(locales);
}, 'poisoned valueOf for ToNumber');
locales.length = {
[Symbol.toPrimitive]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames(locales);
}, 'poisoned ToPrimitive for ToNumber');
locales.length = {
toString() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames(locales);
}, 'poisoned toString for ToNumber');
locales.length = Symbol();
assert.throws(TypeError, () => {
new Intl.DisplayNames(locales);
}, 'length is Symbol');
locales.length = BigInt(1);
assert.throws(TypeError, () => {
new Intl.DisplayNames(locales);
}, 'length is BigInt');

View File

@ -0,0 +1,59 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
CanonicalizeLocaleList tries to fetch length from Object.
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
...
CanonicalizeLocaleList ( locales )
1. If locales is undefined, then
a. Return a new empty List.
2. Let seen be a new empty List.
3. If Type(locales) is String, then
a. Let O be CreateArrayFromList(« locales »).
4. Else,
a. Let O be ? ToObject(locales).
5. Let len be ? ToLength(? Get(O, "length")).
features: [Intl.DisplayNames, Symbol]
locale: [en]
includes: [compareArray.js]
---*/
var calls = [];
var symbol = Symbol();
Symbol.prototype.length = 1;
Object.defineProperty(Symbol.prototype, 'length', {
get() {
assert.notSameValue(this, symbol, 'this is an object from given symbol');
assert.sameValue(this.valueOf(), symbol, 'internal value is the symbol');
assert(this instanceof Symbol);
calls.push('length');
return 1;
}
});
Object.defineProperty(Symbol.prototype, '0', {
get() {
assert.notSameValue(this, symbol, 'this is an object from given symbol');
assert.sameValue(this.valueOf(), symbol, 'internal value is the symbol');
assert(this instanceof Symbol);
calls.push('0');
return 'en';
}
});
new Intl.DisplayNames(symbol);
assert.compareArray(calls, ['length', '0']);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Intl.DisplayNames.name is "DisplayNames".
info: |
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String.
Unless otherwise specified, the name property of a built-in Function object,
if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames]
---*/
verifyProperty(Intl.DisplayNames, "name", {
value: "DisplayNames",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption fallback
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames, Symbol]
locale: [en]
---*/
var options = {};
Object.defineProperty(options, 'fallback', {
get() { throw new Test262Error(); },
});
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
});

View File

@ -0,0 +1,73 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from an invalid fallback option
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
2. If value is not undefined, then
...
c. If type is "string", then
i. Let value be ? ToString(value).
d. If values is not undefined, then
i. If values does not contain an element equal to value, throw a RangeError exception.
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {
fallback: 'err'
};
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'err');
options.fallback = 'non';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'non, not none');
options.fallback = null;
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'null');
options.fallback = '';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'the empty string');
options.fallback = ['code', 'none'];
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'an array with the valid options is not necessarily valid');

View File

@ -0,0 +1,70 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption fallback
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames, Symbol]
locale: [en]
---*/
var options = {
fallback: {
toString() {
throw new Test262Error();
}
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from toString');
options.fallback = {
toString: undefined,
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from valueOf');
options.fallback = {
[Symbol.toPrimitive]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from ToPrimitive');
options.fallback = Symbol();
assert.throws(TypeError, () => {
new Intl.DisplayNames('en', options);
}, 'symbol value');

View File

@ -0,0 +1,54 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Valid options for fallback
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
// results for option values verified in the tests for resolvedOptions
var values = [
undefined,
'code',
'none'
];
for (let valid of values) {
let options = {
fallback: valid
};
var obj = new Intl.DisplayNames('en', options);
assert(obj instanceof Intl.DisplayNames, `instanceof check - ${valid}`);
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${valid}`);
}

View File

@ -0,0 +1,37 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption localeMatcher
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {};
Object.defineProperty(options, 'localeMatcher', {
get() { throw new Test262Error(); },
});
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
});

View File

@ -0,0 +1,67 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from an invalid localeMatcher option
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
2. If value is not undefined, then
...
c. If type is "string", then
i. Let value be ? ToString(value).
d. If values is not undefined, then
i. If values does not contain an element equal to value, throw a RangeError exception.
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {
localeMatcher: 'bestfit' // not "best fit"
};
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'bestfit');
options.localeMatcher = 'look up';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'look up');
options.localeMatcher = null;
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'null');
options.localeMatcher = '';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'the empty string');
// The world could burn
options.localeMatcher = ['lookup', 'best fit'];
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'an array with the valid options is not necessarily valid');

View File

@ -0,0 +1,67 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption localeMatcher
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames, Symbol]
locale: [en]
---*/
var options = {
localeMatcher: {
toString() {
throw new Test262Error();
}
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from toString');
options.localeMatcher = {
toString: undefined,
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from valueOf');
options.localeMatcher = {
[Symbol.toPrimitive]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from ToPrimitive');
options.localeMatcher = Symbol();
assert.throws(TypeError, () => {
new Intl.DisplayNames('en', options);
}, 'symbol value');

View File

@ -0,0 +1,54 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Valid options for localeMatcher
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
// results for option values verified in the tests for resolvedOptions
var values = [
undefined,
'lookup',
'best fit'
];
for (let valid of values) {
let options = {
localeMatcher: valid
};
var obj = new Intl.DisplayNames('en', options);
assert(obj instanceof Intl.DisplayNames, `instanceof check - ${valid}`);
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${valid}`);
}

View File

@ -0,0 +1,26 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Throws TypeError if options is null
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
assert.throws(TypeError, () => {
new Intl.DisplayNames('en', null);
}, 'null');

View File

@ -0,0 +1,54 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Random options are not checked or used, including case sensitive
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {};
Object.defineProperty(options, 'fallBack', {
get() { throw new Test262Error(); }
});
Object.defineProperty(options, 'localematcher', {
get() { throw new Test262Error(); }
});
Object.defineProperty(options, 'locale-matcher', {
get() { throw new Test262Error(); }
});
Object.defineProperty(options, 'Type', {
get() { throw new Test262Error(); }
});
var obj = new Intl.DisplayNames('en', options);
assert(obj instanceof Intl.DisplayNames);
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype);

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption style
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {};
Object.defineProperty(options, 'style', {
get() { throw new Test262Error(); },
});
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
});

View File

@ -0,0 +1,75 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from an invalid style option
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
2. If value is not undefined, then
...
c. If type is "string", then
i. Let value be ? ToString(value).
d. If values is not undefined, then
i. If values does not contain an element equal to value, throw a RangeError exception.
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {
style: 'small'
};
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'small');
options.style = 'very long';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'very long');
options.style = 'full';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'full');
options.style = null;
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'null');
options.style = '';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'the empty string');
options.style = ['narrow', 'short', 'long'];
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'an array with the valid options is not necessarily valid');

View File

@ -0,0 +1,70 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption style
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames, Symbol]
locale: [en]
---*/
var options = {
style: {
toString() {
throw new Test262Error();
}
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from toString');
options.style = {
toString: undefined,
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from valueOf');
options.style = {
[Symbol.toPrimitive]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from ToPrimitive');
options.style = Symbol();
assert.throws(TypeError, () => {
new Intl.DisplayNames('en', options);
}, 'symbol value');

View File

@ -0,0 +1,55 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Valid options for localeMatcher
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
// results for option values verified in the tests for resolvedOptions
var values = [
undefined,
'narrow',
'short',
'long'
];
for (let valid of values) {
let options = {
style: valid
};
var obj = new Intl.DisplayNames('en', options);
assert(obj instanceof Intl.DisplayNames, `instanceof check - ${valid}`);
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${valid}`);
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption type
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {};
Object.defineProperty(options, 'type', {
get() { throw new Test262Error(); },
});
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
});

View File

@ -0,0 +1,79 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from an invalid type option
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
2. If value is not undefined, then
...
c. If type is "string", then
i. Let value be ? ToString(value).
d. If values is not undefined, then
i. If values does not contain an element equal to value, throw a RangeError exception.
...
features: [Intl.DisplayNames]
locale: [en]
---*/
var options = {
type: 'lang'
};
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'lang');
options.type = 'day-period';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'day-period, not dayPeriod');
options.type = 'weekDay';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'weekDay, not weekday');
options.type = null;
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'null');
options.type = '';
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'the empty string');
options.type = ['language', 'region', 'script', 'currency', 'weekday', 'month', 'quarter', 'dayPeriod', 'dateTimeField'];
assert.throws(RangeError, () => {
new Intl.DisplayNames('en', options);
}, 'an array with the valid options is not necessarily valid');

View File

@ -0,0 +1,74 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Return abrupt completion from GetOption type
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames, Symbol]
locale: [en]
---*/
var options = {
type: {
toString() {
throw new Test262Error();
}
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from toString');
options.type = {
toString: undefined,
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from valueOf');
options.type = {
[Symbol.toPrimitive]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new Intl.DisplayNames('en', options);
}, 'from ToPrimitive');
options.type = Symbol();
assert.throws(TypeError, () => {
new Intl.DisplayNames('en', options);
}, 'symbol value');

View File

@ -0,0 +1,61 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Valid options for localeMatcher
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
4. If options is undefined, then
a. Let options be ObjectCreate(null).
5. Else
a. Let options be ? ToObject(options).
...
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
...
11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
...
13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency", "weekday", "month", "quarter", "dayPeriod", "dateTimeField" », "language").
...
15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
...
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
...
features: [Intl.DisplayNames]
locale: [en]
---*/
// results for option values verified in the tests for resolvedOptions
var values = [
undefined,
'language',
'region',
'script',
'currency',
'weekday',
'month',
'quarter',
'dayPeriod',
'dateTimeField'
];
for (let valid of values) {
let options = {
type: valid
};
var obj = new Intl.DisplayNames('en', options);
assert(obj instanceof Intl.DisplayNames, `instanceof check - ${valid}`);
assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${valid}`);
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Property descriptor of Intl.DisplayNames
info: |
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]
features: [Intl.DisplayNames]
---*/
assert.sameValue(typeof Intl.DisplayNames, "function", "`typeof Intl.DisplayNames` is `'function'`");
verifyProperty(Intl, "DisplayNames", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,37 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: Default [[Prototype]] value derived from realm of the newTarget
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
« [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
...
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
...
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
3. Return ObjectCreate(proto, internalSlotsList).
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
...
3. Let proto be ? Get(constructor, "prototype").
4. If Type(proto) is not Object, then
a. Let realm be ? GetFunctionRealm(constructor).
b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
5. Return proto.
features: [Intl.DisplayNames, cross-realm, Reflect]
---*/
var other = $262.createRealm().global;
var C = new other.Function();
C.prototype = null;
var o = Reflect.construct(Intl.DisplayNames, [], C);
assert.sameValue(Object.getPrototypeOf(o), other.Intl.DisplayNames.prototype);

View File

@ -0,0 +1,13 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
The internal prototype of Intl.DisplayNames
features: [Intl.DisplayNames]
---*/
var proto = Object.getPrototypeOf(Intl.DisplayNames);
assert.sameValue(proto, Function.prototype);

View File

@ -0,0 +1,21 @@
// Copyright 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.DisplayNames.prototype-@@tostringtag
description: >
Property descriptor of DisplayNames.prototype[@@toStringTag]
info: |
The initial value of the @@toStringTag property is the string value "Intl.DisplayNames".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames, Symbol.toStringTag]
---*/
verifyProperty(Intl.DisplayNames.prototype, Symbol.toStringTag, {
value: "Intl.DisplayNames",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,20 @@
// Copyright 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames.prototype
description: >
Property descriptor of Intl.DisplayNames.prototype
info: |
The value of Intl.DisplayNames.prototype is %DisplayNamesPrototype%.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames]
---*/
verifyProperty(Intl.DisplayNames, "prototype", {
writable: false,
enumerable: false,
configurable: false,
});

View File

@ -0,0 +1,26 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames
description: >
Throws a TypeError if Intl.DisplayNames is called as a function.
info: |
Intl.DisplayNames ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
...
features: [Intl.DisplayNames]
---*/
assert.throws(TypeError, function() {
Intl.DisplayNames();
});
assert.throws(TypeError, function() {
Intl.DisplayNames('en');
});
assert.throws(TypeError, function() {
Intl.DisplayNames(['en']);
});