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 structurally valid language tags are accepted. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: $INCLUDE("testIntl.js"); michael@0: michael@0: var validLanguageTags = [ michael@0: "de", // ISO 639 language code michael@0: "de-DE", // + ISO 3166-1 country code michael@0: "DE-de", // tags are case-insensitive michael@0: "cmn", // ISO 639 language code michael@0: "cmn-Hans", // + script code michael@0: "CMN-hANS", // tags are case-insensitive michael@0: "cmn-hans-cn", // + ISO 3166-1 country code michael@0: "es-419", // + UN M.49 region code michael@0: "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence michael@0: "i-klingon", // grandfathered tag michael@0: "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags michael@0: "enochian-enochian", // language and variant subtags may be the same michael@0: "de-gregory-u-ca-gregory", // variant and extension subtags may be the same michael@0: "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags michael@0: "x-en-US-12345", // anything goes in private use tags michael@0: "x-12345-12345-en-US", michael@0: "x-en-US-12345-12345", michael@0: "x-en-u-foo", michael@0: "x-en-u-foo-u-bar" michael@0: ]; michael@0: michael@0: testWithIntlConstructors(function (Constructor) { michael@0: validLanguageTags.forEach(function (tag) { michael@0: // this must not throw an exception for a valid language tag michael@0: var obj = new Constructor([tag]); michael@0: }); michael@0: return true; michael@0: }); michael@0: