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 appropriate fallback locales are provided for michael@0: * supported locales. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: $INCLUDE("testIntl.js"); michael@0: michael@0: testWithIntlConstructors(function (Constructor) { michael@0: var info = getLocaleSupportInfo(Constructor); michael@0: var fallback; michael@0: info.supported.forEach(function (locale) { michael@0: var pos = locale.lastIndexOf("-"); michael@0: if (pos !== -1) { michael@0: fallback = locale.substring(0, pos); michael@0: if (info.supported.indexOf(fallback) === -1) { michael@0: $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); michael@0: } michael@0: } michael@0: var match = /([a-z]{2,3})(-[A-Z][a-z]{3})(-[A-Z]{2})/.exec(locale); michael@0: if (match !== null) { michael@0: fallback = match[1] + match[3]; michael@0: if (info.supported.indexOf(fallback) === -1) { michael@0: $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); michael@0: } michael@0: } michael@0: }); michael@0: }); michael@0: