mirror of https://github.com/tc39/test262.git
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:
parent
2d38eed77b
commit
41bf0ee344
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue