js/src/tests/js1_5/Date/regress-301738-01.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 301738;
     8 var summary = 'Date parse compatibilty with MSIE';
     9 var actual = '';
    10 var expect = '';
    12 printBugNumber(BUGNUMBER);
    13 printStatus (summary);
    15 /* 
    16     Case 1. The input string contains an English month name.
    17     The form of the string can be month f l, or f month l, or
    18     f l month which each evaluate to the same date.
    19     If f and l are both greater than or equal to 70, or
    20     both less than 70, the date is invalid.
    21     The year is taken to be the greater of the values f, l.
    22     If the year is greater than or equal to 70 and less than 100,
    23     it is considered to be the number of years after 1900.
    24 */
    26 var month = 'January';
    27 var f;
    28 var l;
    30 f = l = 0;
    31 expect = true;
    33 actual = isNaN(new Date(month + ' ' + f + ' ' + l));
    34 reportCompare(expect, actual, 'January 0 0 is invalid');
    36 actual = isNaN(new Date(f + ' ' + l + ' ' + month));
    37 reportCompare(expect, actual, '0 0 January is invalid');
    39 actual = isNaN(new Date(f + ' ' + month + ' ' + l));
    40 reportCompare(expect, actual, '0 January 0 is invalid');
    42 f = l = 70;
    44 actual = isNaN(new Date(month + ' ' + f + ' ' + l));
    45 reportCompare(expect, actual, 'January 70 70 is invalid');
    47 actual = isNaN(new Date(f + ' ' + l + ' ' + month));
    48 reportCompare(expect, actual, '70 70 January is invalid');
    50 actual = isNaN(new Date(f + ' ' + month + ' ' + l));
    51 reportCompare(expect, actual, '70 January 70 is invalid');
    53 f = 100;
    54 l = 15;
    56 // year, month, day
    57 expect = new Date(f, 0, l).toString();
    59 actual = new Date(month + ' ' + f + ' ' + l).toString();
    60 reportCompare(expect, actual, 'month f l');
    62 actual = new Date(f + ' ' + l + ' ' + month).toString();
    63 reportCompare(expect, actual, 'f l month');
    65 actual = new Date(f + ' ' + month + ' ' + l).toString();
    66 reportCompare(expect, actual, 'f month l');
    68 f = 80;
    69 l = 15;
    71 // year, month, day
    72 expect = (new Date(f, 0, l)).toString();
    74 actual = (new Date(month + ' ' + f + ' ' + l)).toString();
    75 reportCompare(expect, actual, 'month f l');
    77 actual = (new Date(f + ' ' + l + ' ' + month)).toString();
    78 reportCompare(expect, actual, 'f l month');
    80 actual = (new Date(f + ' ' + month + ' ' + l)).toString();
    81 reportCompare(expect, actual, 'f month l');
    83 f = 2040;
    84 l = 15;
    86 // year, month, day
    87 expect = (new Date(f, 0, l)).toString();
    89 actual = (new Date(month + ' ' + f + ' ' + l)).toString();
    90 reportCompare(expect, actual, 'month f l');
    92 actual = (new Date(f + ' ' + l + ' ' + month)).toString();
    93 reportCompare(expect, actual, 'f l month');
    95 actual = (new Date(f + ' ' + month + ' ' + l)).toString();
    96 reportCompare(expect, actual, 'f month l');

mercurial