1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Date/regress-301738-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 301738; 1.11 +var summary = 'Date parse compatibilty with MSIE'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +printBugNumber(BUGNUMBER); 1.16 +printStatus (summary); 1.17 + 1.18 +/* 1.19 + Case 1. The input string contains an English month name. 1.20 + The form of the string can be month f l, or f month l, or 1.21 + f l month which each evaluate to the same date. 1.22 + If f and l are both greater than or equal to 70, or 1.23 + both less than 70, the date is invalid. 1.24 + The year is taken to be the greater of the values f, l. 1.25 + If the year is greater than or equal to 70 and less than 100, 1.26 + it is considered to be the number of years after 1900. 1.27 +*/ 1.28 + 1.29 +var month = 'January'; 1.30 +var f; 1.31 +var l; 1.32 + 1.33 +f = l = 0; 1.34 +expect = true; 1.35 + 1.36 +actual = isNaN(new Date(month + ' ' + f + ' ' + l)); 1.37 +reportCompare(expect, actual, 'January 0 0 is invalid'); 1.38 + 1.39 +actual = isNaN(new Date(f + ' ' + l + ' ' + month)); 1.40 +reportCompare(expect, actual, '0 0 January is invalid'); 1.41 + 1.42 +actual = isNaN(new Date(f + ' ' + month + ' ' + l)); 1.43 +reportCompare(expect, actual, '0 January 0 is invalid'); 1.44 + 1.45 +f = l = 70; 1.46 + 1.47 +actual = isNaN(new Date(month + ' ' + f + ' ' + l)); 1.48 +reportCompare(expect, actual, 'January 70 70 is invalid'); 1.49 + 1.50 +actual = isNaN(new Date(f + ' ' + l + ' ' + month)); 1.51 +reportCompare(expect, actual, '70 70 January is invalid'); 1.52 + 1.53 +actual = isNaN(new Date(f + ' ' + month + ' ' + l)); 1.54 +reportCompare(expect, actual, '70 January 70 is invalid'); 1.55 + 1.56 +f = 100; 1.57 +l = 15; 1.58 + 1.59 +// year, month, day 1.60 +expect = new Date(f, 0, l).toString(); 1.61 + 1.62 +actual = new Date(month + ' ' + f + ' ' + l).toString(); 1.63 +reportCompare(expect, actual, 'month f l'); 1.64 + 1.65 +actual = new Date(f + ' ' + l + ' ' + month).toString(); 1.66 +reportCompare(expect, actual, 'f l month'); 1.67 + 1.68 +actual = new Date(f + ' ' + month + ' ' + l).toString(); 1.69 +reportCompare(expect, actual, 'f month l'); 1.70 + 1.71 +f = 80; 1.72 +l = 15; 1.73 + 1.74 +// year, month, day 1.75 +expect = (new Date(f, 0, l)).toString(); 1.76 + 1.77 +actual = (new Date(month + ' ' + f + ' ' + l)).toString(); 1.78 +reportCompare(expect, actual, 'month f l'); 1.79 + 1.80 +actual = (new Date(f + ' ' + l + ' ' + month)).toString(); 1.81 +reportCompare(expect, actual, 'f l month'); 1.82 + 1.83 +actual = (new Date(f + ' ' + month + ' ' + l)).toString(); 1.84 +reportCompare(expect, actual, 'f month l'); 1.85 + 1.86 +f = 2040; 1.87 +l = 15; 1.88 + 1.89 +// year, month, day 1.90 +expect = (new Date(f, 0, l)).toString(); 1.91 + 1.92 +actual = (new Date(month + ' ' + f + ' ' + l)).toString(); 1.93 +reportCompare(expect, actual, 'month f l'); 1.94 + 1.95 +actual = (new Date(f + ' ' + l + ' ' + month)).toString(); 1.96 +reportCompare(expect, actual, 'f l month'); 1.97 + 1.98 +actual = (new Date(f + ' ' + month + ' ' + l)).toString(); 1.99 +reportCompare(expect, actual, 'f month l'); 1.100 +