gecko-dev/intl/locale/tests/unit/test_bug22310.js
Simon Montagu 8a2e796345 Unify intl/locale xpcshell tests in one directory. Bug 668515, r=ted
--HG--
rename : intl/locale/tests_multilocale/unit/test_bug22310.js => intl/locale/tests/unit/test_bug22310.js
rename : intl/locale/src/unix/tests/unit/test_bug374040.js => intl/locale/tests/unit/test_bug374040.js
2011-07-03 09:38:24 +03:00

48 lines
1.7 KiB
JavaScript

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("ta-IN").has("\u0B9C\u0BC2\u0BA9\u0BCD"), "month name in ta-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);
}