]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Date/15.9.5.35-1.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.9.5.35-1.js
24 ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date])
26 Author: christine@netscape.com
27 Date: 12 november 1997
29 var SECTION
= "15.9.5.35-1";
30 var VERSION
= "ECMA_1";
33 writeHeaderToLog( SECTION
+ " Date.prototype.setUTCMonth(mon [,date] ) ");
39 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
40 testcases
[tc
].passed
= writeTestCaseResult(
43 testcases
[tc
].description
+" = "+
44 testcases
[tc
].actual
);
46 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
52 function getTestCases() {
53 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE",
54 UTCDateFromTime(SetUTCMonth(0,0)),
55 LocalDateFromTime(SetUTCMonth(0,0)) );
57 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE",
58 UTCDateFromTime(SetUTCMonth(0,11)),
59 LocalDateFromTime(SetUTCMonth(0,11)) );
61 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE",
62 UTCDateFromTime(SetUTCMonth(0,3,4)),
63 LocalDateFromTime(SetUTCMonth(0,3,4)) );
67 function addNewTestCase( DateString
, UTCDate
, LocalDate
) {
68 DateCase
= eval( DateString
);
70 var item
= testcases
.length
;
72 // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year;
74 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getTime()", UTCDate
.value
, DateCase
.getTime() );
75 testcases
[item
++] = new TestCase( SECTION
, DateString
+".valueOf()", UTCDate
.value
, DateCase
.valueOf() );
77 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCFullYear()", UTCDate
.year
, DateCase
.getUTCFullYear() );
78 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCMonth()", UTCDate
.month
, DateCase
.getUTCMonth() );
79 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCDate()", UTCDate
.date
, DateCase
.getUTCDate() );
80 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCDay()", UTCDate
.day
, DateCase
.getUTCDay() );
81 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCHours()", UTCDate
.hours
, DateCase
.getUTCHours() );
82 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCMinutes()", UTCDate
.minutes
,DateCase
.getUTCMinutes() );
83 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCSeconds()", UTCDate
.seconds
,DateCase
.getUTCSeconds() );
84 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getUTCMilliseconds()", UTCDate
.ms
, DateCase
.getUTCMilliseconds() );
86 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getFullYear()", LocalDate
.year
, DateCase
.getFullYear() );
87 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getMonth()", LocalDate
.month
, DateCase
.getMonth() );
88 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getDate()", LocalDate
.date
, DateCase
.getDate() );
89 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getDay()", LocalDate
.day
, DateCase
.getDay() );
90 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getHours()", LocalDate
.hours
, DateCase
.getHours() );
91 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getMinutes()", LocalDate
.minutes
, DateCase
.getMinutes() );
92 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getSeconds()", LocalDate
.seconds
, DateCase
.getSeconds() );
93 testcases
[item
++] = new TestCase( SECTION
, DateString
+".getMilliseconds()", LocalDate
.ms
, DateCase
.getMilliseconds() );
95 DateCase
.toString
= Object
.prototype.toString
;
97 testcases
[item
++] = new TestCase( SECTION
,
98 DateString
+".toString=Object.prototype.toString;"+DateString
+".toString()",
100 DateCase
.toString() );
111 function LocalDateFromTime(t
) {
113 return ( MyDateFromTime(t
) );
115 function UTCDateFromTime(t
) {
116 return ( MyDateFromTime(t
) );
118 function MyDateFromTime( t
) {
119 var d
= new MyDate();
120 d
.year
= YearFromTime(t
);
121 d
.month
= MonthFromTime(t
);
122 d
.date
= DateFromTime(t
);
123 d
.hours
= HourFromTime(t
);
124 d
.minutes
= MinFromTime(t
);
125 d
.seconds
= SecFromTime(t
);
126 d
.ms
= msFromTime(t
);
128 d
.time
= MakeTime( d
.hours
, d
.minutes
, d
.seconds
, d
.ms
);
129 d
.value
= TimeClip( MakeDate( MakeDay( d
.year
, d
.month
, d
.date
), d
.time
) );
130 d
.day
= WeekDay( d
.value
);
134 function SetUTCMonth( t
, month
, date
) {
136 var MONTH
= Number( month
);
137 var DATE
= ( date
== void 0) ? DateFromTime(T
) : Number( date
);
139 var RESULT4
= MakeDay(YearFromTime(T
), MONTH
, DATE
);
140 var RESULT5
= MakeDate( RESULT4
, TimeWithinDay(T
));
142 return ( TimeClip(RESULT5
) );