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 invalid currency codes are not accepted. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: var invalidCurrencyCodes = [ michael@0: "", michael@0: "€", michael@0: "$", michael@0: "SFr.", michael@0: "DM", michael@0: "KR₩", michael@0: "702", michael@0: "ßP", michael@0: "ınr" michael@0: ]; michael@0: michael@0: invalidCurrencyCodes.forEach(function (code) { michael@0: var error; michael@0: try { michael@0: // this must throw an exception for an invalid currency code michael@0: var format = new Intl.NumberFormat(["de-de"], {style: "currency", currency: code}); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Invalid currency code '" + code + "' was not rejected."); michael@0: } else if (error.name !== "RangeError") { michael@0: $ERROR("Invalid currency code '" + code + "' was rejected with wrong error " + error.name + "."); michael@0: } michael@0: }); michael@0: