mirror of https://github.com/tc39/test262.git
Intl: Add coverage for meaningful @@toStringTag values (#2634)
* Add Intl.Collator tests * Add Intl.DateTimeFormat tests * Adjust Intl.NumberFormat tests * Add Intl.PluralRules tests * Remove now duplicated tests * Add "toString-changed-tag.js" tests
This commit is contained in:
parent
14478c9061
commit
ef12a8b11c
|
@ -1,13 +0,0 @@
|
|||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 10.4_a
|
||||
description: Tests that Intl.Collator instances have the specified properties.
|
||||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
var obj = new Intl.Collator();
|
||||
|
||||
var toStringValue = Object.prototype.toString.call(obj);
|
||||
assert.sameValue(toStringValue, "[object Object]", "Intl.Collator instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
|
|
@ -10,10 +10,6 @@ description: >
|
|||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.Collator.prototype), "[object Object]",
|
||||
"The [[Class]] internal property of a built-in non-function object must be " +
|
||||
"\"Object\".");
|
||||
|
||||
assert(Object.isExtensible(Intl.Collator.prototype), "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Intl.Collator.prototype), Object.prototype,
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.collator.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.Collator.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.Collator.prototype [ @@toStringTag ]
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
Object.defineProperty(Intl.Collator.prototype, Symbol.toStringTag, {
|
||||
value: "test262",
|
||||
});
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.Collator.prototype), "[object test262]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.Collator()), "[object test262]");
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.collator.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString doesn't special-case neither Intl.Collator instances nor its prototype.
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
delete Intl.Collator.prototype[Symbol.toStringTag];
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.Collator.prototype), "[object Object]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.Collator()), "[object Object]");
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.collator.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.Collator.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.Collator.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.Collator".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.Collator.prototype), "[object Intl.Collator]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.Collator()), "[object Intl.Collator]");
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.collator.prototype-@@tostringtag
|
||||
description: >
|
||||
Property descriptor of Intl.Collator.prototype[@@toStringTag].
|
||||
info: |
|
||||
Intl.Collator.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.Collator".
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.Collator.prototype, Symbol.toStringTag, {
|
||||
value: "Intl.Collator",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 12.4_a
|
||||
description: >
|
||||
Tests that Intl.DateTimeFormat instances have the specified
|
||||
properties.
|
||||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
var obj = new Intl.DateTimeFormat();
|
||||
|
||||
var toStringValue = Object.prototype.toString.call(obj);
|
||||
assert.sameValue(toStringValue, "[object Object]", "Intl.DateTimeFormat instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
|
|
@ -10,10 +10,6 @@ description: >
|
|||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Object]",
|
||||
"The [[Class]] internal property of a built-in non-function object must be " +
|
||||
"\"Object\".");
|
||||
|
||||
assert(Object.isExtensible(Intl.DateTimeFormat.prototype), "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Intl.DateTimeFormat.prototype), Object.prototype,
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.DateTimeFormat.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.DateTimeFormat.prototype [ @@toStringTag ]
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
Object.defineProperty(Intl.DateTimeFormat.prototype, Symbol.toStringTag, {
|
||||
value: "test262",
|
||||
});
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object test262]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.DateTimeFormat()), "[object test262]");
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString doesn't special-case neither Intl.DateTimeFormat instances nor its prototype.
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
delete Intl.DateTimeFormat.prototype[Symbol.toStringTag];
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Object]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.DateTimeFormat()), "[object Object]");
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.DateTimeFormat.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.DateTimeFormat.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.DateTimeFormat".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Intl.DateTimeFormat]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.DateTimeFormat()), "[object Intl.DateTimeFormat]");
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
description: >
|
||||
Property descriptor of Intl.DateTimeFormat.prototype[@@toStringTag].
|
||||
info: |
|
||||
Intl.DateTimeFormat.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.DateTimeFormat".
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.DateTimeFormat.prototype, Symbol.toStringTag, {
|
||||
value: "Intl.DateTimeFormat",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 11.4_a
|
||||
description: >
|
||||
Tests that Intl.NumberFormat instances have the specified
|
||||
properties.
|
||||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
var obj = new Intl.NumberFormat();
|
||||
|
||||
var toStringValue = Object.prototype.toString.call(obj);
|
||||
assert.sameValue(toStringValue, "[object Object]", "Intl.NumberFormat instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
|
|
@ -10,10 +10,6 @@ description: >
|
|||
author: Norbert Lindenberg
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Object]",
|
||||
"The [[Class]] internal property of a built-in non-function object must be " +
|
||||
"\"Object\".");
|
||||
|
||||
assert(Object.isExtensible(Intl.NumberFormat.prototype), "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Intl.NumberFormat.prototype), Object.prototype,
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
/*---
|
||||
esid: sec-intl.numberformat.prototype-@@tostringtag
|
||||
description: >
|
||||
Check that the initial value of the property is "Object" and that any changes
|
||||
Check that the initial value of the property is "Intl.NumberFormat" and that any changes
|
||||
made by reconfiguring are reflected.
|
||||
---*/
|
||||
|
||||
assert.sameValue(Intl.NumberFormat.prototype[Symbol.toStringTag], 'Object');
|
||||
assert.sameValue(Intl.NumberFormat.prototype[Symbol.toStringTag], 'Intl.NumberFormat');
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Intl.NumberFormat()),
|
||||
'[object Object]'
|
||||
'[object Intl.NumberFormat]'
|
||||
);
|
||||
|
||||
Object.defineProperty(Intl.NumberFormat.prototype, Symbol.toStringTag, {
|
||||
|
@ -23,3 +23,11 @@ assert.sameValue(
|
|||
Object.prototype.toString.call(new Intl.NumberFormat()),
|
||||
'[object Alpha]'
|
||||
);
|
||||
|
||||
delete Intl.NumberFormat.prototype[Symbol.toStringTag];
|
||||
|
||||
assert.sameValue(Intl.NumberFormat.prototype[Symbol.toStringTag], undefined);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Intl.NumberFormat()),
|
||||
'[object Object]'
|
||||
);
|
||||
|
|
|
@ -9,7 +9,7 @@ includes: [propertyHelper.js]
|
|||
---*/
|
||||
|
||||
verifyProperty(Intl.NumberFormat.prototype, Symbol.toStringTag, {
|
||||
value: 'Object',
|
||||
value: 'Intl.NumberFormat',
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
|
|
|
@ -10,10 +10,6 @@ description: >
|
|||
author: Zibi Braniecki
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Object]",
|
||||
"The [[Class]] internal property of a built-in non-function object must be " +
|
||||
"\"Object\".");
|
||||
|
||||
assert(Object.isExtensible(Intl.PluralRules.prototype), "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Intl.PluralRules.prototype), Object.prototype,
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.pluralrules.prototype-tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.PluralRules.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.PluralRules.prototype [ @@toStringTag ]
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
Object.defineProperty(Intl.PluralRules.prototype, Symbol.toStringTag, {
|
||||
value: "test262",
|
||||
});
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object test262]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object test262]");
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.pluralrules.prototype-tostringtag
|
||||
description: >
|
||||
Object.prototype.toString doesn't special-case neither Intl.PluralRules instances nor its prototype.
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
delete Intl.PluralRules.prototype[Symbol.toStringTag];
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Object]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object Object]");
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.pluralrules.prototype-tostringtag
|
||||
description: >
|
||||
Object.prototype.toString utilizes Intl.PluralRules.prototype[@@toStringTag].
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
[...]
|
||||
14. Else, let builtinTag be "Object".
|
||||
15. Let tag be ? Get(O, @@toStringTag).
|
||||
16. If Type(tag) is not String, set tag to builtinTag.
|
||||
17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
|
||||
Intl.PluralRules.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.PluralRules".
|
||||
features: [Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Intl.PluralRules]");
|
||||
assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object Intl.PluralRules]");
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.pluralrules.prototype-tostringtag
|
||||
description: >
|
||||
Property descriptor of Intl.PluralRules.prototype[@@toStringTag].
|
||||
info: |
|
||||
Intl.PluralRules.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "Intl.PluralRules".
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
features: [Symbol.toStringTag]
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.PluralRules.prototype, Symbol.toStringTag, {
|
||||
value: "Intl.PluralRules",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
Loading…
Reference in New Issue