From a4501647e3bed1a262c2ba4f7ac7466252debe50 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 8 May 2025 17:59:09 -0400 Subject: [PATCH] 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 --- .../Locale/constructor-getter-order.js | 116 +++++------------- 1 file changed, 31 insertions(+), 85 deletions(-) diff --git a/test/intl402/Locale/constructor-getter-order.js b/test/intl402/Locale/constructor-getter-order.js index f4635b1d6a..35a437384c 100644 --- a/test/intl402/Locale/constructor-getter-order.js +++ b/test/intl402/Locale/constructor-getter-order.js @@ -11,102 +11,48 @@ includes: [compareArray.js] ---*/ const order = []; +function handleGet(name, value) { + order.push("get " + name); + return { + toString() { + order.push("toString " + name); + return value; + } + }; +} new Intl.Locale( { 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() { - order.push("get calendar"); - return { - toString() { - order.push("toString calendar"); - return "gregory"; - } - } + return handleGet("calendar", "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() { - order.push("get caseFirst"); - return { - toString() { - order.push("toString caseFirst"); - return "upper"; - } - } + return handleGet("caseFirst", "upper"); + }, + get collation() { + return handleGet("collation", "zhuyin"); + }, + get hourCycle() { + return handleGet("hourCycle", "h24"); + }, + get language() { + return handleGet("language", "de"); + }, + get numberingSystem() { + return handleGet("numberingSystem", "latn"); }, - get numeric() { order.push("get numeric"); return false; }, - - get numberingSystem() { - order.push("get numberingSystem"); - return { - toString() { - order.push("toString numberingSystem"); - return "latn"; - } - } + get region() { + return handleGet("region", "DE"); + }, + get script() { + return handleGet("script", "Latn"); + }, + get variants() { + return handleGet("variants", "fonipa-1996"); }, } );