blob: 71a8624c9707ef80068165be313255d0c49ef9bd [file] [log] [blame]
This test checks the behavior of Intl.NumberFormat.prototype.formatToParts as described in the ECMAScript Internationalization API Specification.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Intl.NumberFormat.prototype.formatToParts is an instance of Function
PASS Intl.NumberFormat.prototype.formatToParts.length is 1
PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'formatToParts').writable is true
PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'formatToParts').enumerable is false
PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'formatToParts').configurable is true
PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'formatToParts').get is undefined
PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'formatToParts').set is undefined
PASS JSON.stringify(Intl.NumberFormat('en').formatToParts(-Infinity)) is JSON.stringify([
{type:"minusSign",value:"-"},
{type:"infinity",value:"∞"}
])
PASS JSON.stringify(Intl.NumberFormat('en').formatToParts('one')) is JSON.stringify([
{type:"nan",value:"NaN"}
])
PASS JSON.stringify(Intl.NumberFormat('en-US', {style:'percent'}).formatToParts(1)) is JSON.stringify([
{type:"integer",value:"100"},
{type:"percentSign",value:"%"}
])
PASS JSON.stringify(
Intl.NumberFormat("pt-BR-u-nu-fullwide", {
minimumFractionDigits: "3", style: "currency", currency: "USD", currencyDisplay: "name"
}).formatToParts(21069933563725.1)
) is JSON.stringify([
{type:"integer",value:"21"},
{type:"group",value:"."},
{type:"integer",value:"069"},
{type:"group",value:"."},
{type:"integer",value:"933"},
{type:"group",value:"."},
{type:"integer",value:"563"},
{type:"group",value:"."},
{type:"integer",value:"725"},
{type:"decimal",value:","},
{type:"fraction",value:"100"},
{type:"literal",value:" "},
{type:"currency",value:"Dólares americanos"},
])
PASS +Intl.NumberFormat('en-US', { useGrouping: false }).formatToParts(Number.MAX_SAFE_INTEGER)[0].value is Number.MAX_SAFE_INTEGER
PASS Intl.NumberFormat('en-US', { useGrouping: false }).formatToParts(Number.MAX_VALUE).length is 1
PASS Intl.NumberFormat('en-US', { useGrouping: false }).formatToParts(Number.MAX_VALUE)[0].value.length is 309
PASS Intl.NumberFormat('en-US').formatToParts(Number.MAX_VALUE).length is 205
PASS successfullyParsed is true
TEST COMPLETE