michael@0: // Copyright 2012 Mozilla Corporation. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * @description Tests that the currency style can not be used without a specified currency. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; michael@0: michael@0: function expectError(f) { michael@0: var error; michael@0: try { michael@0: f(); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Invalid currency value " + value + " was not rejected."); michael@0: } else if (error.name !== "TypeError") { michael@0: $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + "."); michael@0: } michael@0: } michael@0: michael@0: expectError(function () { michael@0: return new Intl.NumberFormat([defaultLocale], {style: "currency"}); michael@0: }); michael@0: expectError(function () { michael@0: return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency"}); michael@0: }); michael@0: