constructor-locales-get-tostring.js (948B)
1 // Copyright (C) 2018 Ujjwal Sharma. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-initializenumberformat 6 description: > 7 Tests that Get(O, P) and ToString(arg) are properly called within the 8 constructor for Intl.NumberFormat 9 info: | 10 9.2.1 CanonicalizeLocaleList ( locales ) 11 12 5. Let len be ? ToLength(? Get(O, "length")). 13 14 7.a. Let Pk be ToString(k). 15 16 7.c.i. Let kValue be ? Get(O, Pk). 17 ---*/ 18 19 const locales = { 20 length: 8, 21 1: 'en-US', 22 3: 'de-DE', 23 5: 'en-IN', 24 7: 'en-GB' 25 }; 26 27 const actualLookups = []; 28 const expectedLookups = Object.keys(locales); 29 30 const handlers = { 31 get(obj, prop) { 32 actualLookups.push(prop); 33 return Reflect.get(...arguments); 34 } 35 }; 36 37 const proxyLocales = new Proxy(locales, handlers); 38 39 const nf = new Intl.NumberFormat(proxyLocales); 40 41 expectedLookups.forEach(lookup => assert(actualLookups.indexOf(lookup) != -1)); 42 43 reportCompare(0, 0);