Improve test/intl402/Locale/constructor-getter-order.js

* Add a helper for concision
* Specify properties in a different order than the one used for reading
This commit is contained in:
Richard Gibson 2025-05-08 17:59:09 -04:00 committed by Ms2ger
parent c2bfc5bdcd
commit a4501647e3

View File

@ -11,102 +11,48 @@ includes: [compareArray.js]
---*/ ---*/
const order = []; const order = [];
function handleGet(name, value) {
order.push("get " + name);
return {
toString() {
order.push("toString " + name);
return value;
}
};
}
new Intl.Locale( new Intl.Locale(
{ toString() { order.push("tag toString"); return "en"; } }, { toString() { order.push("tag toString"); return "en"; } },
{ {
get language() {
order.push("get language");
return {
toString() {
order.push("toString language");
return "de";
}
}
},
get script() {
order.push("get script");
return {
toString() {
order.push("toString script");
return "Latn";
}
}
},
get region() {
order.push("get region");
return {
toString() {
order.push("toString region");
return "DE";
}
}
},
get variants() {
order.push("get variants");
return {
toString() {
order.push("toString variants");
return "fonipa-1996";
}
}
},
get calendar() { get calendar() {
order.push("get calendar"); return handleGet("calendar", "gregory");
return {
toString() {
order.push("toString calendar");
return "gregory";
}
}
}, },
get collation() {
order.push("get collation");
return {
toString() {
order.push("toString collation");
return "zhuyin";
}
}
},
get hourCycle() {
order.push("get hourCycle");
return {
toString() {
order.push("toString hourCycle");
return "h24";
}
}
},
get caseFirst() { get caseFirst() {
order.push("get caseFirst"); return handleGet("caseFirst", "upper");
return { },
toString() { get collation() {
order.push("toString caseFirst"); return handleGet("collation", "zhuyin");
return "upper"; },
} get hourCycle() {
} return handleGet("hourCycle", "h24");
},
get language() {
return handleGet("language", "de");
},
get numberingSystem() {
return handleGet("numberingSystem", "latn");
}, },
get numeric() { get numeric() {
order.push("get numeric"); order.push("get numeric");
return false; return false;
}, },
get region() {
get numberingSystem() { return handleGet("region", "DE");
order.push("get numberingSystem"); },
return { get script() {
toString() { return handleGet("script", "Latn");
order.push("toString numberingSystem"); },
return "latn"; get variants() {
} return handleGet("variants", "fonipa-1996");
}
}, },
} }
); );