1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/intl402/ch06/6.3/6.3.1_b.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +// Copyright 2012 Mozilla Corporation. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * @description Tests that invalid currency codes are not accepted. 1.9 + * @author Norbert Lindenberg 1.10 + */ 1.11 + 1.12 +var invalidCurrencyCodes = [ 1.13 + "", 1.14 + "€", 1.15 + "$", 1.16 + "SFr.", 1.17 + "DM", 1.18 + "KR₩", 1.19 + "702", 1.20 + "ßP", 1.21 + "ınr" 1.22 +]; 1.23 + 1.24 +invalidCurrencyCodes.forEach(function (code) { 1.25 + var error; 1.26 + try { 1.27 + // this must throw an exception for an invalid currency code 1.28 + var format = new Intl.NumberFormat(["de-de"], {style: "currency", currency: code}); 1.29 + } catch (e) { 1.30 + error = e; 1.31 + } 1.32 + if (error === undefined) { 1.33 + $ERROR("Invalid currency code '" + code + "' was not rejected."); 1.34 + } else if (error.name !== "RangeError") { 1.35 + $ERROR("Invalid currency code '" + code + "' was rejected with wrong error " + error.name + "."); 1.36 + } 1.37 +}); 1.38 +