Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.3.1-2.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.1-2.js';
7
8 /**
9 File Name: 15.9.3.1.js
10 ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
11 Description: The [[Prototype]] property of the newly constructed
12 object is set to the original Date prototype object,
13 the one that is the initial value of Date.prototype.
14
15 The [[Class]] property of the newly constructed object
16 is set as follows:
17 1. Call ToNumber(year)
18 2. Call ToNumber(month)
19 3. Call ToNumber(date)
20 4. Call ToNumber(hours)
21 5. Call ToNumber(minutes)
22 6. Call ToNumber(seconds)
23 7. Call ToNumber(ms)
24 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
25 99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
26 Result(8) is Result(1)
27 9. Compute MakeDay(Result(8), Result(2), Result(3)
28 10. Compute MakeTime(Result(4), Result(5), Result(6),
29 Result(7)
30 11. Compute MakeDate(Result(9), Result(10))
31 12. Set the [[Value]] property of the newly constructed
32 object to TimeClip(UTC(Result(11))).
33
34
35 This tests the returned value of a newly constructed
36 Date object.
37
38 Author: [email protected]
39 Date: 7 july 1997
40 */
41
42 var SECTION = "15.9.3.1";
43 var VERSION = "ECMA_1";
44 startTest();
45 var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
46
47 var TIME = 0;
48 var UTC_YEAR = 1;
49 var UTC_MONTH = 2;
50 var UTC_DATE = 3;
51 var UTC_DAY = 4;
52 var UTC_HOURS = 5;
53 var UTC_MINUTES = 6;
54 var UTC_SECONDS = 7;
55 var UTC_MS = 8;
56
57 var YEAR = 9;
58 var MONTH = 10;
59 var DATE = 11;
60 var DAY = 12;
61 var HOURS = 13;
62 var MINUTES = 14;
63 var SECONDS = 15;
64 var MS = 16;
65
66 writeHeaderToLog( SECTION + " "+ TITLE);
67
68
69 // all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
70
71 // Dates around 2000
72
73 addNewTestCase( new Date( 1999,11,31,15,59,59,999),
74 "new Date( 1999,11,31,15,59,59,999)",
75 [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
76
77 addNewTestCase( new Date( 1999,11,31,16,0,0,0),
78 "new Date( 1999,11,31,16,0,0,0)",
79 [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
80
81 addNewTestCase( new Date( 1999,11,31,23,59,59,999),
82 "new Date( 1999,11,31,23,59,59,999)",
83 [TIME_2000-PST_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
84
85 addNewTestCase( new Date( 2000,0,1,0,0,0,0),
86 "new Date( 2000,0,1,0,0,0,0)",
87 [TIME_2000-PST_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
88
89 addNewTestCase( new Date( 2000,0,1,0,0,0,1),
90 "new Date( 2000,0,1,0,0,0,1)",
91 [TIME_2000-PST_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] );
92
93 test();
94
95 function addNewTestCase( DateCase, DateString, ResultArray ) {
96 //adjust hard-coded ResultArray for tester's timezone instead of PST
97 adjustResultArray(ResultArray);
98
99 new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
100 new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
101
102 new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
103 new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
104 new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
105 new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
106 new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
107 new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
108 new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
109 new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
110
111 new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
112 new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
113 new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
114 new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
115 new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
116 new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
117 new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
118 new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
119 }