Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.9.2.1.js |
michael@0 | 9 | ECMA Section: 15.9.2.1 Date constructor used as a function |
michael@0 | 10 | Date( year, month, date, hours, minutes, seconds, ms ) |
michael@0 | 11 | Description: The arguments are accepted, but are completely ignored. |
michael@0 | 12 | A string is created and returned as if by the |
michael@0 | 13 | expression (new Date()).toString(). |
michael@0 | 14 | |
michael@0 | 15 | Author: christine@netscape.com |
michael@0 | 16 | Date: 28 october 1997 |
michael@0 | 17 | |
michael@0 | 18 | */ |
michael@0 | 19 | var VERSION = "ECMA_1"; |
michael@0 | 20 | startTest(); |
michael@0 | 21 | var SECTION = "15.9.2.1"; |
michael@0 | 22 | var TITLE = "Date Constructor used as a function"; |
michael@0 | 23 | var TYPEOF = "string"; |
michael@0 | 24 | var TOLERANCE = 1000; |
michael@0 | 25 | |
michael@0 | 26 | writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + |
michael@0 | 27 | "Date( year, month, date, hours, minutes, seconds, ms )" ); |
michael@0 | 28 | |
michael@0 | 29 | // allow up to 1 second difference due to possibility |
michael@0 | 30 | // the date may change by 1 second in between calls to Date |
michael@0 | 31 | |
michael@0 | 32 | var d1; |
michael@0 | 33 | var d2; |
michael@0 | 34 | |
michael@0 | 35 | // Dates around 1970 |
michael@0 | 36 | |
michael@0 | 37 | d1 = new Date(); |
michael@0 | 38 | d2 = Date.parse(Date(1970,0,1,0,0,0,0)); |
michael@0 | 39 | new TestCase(SECTION, "Date(1970,0,1,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 40 | |
michael@0 | 41 | d1 = new Date(); |
michael@0 | 42 | d2 = Date.parse(Date(1969,11,31,15,59,59,999)); |
michael@0 | 43 | new TestCase(SECTION, "Date(1969,11,31,15,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 44 | |
michael@0 | 45 | d1 = new Date(); |
michael@0 | 46 | d2 = Date.parse(Date(1969,11,31,16,0,0,0)); |
michael@0 | 47 | new TestCase(SECTION, "Date(1969,11,31,16,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 48 | |
michael@0 | 49 | d1 = new Date(); |
michael@0 | 50 | d2 = Date.parse(Date(1969,11,31,16,0,0,1)); |
michael@0 | 51 | new TestCase(SECTION, "Date(1969,11,31,16,0,0,1)", true, d2 - d1 <= 1000); |
michael@0 | 52 | |
michael@0 | 53 | // Dates around 2000 |
michael@0 | 54 | d1 = new Date(); |
michael@0 | 55 | d2 = Date.parse(Date(1999,11,15,59,59,999)); |
michael@0 | 56 | new TestCase(SECTION, "Date(1999,11,15,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 57 | |
michael@0 | 58 | d1 = new Date(); |
michael@0 | 59 | d2 = Date.parse(Date(1999,11,16,0,0,0,0)); |
michael@0 | 60 | new TestCase(SECTION, "Date(1999,11,16,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 61 | |
michael@0 | 62 | d1 = new Date(); |
michael@0 | 63 | d2 = Date.parse(Date(1999,11,31,23,59,59,999)); |
michael@0 | 64 | new TestCase(SECTION, "Date(1999,11,31,23,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 65 | |
michael@0 | 66 | d1 = new Date(); |
michael@0 | 67 | d2 = Date.parse(Date(2000,0,0,0,0,0,0)); |
michael@0 | 68 | new TestCase(SECTION, "Date(2000,0,1,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 69 | |
michael@0 | 70 | d1 = new Date(); |
michael@0 | 71 | d2 = Date.parse(Date(2000,0,0,0,0,0,1)); |
michael@0 | 72 | new TestCase(SECTION, "Date(2000,0,1,0,0,0,1)", true, d2 - d1 <= 1000); |
michael@0 | 73 | |
michael@0 | 74 | // Dates around 1900 |
michael@0 | 75 | |
michael@0 | 76 | d1 = new Date(); |
michael@0 | 77 | d2 = Date.parse(Date(1899,11,31,23,59,59,999)); |
michael@0 | 78 | new TestCase(SECTION, "Date(1899,11,31,23,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 79 | |
michael@0 | 80 | d1 = new Date(); |
michael@0 | 81 | d2 = Date.parse(Date(1900,0,1,0,0,0,0)); |
michael@0 | 82 | new TestCase(SECTION, "Date(1900,0,1,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 83 | |
michael@0 | 84 | d1 = new Date(); |
michael@0 | 85 | d2 = Date.parse(Date(1900,0,1,0,0,0,1)); |
michael@0 | 86 | new TestCase(SECTION, "Date(1900,0,1,0,0,0,1)", true, d2 - d1 <= 1000); |
michael@0 | 87 | |
michael@0 | 88 | d1 = new Date(); |
michael@0 | 89 | d2 = Date.parse(Date(1899,11,31,16,0,0,0,0)); |
michael@0 | 90 | new TestCase(SECTION, "Date(1899,11,31,16,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 91 | |
michael@0 | 92 | // Dates around feb 29, 2000 |
michael@0 | 93 | |
michael@0 | 94 | d1 = new Date(); |
michael@0 | 95 | d2 = Date.parse(Date(2000,1,29,0,0,0,0)); |
michael@0 | 96 | new TestCase(SECTION, "Date(2000,1,29,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 97 | |
michael@0 | 98 | d1 = new Date(); |
michael@0 | 99 | d2 = Date.parse(Date(2000,1,28,23,59,59,999)); |
michael@0 | 100 | new TestCase(SECTION, "Date(2000,1,28,23,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 101 | |
michael@0 | 102 | d1 = new Date(); |
michael@0 | 103 | d2 = Date.parse(Date(2000,1,27,16,0,0,0)); |
michael@0 | 104 | new TestCase(SECTION, "Date(2000,1,27,16,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 105 | |
michael@0 | 106 | // Dates around jan 1, 2005 |
michael@0 | 107 | d1 = new Date(); |
michael@0 | 108 | d2 = Date.parse(Date(2004,11,31,23,59,59,999)); |
michael@0 | 109 | new TestCase(SECTION, "Date(2004,11,31,23,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 110 | |
michael@0 | 111 | d1 = new Date(); |
michael@0 | 112 | d2 = Date.parse(Date(2005,0,1,0,0,0,0)); |
michael@0 | 113 | new TestCase(SECTION, "Date(2005,0,1,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 114 | |
michael@0 | 115 | d1 = new Date(); |
michael@0 | 116 | d2 = Date.parse(Date(2005,0,1,0,0,0,1)); |
michael@0 | 117 | new TestCase(SECTION, "Date(2005,0,1,0,0,0,1)", true, d2 - d1 <= 1000); |
michael@0 | 118 | |
michael@0 | 119 | d1 = new Date(); |
michael@0 | 120 | d2 = Date.parse(Date(2004,11,31,16,0,0,0,0)); |
michael@0 | 121 | new TestCase(SECTION, "Date(2004,11,31,16,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 122 | |
michael@0 | 123 | // Dates around jan 1, 2032 |
michael@0 | 124 | d1 = new Date(); |
michael@0 | 125 | d2 = Date.parse(Date(2031,11,31,23,59,59,999)); |
michael@0 | 126 | new TestCase(SECTION, "Date(2031,11,31,23,59,59,999)", true, d2 - d1 <= 1000); |
michael@0 | 127 | |
michael@0 | 128 | d1 = new Date(); |
michael@0 | 129 | d2 = Date.parse(Date(2032,0,1,0,0,0,0)); |
michael@0 | 130 | new TestCase(SECTION, "Date(2032,0,1,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 131 | |
michael@0 | 132 | d1 = new Date(); |
michael@0 | 133 | d2 = Date.parse(Date(2032,0,1,0,0,0,1)); |
michael@0 | 134 | new TestCase(SECTION, "Date(2032,0,1,0,0,0,1)", true, d2 - d1 <= 1000); |
michael@0 | 135 | |
michael@0 | 136 | d1 = new Date(); |
michael@0 | 137 | d2 = Date.parse(Date(2031,11,31,16,0,0,0,0)); |
michael@0 | 138 | new TestCase(SECTION, "Date(2031,11,31,16,0,0,0,0)", true, d2 - d1 <= 1000); |
michael@0 | 139 | |
michael@0 | 140 | test(); |