js/src/tests/test262/intl402/ch13/13.3/13.3.0_2.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:038a2928475b
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /**
5 * @description Tests that Date.prototype.toLocaleString & Co. handle non-finite values correctly.
6 * @author Norbert Lindenberg
7 */
8
9 var functions = {
10 toLocaleString: Date.prototype.toLocaleString,
11 toLocaleDateString: Date.prototype.toLocaleDateString,
12 toLocaleTimeString: Date.prototype.toLocaleTimeString
13 };
14 var invalidValues = [NaN, Infinity, -Infinity];
15
16 Object.getOwnPropertyNames(functions).forEach(function (p) {
17 var f = functions[p];
18 invalidValues.forEach(function (value) {
19 var result = f.call(new Date(value));
20 if (result !== "Invalid Date") {
21 $ERROR("Date.prototype." + p + " did not return \"Invalid Date\" for " +
22 value + " – got " + result + " instead.");
23 }
24 });
25 });
26

mercurial