supportedLocalesOf-test-option-localeMatcher.js (1034B)
1 // Copyright 2012 Mozilla Corporation. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 9.2.8_1_c 6 description: Tests that the option localeMatcher is processed correctly. 7 author: Norbert Lindenberg 8 includes: [testIntl.js] 9 ---*/ 10 11 testWithIntlConstructors(function (Constructor) { 12 var defaultLocale = new Constructor().resolvedOptions().locale; 13 14 var validValues = [undefined, "lookup", "best fit", {toString: function () { return "lookup"; }}]; 15 validValues.forEach(function (value) { 16 var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value}); 17 }); 18 19 var invalidValues = [null, 0, 5, NaN, true, false, "invalid"]; 20 invalidValues.forEach(function (value) { 21 assert.throws(RangeError, function() { 22 var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value}); 23 }, "Invalid localeMatcher value " + value + " was not rejected."); 24 }); 25 }); 26 27 reportCompare(0, 0);