constructor-options-casefirst-invalid.js (1029B)
1 // Copyright 2018 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-intl.locale 6 description: > 7 Checks error cases for the options argument to the Locale constructor. 8 info: | 9 Intl.Locale( tag [, options] ) 10 11 ... 12 22. Let kf be ? GetOption(options, "caseFirst", "string", « "upper", "lower", "false" », undefined). 13 ... 14 15 GetOption ( options, property, type, values, fallback ) 16 ... 17 2. d. If values is not undefined, then 18 i. If values does not contain an element equal to value, throw a RangeError exception. 19 ... 20 features: [Intl.Locale] 21 ---*/ 22 23 24 const invalidCaseFirstOptions = [ 25 "", 26 "u", 27 "Upper", 28 "upper\0", 29 "uppercase", 30 "true", 31 { valueOf() { return false; } }, 32 ]; 33 for (const caseFirst of invalidCaseFirstOptions) { 34 assert.throws(RangeError, function() { 35 new Intl.Locale("en", {caseFirst}); 36 }, `new Intl.Locale("en", {caseFirst: "${caseFirst}"}) throws RangeError`); 37 } 38 39 reportCompare(0, 0);