|
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 well-formed currency codes are accepted. |
|
6 * @author Norbert Lindenberg |
|
7 */ |
|
8 |
|
9 var wellFormedCurrencyCodes = [ |
|
10 "BOB", |
|
11 "EUR", |
|
12 "usd", // currency codes are case-insensitive |
|
13 "XdR", |
|
14 "xTs" |
|
15 ]; |
|
16 |
|
17 wellFormedCurrencyCodes.forEach(function (code) { |
|
18 // this must not throw an exception for a valid currency code |
|
19 var format = new Intl.NumberFormat(["de-de"], {style: "currency", currency: code}); |
|
20 if (format.resolvedOptions().currency !== code.toUpperCase()) { |
|
21 $ERROR("Currency " + code + " was not correctly accepted; turned into " + |
|
22 format.resolvedOptions().currency + "."); |
|
23 } |
|
24 }); |
|
25 |