From 0ead0130ea232138d1a0c8ccf26fdb888d45aa72 Mon Sep 17 00:00:00 2001 From: Rick Waldron <waldron.rick@gmail.com> Date: Tue, 2 Oct 2018 15:03:52 -0400 Subject: [PATCH] Intl.NumberFormat: cannot use assert.sameValue to compare object references. --- .../NumberFormat/constructor-default-value.js | 12 +++++++++--- .../NumberFormat/constructor-locales-toobject.js | 14 ++++++++++---- .../NumberFormat/constructor-options-toobject.js | 14 ++++++++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/test/intl402/NumberFormat/constructor-default-value.js b/test/intl402/NumberFormat/constructor-default-value.js index 00c6081a44..0b6d69c9bc 100644 --- a/test/intl402/NumberFormat/constructor-default-value.js +++ b/test/intl402/NumberFormat/constructor-default-value.js @@ -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); diff --git a/test/intl402/NumberFormat/constructor-locales-toobject.js b/test/intl402/NumberFormat/constructor-locales-toobject.js index 7799fcf66d..3d2625191b 100644 --- a/test/intl402/NumberFormat/constructor-locales-toobject.js +++ b/test/intl402/NumberFormat/constructor-locales-toobject.js @@ -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 diff --git a/test/intl402/NumberFormat/constructor-options-toobject.js b/test/intl402/NumberFormat/constructor-options-toobject.js index 7b1ed4e4be..43f5d10edf 100644 --- a/test/intl402/NumberFormat/constructor-options-toobject.js +++ b/test/intl402/NumberFormat/constructor-options-toobject.js @@ -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 -- GitLab