Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * @description Tests that Date.prototype.toLocaleString & Co. handle "this time value" correctly.
6 * @author Norbert Lindenberg
7 */
9 var functions = {
10 toLocaleString: Date.prototype.toLocaleString,
11 toLocaleDateString: Date.prototype.toLocaleDateString,
12 toLocaleTimeString: Date.prototype.toLocaleTimeString
13 };
14 var invalidValues = [undefined, null, 5, "5", false, {valueOf: function () { return 5; }}];
16 Object.getOwnPropertyNames(functions).forEach(function (p) {
17 var f = functions[p];
18 invalidValues.forEach(function (value) {
19 var error;
20 try {
21 var result = f.call(value);
22 } catch (e) {
23 error = e;
24 }
25 if (error === undefined) {
26 $ERROR("Date.prototype." + p + " did not reject this = " + value + ".");
27 } else if (error.name !== "TypeError") {
28 $ERROR("Date.prototype." + p + " rejected this = " + value + " with wrong error " + error.name + ".");
29 }
30 });
31 });