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 language tags with "_" are not accepted. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: $INCLUDE("testIntl.js"); michael@0: michael@0: var invalidLanguageTags = [ michael@0: "de_DE", michael@0: "DE_de", michael@0: "cmn_Hans", michael@0: "cmn-hans_cn", michael@0: "es_419", michael@0: "es-419-u-nu-latn-cu_bob", michael@0: "i_klingon", michael@0: "cmn-hans-cn-t-ca-u-ca-x_t-u", michael@0: "enochian_enochian", michael@0: "de-gregory_u-ca-gregory" michael@0: ]; michael@0: michael@0: testWithIntlConstructors(function (Constructor) { michael@0: invalidLanguageTags.forEach(function (tag) { michael@0: var error; michael@0: try { michael@0: // this must throw an exception for an invalid language tag michael@0: var obj = new Constructor([tag]); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Invalid language tag " + tag + " was not rejected."); michael@0: } else if (error.name !== "RangeError") { michael@0: $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + "."); michael@0: } michael@0: }); michael@0: return true; michael@0: }); michael@0: