js/src/tests/ecma/Date/15.9.5.2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 /**
     8    File Name:          15.9.5.2.js
     9    ECMA Section:       15.9.5.2 Date.prototype.toString
    10    Description:
    11    This function returns a string value. The contents of the string are
    12    implementation dependent, but are intended to represent the Date in a
    13    convenient, human-readable form in the current time zone.
    15    The toString function is not generic; it generates a runtime error if its
    16    this value is not a Date object. Therefore it cannot be transferred to
    17    other kinds of objects for use as a method.
    19    Author:             christine@netscape.com
    20    Date:               12 november 1997
    21 */
    23 var SECTION = "15.9.5.2";
    24 var VERSION = "ECMA_1";
    25 startTest();
    26 var TITLE   = "Date.prototype.toString";
    28 writeHeaderToLog( SECTION + " "+ TITLE);
    30 new TestCase( SECTION,
    31 	      "Date.prototype.toString.length",
    32 	      0,
    33 	      Date.prototype.toString.length );
    35 var now = new Date();
    37 // can't test the content of the string, but can verify that the string is
    38 // parsable by Date.parse
    40 new TestCase( SECTION,
    41 	      "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000",
    42 	      true,
    43 	      Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 );
    45 new TestCase( SECTION,
    46 	      "typeof now.toString()",
    47 	      "string",
    48 	      typeof now.toString() );
    49 // 1970
    51 new TestCase( SECTION,
    52 	      "Date.parse( (new Date(0)).toString() )",
    53 	      0,
    54 	      Date.parse( (new Date(0)).toString() ) );
    56 new TestCase( SECTION,
    57 	      "Date.parse( (new Date("+TZ_ADJUST+")).toString() )",
    58 	      TZ_ADJUST,
    59 	      Date.parse( (new Date(TZ_ADJUST)).toString() ) );
    61 // 1900
    62 new TestCase( SECTION,
    63 	      "Date.parse( (new Date("+TIME_1900+")).toString() )",
    64 	      TIME_1900,
    65 	      Date.parse( (new Date(TIME_1900)).toString() ) );
    67 new TestCase( SECTION,
    68 	      "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )",
    69 	      TIME_1900 -TZ_ADJUST,
    70 	      Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) );
    72 // 2000
    73 new TestCase( SECTION,
    74 	      "Date.parse( (new Date("+TIME_2000+")).toString() )",
    75 	      TIME_2000,
    76 	      Date.parse( (new Date(TIME_2000)).toString() ) );
    78 new TestCase( SECTION,
    79 	      "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )",
    80 	      TIME_2000 -TZ_ADJUST,
    81 	      Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) );
    83 // 29 Feb 2000
    85 new TestCase( SECTION,
    86 	      "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )",
    87 	      UTC_FEB_29_2000,
    88 	      Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) );
    90 new TestCase( SECTION,
    91 	      "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )",
    92 	      UTC_FEB_29_2000-1000,
    93 	      Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) );
    96 new TestCase( SECTION,
    97 	      "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )",
    98 	      UTC_FEB_29_2000-TZ_ADJUST,
    99 	      Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) );
   100 // 2O05
   102 new TestCase( SECTION,
   103 	      "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )",
   104 	      UTC_JAN_1_2005,
   105 	      Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) );
   107 new TestCase( SECTION,
   108 	      "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )",
   109 	      UTC_JAN_1_2005-1000,
   110 	      Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) );
   112 new TestCase( SECTION,
   113 	      "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )",
   114 	      UTC_JAN_1_2005-TZ_ADJUST,
   115 	      Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) );
   117 test();

mercurial