Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | // Copyright 2012 Mozilla Corporation. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * @description Tests that the currency style can not be used without a specified currency. |
michael@0 | 6 | * @author Norbert Lindenberg |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; |
michael@0 | 10 | |
michael@0 | 11 | function expectError(f) { |
michael@0 | 12 | var error; |
michael@0 | 13 | try { |
michael@0 | 14 | f(); |
michael@0 | 15 | } catch (e) { |
michael@0 | 16 | error = e; |
michael@0 | 17 | } |
michael@0 | 18 | if (error === undefined) { |
michael@0 | 19 | $ERROR("Invalid currency value " + value + " was not rejected."); |
michael@0 | 20 | } else if (error.name !== "TypeError") { |
michael@0 | 21 | $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + "."); |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | expectError(function () { |
michael@0 | 26 | return new Intl.NumberFormat([defaultLocale], {style: "currency"}); |
michael@0 | 27 | }); |
michael@0 | 28 | expectError(function () { |
michael@0 | 29 | return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency"}); |
michael@0 | 30 | }); |
michael@0 | 31 |