intl: add assertion to test that the result for default parameter

Add an assertion to the test for default parameters in Intl.NumberFormat's
method formatToParts checking that both the values are equal to the correct
result.
This commit is contained in:
Ujjwal Sharma 2018-09-27 03:37:44 +05:30 committed by Rick Waldron
parent 2d38eed77b
commit 41bf0ee344
1 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,6 @@
// Copyright (C) 2017 Josh Wolfe. All rights reserved. // Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-intl.numberformat.prototype.formattoparts esid: sec-intl.numberformat.prototype.formattoparts
description: Intl.NumberFormat.prototype.formatToParts called with no parameters description: Intl.NumberFormat.prototype.formatToParts called with no parameters
@ -11,12 +12,19 @@ info: |
var nf = new Intl.NumberFormat(); var nf = new Intl.NumberFormat();
// Example value: [{"type":"nan","value":"NaN"}] const implicit = nf.formatToParts();
var implicit = nf.formatToParts(); const explicit = nf.formatToParts(undefined);
var explicit = nf.formatToParts(undefined); const result = [{ type: 'nan', value: 'NaN' }];
assert(partsEquals(implicit, explicit), assert(
"formatToParts() should be equivalent to formatToParts(undefined)"); partsEquals(implicit, explicit),
'formatToParts() should be equivalent to formatToParts(undefined)'
);
assert(
partsEquals(implicit, result),
'Both implicit and explicit calls should have the correct result'
);
function partsEquals(parts1, parts2) { function partsEquals(parts1, parts2) {
if (parts1.length !== parts2.length) return false; if (parts1.length !== parts2.length) return false;