|
1 // |reftest| random-if(Android) |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 |
|
8 /** |
|
9 File Name: 15.9.5.8.js |
|
10 ECMA Section: 15.9.5.8 |
|
11 Description: Date.prototype.getMonth |
|
12 |
|
13 1. Let t be this time value. |
|
14 2. If t is NaN, return NaN. |
|
15 3. Return MonthFromTime(LocalTime(t)). |
|
16 |
|
17 Author: christine@netscape.com |
|
18 Date: 12 november 1997 |
|
19 */ |
|
20 |
|
21 var SECTION = "15.9.5.8"; |
|
22 var VERSION = "ECMA_1"; |
|
23 startTest(); |
|
24 var TITLE = "Date.prototype.getMonth()"; |
|
25 |
|
26 writeHeaderToLog( SECTION + " "+ TITLE); |
|
27 |
|
28 addTestCase( TIME_NOW ); |
|
29 addTestCase( TIME_0000 ); |
|
30 addTestCase( TIME_1970 ); |
|
31 addTestCase( TIME_1900 ); |
|
32 addTestCase( TIME_2000 ); |
|
33 addTestCase( UTC_FEB_29_2000 ); |
|
34 addTestCase( UTC_JAN_1_2005 ); |
|
35 |
|
36 new TestCase( SECTION, |
|
37 "(new Date(NaN)).getMonth()", |
|
38 NaN, |
|
39 (new Date(NaN)).getMonth() ); |
|
40 |
|
41 new TestCase( SECTION, |
|
42 "Date.prototype.getMonth.length", |
|
43 0, |
|
44 Date.prototype.getMonth.length ); |
|
45 test(); |
|
46 |
|
47 function addTestCase( t ) { |
|
48 var leap = InLeapYear(t); |
|
49 |
|
50 for ( var m = 0; m < 12; m++ ) { |
|
51 |
|
52 t += TimeInMonth(m, leap); |
|
53 |
|
54 new TestCase( SECTION, |
|
55 "(new Date("+t+")).getMonth()", |
|
56 MonthFromTime(LocalTime(t)), |
|
57 (new Date(t)).getMonth() ); |
|
58 |
|
59 new TestCase( SECTION, |
|
60 "(new Date("+(t+1)+")).getMonth()", |
|
61 MonthFromTime(LocalTime(t+1)), |
|
62 (new Date(t+1)).getMonth() ); |
|
63 |
|
64 new TestCase( SECTION, |
|
65 "(new Date("+(t-1)+")).getMonth()", |
|
66 MonthFromTime(LocalTime(t-1)), |
|
67 (new Date(t-1)).getMonth() ); |
|
68 |
|
69 new TestCase( SECTION, |
|
70 "(new Date("+(t-TZ_ADJUST)+")).getMonth()", |
|
71 MonthFromTime(LocalTime(t-TZ_ADJUST)), |
|
72 (new Date(t-TZ_ADJUST)).getMonth() ); |
|
73 |
|
74 new TestCase( SECTION, |
|
75 "(new Date("+(t+TZ_ADJUST)+")).getMonth()", |
|
76 MonthFromTime(LocalTime(t+TZ_ADJUST)), |
|
77 (new Date(t+TZ_ADJUST)).getMonth() ); |
|
78 |
|
79 } |
|
80 } |