1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Date/15.9.5.2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 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 +/** 1.11 + File Name: 15.9.5.2.js 1.12 + ECMA Section: 15.9.5.2 Date.prototype.toString 1.13 + Description: 1.14 + This function returns a string value. The contents of the string are 1.15 + implementation dependent, but are intended to represent the Date in a 1.16 + convenient, human-readable form in the current time zone. 1.17 + 1.18 + The toString function is not generic; it generates a runtime error if its 1.19 + this value is not a Date object. Therefore it cannot be transferred to 1.20 + other kinds of objects for use as a method. 1.21 + 1.22 + Author: christine@netscape.com 1.23 + Date: 12 november 1997 1.24 +*/ 1.25 + 1.26 +var SECTION = "15.9.5.2"; 1.27 +var VERSION = "ECMA_1"; 1.28 +startTest(); 1.29 +var TITLE = "Date.prototype.toString"; 1.30 + 1.31 +writeHeaderToLog( SECTION + " "+ TITLE); 1.32 + 1.33 +new TestCase( SECTION, 1.34 + "Date.prototype.toString.length", 1.35 + 0, 1.36 + Date.prototype.toString.length ); 1.37 + 1.38 +var now = new Date(); 1.39 + 1.40 +// can't test the content of the string, but can verify that the string is 1.41 +// parsable by Date.parse 1.42 + 1.43 +new TestCase( SECTION, 1.44 + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", 1.45 + true, 1.46 + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); 1.47 + 1.48 +new TestCase( SECTION, 1.49 + "typeof now.toString()", 1.50 + "string", 1.51 + typeof now.toString() ); 1.52 +// 1970 1.53 + 1.54 +new TestCase( SECTION, 1.55 + "Date.parse( (new Date(0)).toString() )", 1.56 + 0, 1.57 + Date.parse( (new Date(0)).toString() ) ); 1.58 + 1.59 +new TestCase( SECTION, 1.60 + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", 1.61 + TZ_ADJUST, 1.62 + Date.parse( (new Date(TZ_ADJUST)).toString() ) ); 1.63 + 1.64 +// 1900 1.65 +new TestCase( SECTION, 1.66 + "Date.parse( (new Date("+TIME_1900+")).toString() )", 1.67 + TIME_1900, 1.68 + Date.parse( (new Date(TIME_1900)).toString() ) ); 1.69 + 1.70 +new TestCase( SECTION, 1.71 + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", 1.72 + TIME_1900 -TZ_ADJUST, 1.73 + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ); 1.74 + 1.75 +// 2000 1.76 +new TestCase( SECTION, 1.77 + "Date.parse( (new Date("+TIME_2000+")).toString() )", 1.78 + TIME_2000, 1.79 + Date.parse( (new Date(TIME_2000)).toString() ) ); 1.80 + 1.81 +new TestCase( SECTION, 1.82 + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", 1.83 + TIME_2000 -TZ_ADJUST, 1.84 + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ); 1.85 + 1.86 +// 29 Feb 2000 1.87 + 1.88 +new TestCase( SECTION, 1.89 + "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )", 1.90 + UTC_FEB_29_2000, 1.91 + Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) ); 1.92 + 1.93 +new TestCase( SECTION, 1.94 + "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )", 1.95 + UTC_FEB_29_2000-1000, 1.96 + Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) ); 1.97 + 1.98 + 1.99 +new TestCase( SECTION, 1.100 + "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )", 1.101 + UTC_FEB_29_2000-TZ_ADJUST, 1.102 + Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) ); 1.103 +// 2O05 1.104 + 1.105 +new TestCase( SECTION, 1.106 + "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )", 1.107 + UTC_JAN_1_2005, 1.108 + Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) ); 1.109 + 1.110 +new TestCase( SECTION, 1.111 + "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )", 1.112 + UTC_JAN_1_2005-1000, 1.113 + Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) ); 1.114 + 1.115 +new TestCase( SECTION, 1.116 + "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )", 1.117 + UTC_JAN_1_2005-TZ_ADJUST, 1.118 + Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) ); 1.119 + 1.120 +test();