From 261579694efe1aae10cb81e10bffc7e693a7af85 Mon Sep 17 00:00:00 2001 From: Josh Wolfe <jwolfe@igalia.com> Date: Fri, 15 Sep 2017 10:08:53 -0700 Subject: [PATCH] NumberFormat formatToParts with no arguments --- .../formatToParts/default-parameter.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js diff --git a/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js b/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js new file mode 100644 index 0000000000..408694c48c --- /dev/null +++ b/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: #sec-intl.numberformat.prototype.formattoparts +description: Intl.NumberFormat.prototype.formatToParts called with no parameters +info: > + Intl.NumberFormat.prototype.formatToParts ([ value ]) + + 3. If value is not provided, let value be undefined. +---*/ + +var nf = new Intl.NumberFormat(); + +// Example value: [{"type":"nan","value":"NaN"}] +var implicit = nf.formatToParts(); +var explicit = nf.formatToParts(undefined); + +assert(partsEquals(implicit, explicit), + "formatToParts() should be equivalent to formatToParts(undefined)"); + +function partsEquals(parts1, parts2) { + if (parts1.length !== parts2.length) return false; + for (var i = 0; i < parts1.length; i++) { + var part1 = parts1[i]; + var part2 = parts2[i]; + if (part1.type !== part2.type) return false; + if (part1.value !== part2.value) return false; + } + return true; +} -- GitLab