constructor-locales-hasproperty.js (890B)
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 HasProperty(O, Pk) is properly called within the constructor for 8 Intl.NumberFormat 9 info: | 10 9.2.1 CanonicalizeLocaleList ( locales ) 11 12 7.b. Let kPresent be ? HasProperty(O, Pk). 13 ---*/ 14 15 const locales = { 16 length: 8, 17 1: 'en-US', 18 3: 'de-DE', 19 5: 'en-IN', 20 7: 'en-GB' 21 }; 22 23 const actualLookups = []; 24 25 const handlers = { 26 has(obj, prop) { 27 actualLookups.push(prop); 28 return Reflect.has(...arguments); 29 } 30 }; 31 32 const proxyLocales = new Proxy(locales, handlers); 33 34 const nf = new Intl.NumberFormat(proxyLocales); 35 36 assert.sameValue(actualLookups.length, locales.length); 37 for (let index in actualLookups) { 38 assert.sameValue(actualLookups[index], String(index)); 39 } 40 41 reportCompare(0, 0);