diff --git a/intl/locale/Makefile.in b/intl/locale/Makefile.in index 0d611b5fa602..3f75ef515ab6 100644 --- a/intl/locale/Makefile.in +++ b/intl/locale/Makefile.in @@ -49,6 +49,9 @@ DIRS = public idl src ifdef ENABLE_TESTS DIRS += tests +ifneq (,$(filter mac cocoa windows, $(MOZ_WIDGET_TOOLKIT))) +DIRS += tests_multilocale +endif endif include $(topsrcdir)/config/rules.mk diff --git a/intl/locale/tests_multilocale/Makefile.in b/intl/locale/tests_multilocale/Makefile.in new file mode 100644 index 000000000000..8c512a50b68c --- /dev/null +++ b/intl/locale/tests_multilocale/Makefile.in @@ -0,0 +1,48 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = test_intl_locale +XPCSHELL_TESTS = unit + +include $(topsrcdir)/config/rules.mk diff --git a/intl/locale/tests_multilocale/unit/test_bug22310.js b/intl/locale/tests_multilocale/unit/test_bug22310.js new file mode 100644 index 000000000000..4996377dd2c6 --- /dev/null +++ b/intl/locale/tests_multilocale/unit/test_bug22310.js @@ -0,0 +1,47 @@ +String.prototype.has = function(s) this.indexOf(s) != -1; +const Cc = Components.classes; +const Ci = Components.interfaces; + +const dts = Cc["@mozilla.org/intl/scriptabledateformat;1"] + .getService(Ci.nsIScriptableDateFormat); +function dt(locale) dts.FormatDateTime(locale, dts.dateFormatLong, + dts.timeFormatSeconds, 2008, 6, 30, 13, 56, 34); +var all_passed = true; +const tests = +[ + [dt("en-US").has("June"), "month name in en-US"], + [dt("en-US").has("2008"), "year in en-US"], + [dt("da").has("jun"), "month name in da"], + [dt("da-DK") == dt("da"), "da same as da-DK"], + [dt("en-GB").has("30") && dt("en-GB").has("June") && + dt("en-GB").indexOf("30") < dt("en-GB").indexOf("June"), + "day before month in en-GB"], + [dt("en-US").has("30") && dt("en-US").has("June") && + dt("en-US").indexOf("30") > dt("en-US").indexOf("June"), + "month before day in en-US"], + [dt("ja-JP").has("\u5E746\u670830\u65E5"), "year month and day in ja-JP"], + [dt("ja-JP") == dt("ja-JP-mac"), "ja-JP-mac same as ja-JP"], + [dt("nn-NO").has("juni"), "month name in nn-NO"], + [dt("nb-NO").has("juni"), "month name in nb-NO"], + [dt("no-NO").has("30. juni"), "month name in no-NO"], + [dt("sv-SE").has("30 jun"), "month name in sv-SE"], + [dt("kok").has("\u091C\u0942\u0928"), "month name in kok"], + [dt("gu-IN").has("\u0A9C\u0AC2\u0AA8"), "month name in gu-IN"], + [dt("ab-CD").length > 0, "fallback for ab-CD"] +]; + +function one_test(testcase, msg) +{ + if (!testcase) { + all_passed = false; + dump("Unexpected date format: " + msg + "\n"); + } +} + +function run_test() +{ + for (var i = 0; i < tests.length; ++i) { + one_test(tests[i][0], tests[i][1]); + } + do_check_true(all_passed); +}