1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/intl402/ch09/9.1/9.1_b.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,32 @@ 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 appropriate fallback locales are provided for 1.9 + * supported locales. 1.10 + * @author Norbert Lindenberg 1.11 + */ 1.12 + 1.13 +$INCLUDE("testIntl.js"); 1.14 + 1.15 +testWithIntlConstructors(function (Constructor) { 1.16 + var info = getLocaleSupportInfo(Constructor); 1.17 + var fallback; 1.18 + info.supported.forEach(function (locale) { 1.19 + var pos = locale.lastIndexOf("-"); 1.20 + if (pos !== -1) { 1.21 + fallback = locale.substring(0, pos); 1.22 + if (info.supported.indexOf(fallback) === -1) { 1.23 + $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); 1.24 + } 1.25 + } 1.26 + var match = /([a-z]{2,3})(-[A-Z][a-z]{3})(-[A-Z]{2})/.exec(locale); 1.27 + if (match !== null) { 1.28 + fallback = match[1] + match[3]; 1.29 + if (info.supported.indexOf(fallback) === -1) { 1.30 + $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); 1.31 + } 1.32 + } 1.33 + }); 1.34 +}); 1.35 +