Debian Codegraph @

js/src/tests/non262/Intl/supportedValuesOf-unit.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
2
3 const units = Intl.supportedValuesOf("unit");
4
5 assertEq(new Set(units).size, units.length, "No duplicates are present");
6 assertEqArray(units, [...units].sort(), "The list is sorted");
7
8 const unitRE = /^[a-z]+(-[a-z]+)*$/;
9 for (let unit of units) {
10 assertEq(unitRE.test(unit), true, `${unit} is ASCII lower-case, separated by hyphens`);
11 assertEq(unit.includes("-per-"), false, `${unit} is a simple unit identifier`);
12 }
13
14 for (let unit of units) {
15 let obj = new Intl.NumberFormat("en", {style: "unit", unit});
16 assertEq(obj.resolvedOptions().unit, unit, `${unit} is supported by NumberFormat`);
17 }
18
19 if (typeof reportCompare === "function")
20 reportCompare(true, true);