keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 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.1_8_c_ii |
| 6 | description: Tests that values other than strings are not accepted as locales. |
| 7 | author: Norbert Lindenberg |
| 8 | includes: [testIntl.js] |
| 9 | ---*/ |
| 10 | |
| 11 | var notStringOrObject = [undefined, null, true, false, 0, 5, -5, NaN]; |
| 12 | |
| 13 | testWithIntlConstructors(function (Constructor) { |
| 14 | notStringOrObject.forEach(function (value) { |
| 15 | var error; |
| 16 | try { |
| 17 | var supported = Constructor.supportedLocalesOf([value]); |
| 18 | } catch (e) { |
| 19 | error = e; |
| 20 | } |
| 21 | if (error === undefined) { |
| 22 | $ERROR("" + value + " as locale was not rejected."); |
| 23 | } else if (error.name !== "TypeError") { |
| 24 | $ERROR("" + value + " as locale was rejected with wrong error " + error.name + "."); |
| 25 | } |
| 26 | }); |
| 27 | |
| 28 | return true; |
| 29 | }); |