Change the unit in the NumberFormat unit tests.

This ensures https://github.com/tc39/proposal-unified-intl-numberformat/pull/93 is covered.
This commit is contained in:
Ms2ger 2020-02-04 16:56:51 +01:00 committed by Rick Waldron
parent 6ecaf1f065
commit 1f7f5ef23c
10 changed files with 190 additions and 190 deletions

View File

@ -13,56 +13,56 @@ const tests = [
[ [
-987, -987,
{ {
"short": "-987 m", "short": "-987 km/h",
"narrow": "-987 m", "narrow": "-987 km/h",
"long": "-987 Meter", "long": "-987 Kilometer pro Stunde",
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "-0,001 m", "short": "-0,001 km/h",
"narrow": "-0,001 m", "narrow": "-0,001 km/h",
"long": "-0,001 Meter", "long": "-0,001 Kilometer pro Stunde",
} }
], ],
[ [
-0, -0,
{ {
"short": "-0 m", "short": "-0 km/h",
"narrow": "-0 m", "narrow": "-0 km/h",
"long": "-0 Meter", "long": "-0 Kilometer pro Stunde",
} }
], ],
[ [
0, 0,
{ {
"short": "0 m", "short": "0 km/h",
"narrow": "0 m", "narrow": "0 km/h",
"long": "0 Meter", "long": "0 Kilometer pro Stunde",
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "0,001 m", "short": "0,001 km/h",
"narrow": "0,001 m", "narrow": "0,001 km/h",
"long": "0,001 Meter", "long": "0,001 Kilometer pro Stunde",
} }
], ],
[ [
987, 987,
{ {
"short": "987 m", "short": "987 km/h",
"narrow": "987 m", "narrow": "987 km/h",
"long": "987 Meter", "long": "987 Kilometer pro Stunde",
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("de-DE", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("de-DE", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
assert.sameValue(nf.format(number), expected); assert.sameValue(nf.format(number), expected);
} }
} }

View File

@ -13,56 +13,56 @@ const tests = [
[ [
-987, -987,
{ {
"short": "-987 m", "short": "-987 km/h",
"narrow": "-987m", "narrow": "-987km/h",
"long": "-987 meters", "long": "-987 kilometers per hour",
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "-0.001 m", "short": "-0.001 km/h",
"narrow": "-0.001m", "narrow": "-0.001km/h",
"long": "-0.001 meters", "long": "-0.001 kilometers per hour",
} }
], ],
[ [
-0, -0,
{ {
"short": "-0 m", "short": "-0 km/h",
"narrow": "-0m", "narrow": "-0km/h",
"long": "-0 meters", "long": "-0 kilometers per hour",
} }
], ],
[ [
0, 0,
{ {
"short": "0 m", "short": "0 km/h",
"narrow": "0m", "narrow": "0km/h",
"long": "0 meters", "long": "0 kilometers per hour",
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "0.001 m", "short": "0.001 km/h",
"narrow": "0.001m", "narrow": "0.001km/h",
"long": "0.001 meters", "long": "0.001 kilometers per hour",
} }
], ],
[ [
987, 987,
{ {
"short": "987 m", "short": "987 km/h",
"narrow": "987m", "narrow": "987km/h",
"long": "987 meters", "long": "987 kilometers per hour",
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("en-US", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("en-US", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
assert.sameValue(nf.format(number), expected); assert.sameValue(nf.format(number), expected);
} }
} }

View File

@ -13,56 +13,56 @@ const tests = [
[ [
-987, -987,
{ {
"short": "-987 m", "short": "-987 km/h",
"narrow": "-987m", "narrow": "-987km/h",
"long": "-987 メートル", "long": "時速 -987 キロメートル",
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "-0.001 m", "short": "-0.001 km/h",
"narrow": "-0.001m", "narrow": "-0.001km/h",
"long": "-0.001 メートル", "long": "時速 -0.001 キロメートル",
} }
], ],
[ [
-0, -0,
{ {
"short": "-0 m", "short": "-0 km/h",
"narrow": "-0m", "narrow": "-0km/h",
"long": "-0 メートル", "long": "時速 -0 キロメートル",
} }
], ],
[ [
0, 0,
{ {
"short": "0 m", "short": "0 km/h",
"narrow": "0m", "narrow": "0km/h",
"long": "0 メートル", "long": "時速 0 キロメートル",
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "0.001 m", "short": "0.001 km/h",
"narrow": "0.001m", "narrow": "0.001km/h",
"long": "0.001 メートル", "long": "時速 0.001 キロメートル",
} }
], ],
[ [
987, 987,
{ {
"short": "987 m", "short": "987 km/h",
"narrow": "987m", "narrow": "987km/h",
"long": "987 メートル", "long": "時速 987 キロメートル",
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("ja-JP", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("ja-JP", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
assert.sameValue(nf.format(number), expected); assert.sameValue(nf.format(number), expected);
} }
} }

View File

@ -13,56 +13,56 @@ const tests = [
[ [
-987, -987,
{ {
"short": "-987m", "short": "-987km/h",
"narrow": "-987m", "narrow": "-987km/h",
"long": "-987미터", "long": "시속 -987킬로미터",
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "-0.001m", "short": "-0.001km/h",
"narrow": "-0.001m", "narrow": "-0.001km/h",
"long": "-0.001미터", "long": "시속 -0.001킬로미터",
} }
], ],
[ [
-0, -0,
{ {
"short": "-0m", "short": "-0km/h",
"narrow": "-0m", "narrow": "-0km/h",
"long": "-0미터", "long": "시속 -0킬로미터",
} }
], ],
[ [
0, 0,
{ {
"short": "0m", "short": "0km/h",
"narrow": "0m", "narrow": "0km/h",
"long": "0미터", "long": "시속 0킬로미터",
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "0.001m", "short": "0.001km/h",
"narrow": "0.001m", "narrow": "0.001km/h",
"long": "0.001미터", "long": "시속 0.001킬로미터",
} }
], ],
[ [
987, 987,
{ {
"short": "987m", "short": "987km/h",
"narrow": "987m", "narrow": "987km/h",
"long": "987미터", "long": "시속 987킬로미터",
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("ko-KR", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("ko-KR", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
assert.sameValue(nf.format(number), expected); assert.sameValue(nf.format(number), expected);
} }
} }

View File

@ -13,56 +13,56 @@ const tests = [
[ [
-987, -987,
{ {
"short": "-987 公", "short": "-987 公里/小時",
"narrow": "-987公", "narrow": "-987公里/小時",
"long": "-987 公尺", "long": "每小時 -987 公里",
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "-0.001 公", "short": "-0.001 公里/小時",
"narrow": "-0.001公", "narrow": "-0.001公里/小時",
"long": "-0.001 公尺", "long": "每小時 -0.001 公里",
} }
], ],
[ [
-0, -0,
{ {
"short": "-0 公", "short": "-0 公里/小時",
"narrow": "-0公", "narrow": "-0公里/小時",
"long": "-0 公尺", "long": "每小時 -0 公里",
} }
], ],
[ [
0, 0,
{ {
"short": "0 公", "short": "0 公里/小時",
"narrow": "0公", "narrow": "0公里/小時",
"long": "0 公尺", "long": "每小時 0 公里",
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "0.001 公", "short": "0.001 公里/小時",
"narrow": "0.001公", "narrow": "0.001公里/小時",
"long": "0.001 公尺", "long": "每小時 0.001 公里",
} }
], ],
[ [
987, 987,
{ {
"short": "987 公", "short": "987 公里/小時",
"narrow": "987公", "narrow": "987公里/小時",
"long": "987 公尺", "long": "每小時 987 公里",
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("zh-TW", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("zh-TW", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
assert.sameValue(nf.format(number), expected); assert.sameValue(nf.format(number), expected);
} }
} }

View File

@ -24,73 +24,73 @@ const tests = [
-987, -987,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
[ [
-0, -0,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
[ [
0, 0,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"integer","value":"0"},{"type":"decimal","value":","},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
[ [
987, 987,
{ {
"short": "short":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"Meter"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"Kilometer pro Stunde"}],
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("de-DE", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("de-DE", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
verifyFormatParts(nf.formatToParts(number), expected); verifyFormatParts(nf.formatToParts(number), expected);
} }
} }

View File

@ -24,73 +24,73 @@ const tests = [
-987, -987,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
[ [
-0, -0,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
[ [
0, 0,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
[ [
987, 987,
{ {
"short": "short":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"meters"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"kilometers per hour"}],
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("en-US", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("en-US", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
verifyFormatParts(nf.formatToParts(number), expected); verifyFormatParts(nf.formatToParts(number), expected);
} }
} }

View File

@ -24,73 +24,73 @@ const tests = [
-987, -987,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
[ [
-0, -0,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
[ [
0, 0,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
[ [
987, 987,
{ {
"short": "short":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"メートル"}], [{"type":"unit","value":"時速"},{"type":"literal","value":" "},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"キロメートル"}],
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("ja-JP", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("ja-JP", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
verifyFormatParts(nf.formatToParts(number), expected); verifyFormatParts(nf.formatToParts(number), expected);
} }
} }

View File

@ -24,73 +24,73 @@ const tests = [
-987, -987,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"킬로미터"}],
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"킬로미터"}],
} }
], ],
[ [
-0, -0,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"킬로미터"}],
} }
], ],
[ [
0, 0,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"unit","value":"킬로미터"}],
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"m"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"킬로미터"}],
} }
], ],
[ [
987, 987,
{ {
"short": "short":
[{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"narrow": "narrow":
[{"type":"integer","value":"987"},{"type":"unit","value":"m"}], [{"type":"integer","value":"987"},{"type":"unit","value":"km/h"}],
"long": "long":
[{"type":"integer","value":"987"},{"type":"unit","value":"미터"}], [{"type":"unit","value":"시속"},{"type":"literal","value":" "},{"type":"integer","value":"987"},{"type":"unit","value":"킬로미터"}],
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("ko-KR", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("ko-KR", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
verifyFormatParts(nf.formatToParts(number), expected); verifyFormatParts(nf.formatToParts(number), expected);
} }
} }

View File

@ -24,73 +24,73 @@ const tests = [
-987, -987,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
[ [
-0.001, -0.001,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
[ [
-0, -0,
{ {
"short": "short":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"公"}], [{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"minusSign","value":"-"},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
[ [
0, 0,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"unit","value":"公"}], [{"type":"integer","value":"0"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
[ [
0.001, 0.001,
{ {
"short": "short":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"公"}], [{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"integer","value":"0"},{"type":"decimal","value":"."},{"type":"fraction","value":"001"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
[ [
987, 987,
{ {
"short": "short":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公里/小時"}],
"narrow": "narrow":
[{"type":"integer","value":"987"},{"type":"unit","value":"公"}], [{"type":"integer","value":"987"},{"type":"unit","value":"公里/小時"}],
"long": "long":
[{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}], [{"type":"unit","value":"每小時"},{"type":"literal","value":" "},{"type":"integer","value":"987"},{"type":"literal","value":" "},{"type":"unit","value":"公"}],
} }
], ],
]; ];
for (const [number, expectedData] of tests) { for (const [number, expectedData] of tests) {
for (const [unitDisplay, expected] of Object.entries(expectedData)) { for (const [unitDisplay, expected] of Object.entries(expectedData)) {
const nf = new Intl.NumberFormat("zh-TW", { style: "unit", unit: "meter", unitDisplay }); const nf = new Intl.NumberFormat("zh-TW", { style: "unit", unit: "kilometer-per-hour", unitDisplay });
verifyFormatParts(nf.formatToParts(number), expected); verifyFormatParts(nf.formatToParts(number), expected);
} }
} }