Debian Codegraph @

js/src/tests/test262/intl402/PluralRules/constructor-option-read-order.js

raw
1 // Copyright 2023 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-initializepluralrules
6 description: Checks the order of option read.
7 features: [Intl.NumberFormat-v3]
8 includes: [compareArray.js]
9 ---*/
10
11 let optionKeys = [
12 // Inside InitializePluralRules
13 "localeMatcher",
14 "type",
15 "notation",
16 // Inside SetNumberFormatDigitOptions
17 "minimumIntegerDigits",
18 "minimumFractionDigits",
19 "maximumFractionDigits",
20 "minimumSignificantDigits",
21 "maximumSignificantDigits",
22 "roundingIncrement",
23 "roundingMode",
24 "roundingPriority",
25 "trailingZeroDisplay",
26 // End of SetNumberFormatDigitOptions
27 ];
28
29 // Use getters to track the order of reading known properties.
30 // TODO: Should we use a Proxy to detect *unexpected* property reads?
31 let reads = new Array();
32 let options = {};
33 optionKeys.forEach((key) => {
34 Object.defineProperty(options, key, {
35 get() {
36 reads.push(key);
37 return undefined;
38 },
39 });
40 });
41 new Intl.PluralRules(undefined, options);
42 assert.compareArray(reads, optionKeys, "Intl.PluralRules options read order");
43
44 reportCompare(0, 0);