darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 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/ |
| 5 | * |
| 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. |
| 10 | * |
| 11 | * The Original Code is Mozilla Communicator client code, released March |
| 12 | * 31, 1998. |
| 13 | * |
| 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 |
| 17 | * Rights Reserved. |
| 18 | * |
| 19 | * Contributor(s): |
| 20 | * |
| 21 | */ |
| 22 | /** |
| 23 | File Name: 15.9.2.2.js |
| 24 | ECMA Section: 15.9.2.2 Date constructor used as a function |
| 25 | Date( year, month, date, hours, minutes, seconds ) |
| 26 | Description: The arguments are accepted, but are completely ignored. |
| 27 | A string is created and returned as if by the |
| 28 | expression (new Date()).toString(). |
| 29 | |
| 30 | Author: christine@netscape.com |
| 31 | Date: 28 october 1997 |
| 32 | Version: 9706 |
| 33 | |
| 34 | */ |
| 35 | var VERSION = 9706; |
| 36 | startTest(); |
| 37 | var SECTION = "15.9.2.2"; |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 38 | var TITLE = "The Date Constructor Called as a Function"; |
| 39 | |
| 40 | writeHeaderToLog(SECTION+" "+TITLE ); |
| 41 | var tc= 0; |
| 42 | var testcases = getTestCases(); |
| 43 | |
| 44 | // all tests must call a function that returns an array of TestCase objects. |
| 45 | test(); |
| 46 | |
| 47 | function getTestCases() { |
| 48 | var array = new Array(); |
| 49 | var item = 0; |
| 50 | |
ap@apple.com | 2260148 | 2014-12-01 21:14:35 +0000 | [diff] [blame] | 51 | // allow up to 1 second difference due to possibility |
| 52 | // the date may change by 1 second in between calls to Date |
| 53 | |
| 54 | var d1; |
| 55 | var d2; |
| 56 | |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 57 | // Dates around 1970 |
| 58 | |
ap@apple.com | 2260148 | 2014-12-01 21:14:35 +0000 | [diff] [blame] | 59 | d1 = new Date(); |
| 60 | d2 = Date.parse(Date(1970,0,1,0,0,0)); |
| 61 | array[item++] = new TestCase(SECTION, "Date(1970,0,1,0,0,0)", true, d2 - d1 <= 1000); |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 62 | |
ap@apple.com | 2260148 | 2014-12-01 21:14:35 +0000 | [diff] [blame] | 63 | d1 = new Date(); |
| 64 | d2 = Date.parse(Date(1969,11,31,15,59,59)); |
| 65 | array[item++] = new TestCase(SECTION, "Date(1969,11,31,15,59,59)", true, d2 - d1 <= 1000); |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 66 | |
ap@apple.com | 2260148 | 2014-12-01 21:14:35 +0000 | [diff] [blame] | 67 | d1 = new Date(); |
| 68 | d2 = Date.parse(Date(1969,11,31,16,0,0)); |
| 69 | array[item++] = new TestCase(SECTION, "Date(1969,11,31,16,0,0)", true, d2 - d1 <= 1000); |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 70 | |
ap@apple.com | 2260148 | 2014-12-01 21:14:35 +0000 | [diff] [blame] | 71 | d1 = new Date(); |
| 72 | d2 = Date.parse(Date(1969,11,31,16,0,1)); |
| 73 | array[item++] = new TestCase(SECTION, "Date(1969,11,31,16,0,1)", true, d2 - d1 <= 1000); |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 74 | |
darin | cd553de | 2003-10-13 02:05:37 +0000 | [diff] [blame] | 75 | return ( array ); |
| 76 | } |
| 77 | function test() { |
| 78 | for ( tc=0; tc < testcases.length; tc++ ) { |
| 79 | testcases[tc].passed = writeTestCaseResult( |
| 80 | testcases[tc].expect, |
| 81 | testcases[tc].actual, |
| 82 | testcases[tc].description +" = "+ |
| 83 | testcases[tc].actual ); |
| 84 | |
| 85 | testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; |
| 86 | } |
| 87 | stopTest(); |
| 88 | return ( testcases ); |
| 89 | } |