Intl.NumberFormat: cannot use assert.sameValue to compare object references.

This commit is contained in:
Rick Waldron 2018-10-02 15:03:52 -04:00
parent bba2429cad
commit 0ead0130ea
3 changed files with 29 additions and 11 deletions

View File

@ -8,7 +8,13 @@ description: >
values for its arguments (locales and options).
---*/
const actual = new Intl.NumberFormat();
const expected = new Intl.NumberFormat([], { __proto__: null });
const actual = new Intl.NumberFormat().resolvedOptions();
const expected = new Intl.NumberFormat([], { __proto__: null }).resolvedOptions();
assert.sameValue(actual.resolvedOptions(), expected.resolvedOptions());
assert.sameValue(actual.locale, expected.locale);
assert.sameValue(actual.minimumIntegerDigits, expected.minimumIntegerDigits);
assert.sameValue(actual.minimumFractionDigits, expected.minimumFractionDigits);
assert.sameValue(actual.maximumFractionDigits, expected.maximumFractionDigits);
assert.sameValue(actual.numberingSystem, expected.numberingSystem);
assert.sameValue(actual.style, expected.style);
assert.sameValue(actual.useGrouping, expected.useGrouping);

View File

@ -22,10 +22,16 @@ const toObjectResults = [
// Test if ToObject is used to convert primitives to Objects.
toObjectResults.forEach(pair => {
const [value, result] = pair;
assert.sameValue(
new Intl.NumberFormat(value).resolvedOptions(),
new Intl.NumberFormat(result).resolvedOptions()
);
const actual = new Intl.NumberFormat(value).resolvedOptions();
const expected = new Intl.NumberFormat(result).resolvedOptions()
assert.sameValue(actual.locale, expected.locale);
assert.sameValue(actual.minimumIntegerDigits, expected.minimumIntegerDigits);
assert.sameValue(actual.minimumFractionDigits, expected.minimumFractionDigits);
assert.sameValue(actual.maximumFractionDigits, expected.maximumFractionDigits);
assert.sameValue(actual.numberingSystem, expected.numberingSystem);
assert.sameValue(actual.style, expected.style);
assert.sameValue(actual.useGrouping, expected.useGrouping);
});
// ToObject throws a TypeError for undefined and null, but it's not called

View File

@ -23,10 +23,16 @@ const toObjectResults = [
// Test if ToObject is used to convert primitives to Objects.
toObjectResults.forEach(pair => {
const [value, result] = pair;
assert.sameValue(
new Intl.NumberFormat(['en-US'], value).resolvedOptions(),
new Intl.NumberFormat(['en-US'], result).resolvedOptions()
);
const actual = new Intl.NumberFormat(['en-US'], value).resolvedOptions();
const expected = new Intl.NumberFormat(['en-US'], result).resolvedOptions();
assert.sameValue(actual.locale, expected.locale);
assert.sameValue(actual.minimumIntegerDigits, expected.minimumIntegerDigits);
assert.sameValue(actual.minimumFractionDigits, expected.minimumFractionDigits);
assert.sameValue(actual.maximumFractionDigits, expected.maximumFractionDigits);
assert.sameValue(actual.numberingSystem, expected.numberingSystem);
assert.sameValue(actual.style, expected.style);
assert.sameValue(actual.useGrouping, expected.useGrouping);
});
// ToObject throws a TypeError for undefined and null, but it's not called