Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.3.8-5.js

raw symbols SCIP
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/. */
5
6 gTestfile = '15.9.3.8-5.js';
7
8 /**
9 File Name: 15.9.3.8.js
10 ECMA Section: 15.9.3.8 The Date Constructor
11 new Date( value )
12 Description: The [[Prototype]] property of the newly constructed
13 object is set to the original Date prototype object,
14 the one that is the initial valiue of Date.prototype.
15
16 The [[Class]] property of the newly constructed object is
17 set to "Date".
18
19 The [[Value]] property of the newly constructed object is
20 set as follows:
21
22 1. Call ToPrimitive(value)
23 2. If Type( Result(1) ) is String, then go to step 5.
24 3. Let V be ToNumber( Result(1) ).
25 4. Set the [[Value]] property of the newly constructed
26 object to TimeClip(V) and return.
27 5. Parse Result(1) as a date, in exactly the same manner
28 as for the parse method. Let V be the time value for
29 this date.
30 6. Go to step 4.
31
32 Author: [email protected]
33 Date: 28 october 1997
34 Version: 9706
35
36 */
37
38 var VERSION = "ECMA_1";
39 startTest();
40 var SECTION = "15.9.3.8";
41 var TYPEOF = "object";
42
43 var TIME = 0;
44 var UTC_YEAR = 1;
45 var UTC_MONTH = 2;
46 var UTC_DATE = 3;
47 var UTC_DAY = 4;
48 var UTC_HOURS = 5;
49 var UTC_MINUTES = 6;
50 var UTC_SECONDS = 7;
51 var UTC_MS = 8;
52
53 var YEAR = 9;
54 var MONTH = 10;
55 var DATE = 11;
56 var DAY = 12;
57 var HOURS = 13;
58 var MINUTES = 14;
59 var SECONDS = 15;
60 var MS = 16;
61
62
63 // for TCMS, the gTestcases array must be global.
64 var gTc= 0;
65 var TITLE = "Date constructor: new Date( value )";
66 var SECTION = "15.9.3.8";
67 var VERSION = "ECMA_1";
68 startTest();
69
70 writeHeaderToLog( SECTION +" " + TITLE );
71
72 // all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
73 var TZ_ADJUST = -TZ_PST * msPerHour;
74
75
76 // Dates around 1900
77
78 var PST_1900 = TIME_1900 + 8*msPerHour;
79
80 addNewTestCase( new Date( TIME_1900 ),
81 "new Date("+TIME_1900+")",
82 [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
83
84 addNewTestCase( new Date(PST_1900),
85 "new Date("+PST_1900+")",
86 [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
87
88 addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
89 "new Date(\""+(new Date(TIME_1900)).toString()+"\")",
90 [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
91
92 addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
93 "new Date(\""+(new Date(PST_1900 )).toString()+"\")",
94 [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
95
96 addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
97 "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
98 [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
99
100 addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
101 "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
102 [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
103
104 test();
105
106 function addNewTestCase( DateCase, DateString, ResultArray ) {
107 //adjust hard-coded ResultArray for tester's timezone instead of PST
108 adjustResultArray(ResultArray, 'msMode');
109
110 new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
111 new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
112 new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
113 new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
114 new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
115 new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
116 new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
117 new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
118 new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
119 new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
120 new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
121 new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
122 new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
123 new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
124 new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
125 new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
126 new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
127 new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
128 }