Improve NumberFormat and DateTimeFormat tests for OrdinaryHasInstance

This commit is contained in:
Ms2ger 2022-12-02 15:59:32 +01:00 committed by Philip Chimento
parent 58b3321dba
commit 6fcebf2f85
6 changed files with 54 additions and 18 deletions

View File

@ -2,11 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.resolvedOptions
esid: sec-intl-datetimeformat-constructor
description: >
Tests that Intl.DateTimeFormat.prototype.resolvedOptions calls
Tests that the Intl.DateTimeFormat constructor calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
ChainDateTimeFormat ( dateTimeFormat, newTarget, this )
1. If newTarget is undefined and ? OrdinaryHasInstance(%DateTimeFormat%, this) is true, then
a. Perform ? DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor{
[[Value]]: dateTimeFormat, [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: false }).
b. Return this.
---*/
Object.defineProperty(Intl.DateTimeFormat, Symbol.hasInstance, {

View File

@ -2,17 +2,22 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.resolvedOptions
esid: sec-intl.datetimeformat.prototype.format
description: >
Tests that Intl.DateTimeFormat.prototype.resolvedOptions calls
Tests that Intl.DateTimeFormat.prototype.format calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
UnwrapDateTimeFormat ( dtf )
2. If dtf does not have an [[InitializedDateTimeFormat]] internal slot and
? OrdinaryHasInstance(%DateTimeFormat%, dtf) is true, then
a. Return ? Get(dtf, %Intl%.[[FallbackSymbol]]).
---*/
const dtf = new Intl.DateTimeFormat();
const dtf = Object.create(Intl.DateTimeFormat.prototype);
Object.defineProperty(Intl.DateTimeFormat, Symbol.hasInstance, {
get() { throw new Test262Error(); }
});
dtf.format;
assert.throws(TypeError, () => dtf.format);

View File

@ -2,17 +2,22 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.resolvedOptions
esid: sec-intl.datetimeformat.prototype.resolvedoptions
description: >
Tests that Intl.DateTimeFormat.prototype.resolvedOptions calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
UnwrapDateTimeFormat ( dtf )
2. If dtf does not have an [[InitializedDateTimeFormat]] internal slot and
? OrdinaryHasInstance(%DateTimeFormat%, dtf) is true, then
a. Return ? Get(dtf, %Intl%.[[FallbackSymbol]]).
---*/
const dtf = new Intl.DateTimeFormat();
const dtf = Object.create(Intl.DateTimeFormat.prototype);
Object.defineProperty(Intl.DateTimeFormat, Symbol.hasInstance, {
get() { throw new Test262Error(); }
});
dtf.resolvedOptions();
assert.throws(TypeError, () => dtf.resolvedOptions());

View File

@ -2,11 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.NumberFormat.prototype.resolvedOptions
esid: sec-intl-numberformat-constructor
description: >
Tests that Intl.NumberFormat.prototype.resolvedOptions calls
Tests that the Intl.NumberFormat constructor calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
ChainNumberFormat ( numberFormat, newTarget, this )
1. If newTarget is undefined and ? OrdinaryHasInstance(%NumberFormat%, this) is true, then
a. Perform ? DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor{
[[Value]]: numberFormat, [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: false }).
b. Return this.
---*/
Object.defineProperty(Intl.NumberFormat, Symbol.hasInstance, {

View File

@ -2,17 +2,23 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.NumberFormat.prototype.resolvedOptions
esid: sec-intl.numberformat.prototype.format
description: >
Tests that Intl.NumberFormat.prototype.resolvedOptions calls
Tests that Intl.NumberFormat.prototype.format calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
UnwrapNumberFormat ( nf )
2. If nf does not have an [[InitializedNumberFormat]] internal slot and
? OrdinaryHasInstance(%NumberFormat%, nf) is true, then
a. Return ? Get(nf, %Intl%.[[FallbackSymbol]]).
---*/
const nf = new Intl.NumberFormat();
const nf = Object.create(Intl.NumberFormat.prototype);
Object.defineProperty(Intl.NumberFormat, Symbol.hasInstance, {
get() { throw new Test262Error(); }
});
nf.format;
assert.throws(TypeError, () => nf.format);

View File

@ -2,17 +2,23 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.NumberFormat.prototype.resolvedOptions
esid: sec-intl.numberformat.prototype.resolvedoptions
description: >
Tests that Intl.NumberFormat.prototype.resolvedOptions calls
OrdinaryHasInstance instead of the instanceof operator which includes a
Symbol.hasInstance lookup and call among other things.
info: >
UnwrapNumberFormat ( nf )
2. If nf does not have an [[InitializedNumberFormat]] internal slot and
? OrdinaryHasInstance(%NumberFormat%, nf) is true, then
a. Return ? Get(nf, %Intl%.[[FallbackSymbol]]).
---*/
const nf = new Intl.NumberFormat();
const nf = Object.create(Intl.NumberFormat.prototype);
Object.defineProperty(Intl.NumberFormat, Symbol.hasInstance, {
get() { throw new Test262Error(); }
});
nf.resolvedOptions();
assert.throws(TypeError, () => nf.resolvedOptions());