invalid-key.js (1122B)
1 // Copyright (C) 2021 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-intl.supportedvaluesof 6 description: > 7 Intl.supportedValuesOf throws a RangeError if the key is invalid. 8 info: | 9 Intl.supportedValuesOf ( key ) 10 11 1. Let key be ? ToString(key). 12 ... 13 8. Else, 14 a. Throw a RangeError exception. 15 ... 16 features: [Intl-enumeration] 17 ---*/ 18 19 const invalidKeys = [ 20 // Empty string is invalid. 21 "", 22 23 // Various unsupported keys. 24 "hourCycle", "locale", "language", "script", "region", 25 26 // Plural form of supported keys not valid. 27 "calendars", "collations", "currencies", "numberingSystems", "timeZones", "units", 28 29 // Wrong case for supported keys. 30 "CALENDAR", "Collation", "Currency", "numberingsystem", "timezone", "UNIT", 31 32 // NUL character must be handled correctly. 33 "calendar\0", 34 35 // Non-string cases. 36 undefined, null, false, true, NaN, 0, Math.PI, 123n, {}, [], 37 ]; 38 39 for (let key of invalidKeys) { 40 assert.throws(RangeError, function() { 41 Intl.supportedValuesOf(key); 42 }, "key: " + key); 43 } 44 45 reportCompare(0, 0);