constructor-option-read-order.js (1220B)
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-Intl.DurationFormat 6 description: Checks the order of option read. 7 features: [Intl.DurationFormat] 8 includes: [compareArray.js] 9 ---*/ 10 11 let optionKeys = Object.keys((new Intl.DurationFormat()).resolvedOptions()); 12 let opt = {}; 13 let readKeys = new Array(); 14 // For each item returned by resolvedOptions of default, add a getter 15 // to track the reading order. 16 optionKeys.forEach((property) => 17 Object.defineProperty(opt, property, { 18 get() { 19 readKeys[readKeys.length] = property; 20 return undefined; 21 }, 22 })); 23 let p = new Intl.DurationFormat(undefined, opt); 24 assert.compareArray( 25 readKeys, 26 ['numberingSystem', 27 'style', 28 'years', 29 'yearsDisplay', 30 'months', 31 'monthsDisplay', 32 'weeks', 33 'weeksDisplay', 34 'days', 35 'daysDisplay', 36 'hours', 37 'hoursDisplay', 38 'minutes', 39 'minutesDisplay', 40 'seconds', 41 'secondsDisplay', 42 'milliseconds', 43 'millisecondsDisplay', 44 'microseconds', 45 'microsecondsDisplay', 46 'nanoseconds', 47 'nanosecondsDisplay']); 48 49 reportCompare(0, 0);