|
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 * @description Tests that the currency style can not be used without a specified currency. |
|
6 * @author Norbert Lindenberg |
|
7 */ |
|
8 |
|
9 var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; |
|
10 |
|
11 function expectError(f) { |
|
12 var error; |
|
13 try { |
|
14 f(); |
|
15 } catch (e) { |
|
16 error = e; |
|
17 } |
|
18 if (error === undefined) { |
|
19 $ERROR("Invalid currency value " + value + " was not rejected."); |
|
20 } else if (error.name !== "TypeError") { |
|
21 $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + "."); |
|
22 } |
|
23 } |
|
24 |
|
25 expectError(function () { |
|
26 return new Intl.NumberFormat([defaultLocale], {style: "currency"}); |
|
27 }); |
|
28 expectError(function () { |
|
29 return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency"}); |
|
30 }); |
|
31 |