1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Date/15.9.4.3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,200 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 363578; 1.11 +var summary = '15.9.4.3 - Date.UTC edge-case arguments.'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 + 1.16 +//----------------------------------------------------------------------------- 1.17 +test(); 1.18 +//----------------------------------------------------------------------------- 1.19 + 1.20 +function test() 1.21 +{ 1.22 + enterFunc ('test'); 1.23 + printBugNumber(BUGNUMBER); 1.24 + printStatus (summary); 1.25 + 1.26 + // 1.27 + 1.28 + expect = 31; 1.29 + actual = (new Date(Date.UTC(2006, 0, 0)).getUTCDate()); 1.30 + reportCompare(expect, actual, summary + ': date 0'); 1.31 + 1.32 + expect = 0; 1.33 + actual = (new Date(Date.UTC(2006, 0, 0, 0)).getUTCHours()); 1.34 + reportCompare(expect, actual, summary + ': hours 0'); 1.35 + 1.36 + expect = 0; 1.37 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0)).getUTCMinutes()); 1.38 + reportCompare(expect, actual, summary + ': minutes 0'); 1.39 + 1.40 + expect = 0; 1.41 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0)).getUTCSeconds()); 1.42 + reportCompare(expect, actual, summary + ': seconds 0'); 1.43 + 1.44 + expect = 0; 1.45 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, 0)).getUTCMilliseconds()); 1.46 + reportCompare(expect, actual, summary + ': milliseconds 0'); 1.47 + 1.48 + // 1.49 + 1.50 + expect = 30; 1.51 + actual = (new Date(Date.UTC(2006, 0, -1)).getUTCDate()); 1.52 + reportCompare(expect, actual, summary + ': date -1'); 1.53 + 1.54 + expect = 23; 1.55 + actual = (new Date(Date.UTC(2006, 0, 0, -1)).getUTCHours()); 1.56 + reportCompare(expect, actual, summary + ': hours -1'); 1.57 + 1.58 + expect = 59; 1.59 + actual = (new Date(Date.UTC(2006, 0, 0, 0, -1)).getUTCMinutes()); 1.60 + reportCompare(expect, actual, summary + ': minutes -1'); 1.61 + 1.62 + expect = 59; 1.63 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, -1)).getUTCSeconds()); 1.64 + reportCompare(expect, actual, summary + ': seconds -1'); 1.65 + 1.66 + expect = 999; 1.67 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, -1)).getUTCMilliseconds()); 1.68 + reportCompare(expect, actual, summary + ': milliseconds -1'); 1.69 + 1.70 + // 1.71 + 1.72 + expect = true; 1.73 + actual = isNaN(new Date(Date.UTC(2006, 0, undefined)).getUTCDate()); 1.74 + reportCompare(expect, actual, summary + ': date undefined'); 1.75 + 1.76 + expect = true; 1.77 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, undefined)).getUTCHours()); 1.78 + reportCompare(expect, actual, summary + ': hours undefined'); 1.79 + 1.80 + expect = true; 1.81 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, undefined)).getUTCMinutes()); 1.82 + reportCompare(expect, actual, summary + ': minutes undefined'); 1.83 + 1.84 + expect = true; 1.85 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, undefined)).getUTCSeconds()); 1.86 + reportCompare(expect, actual, summary + ': seconds undefined'); 1.87 + 1.88 + expect = true; 1.89 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, undefined)).getUTCMilliseconds()); 1.90 + reportCompare(expect, actual, summary + ': milliseconds undefined'); 1.91 + 1.92 + // 1.93 + 1.94 + expect = true; 1.95 + actual = isNaN(new Date(Date.UTC(2006, 0, {})).getUTCDate()); 1.96 + reportCompare(expect, actual, summary + ': date {}'); 1.97 + 1.98 + expect = true; 1.99 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, {})).getUTCHours()); 1.100 + reportCompare(expect, actual, summary + ': hours {}'); 1.101 + 1.102 + expect = true; 1.103 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, {})).getUTCMinutes()); 1.104 + reportCompare(expect, actual, summary + ': minutes {}'); 1.105 + 1.106 + expect = true; 1.107 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, {})).getUTCSeconds()); 1.108 + reportCompare(expect, actual, summary + ': seconds {}'); 1.109 + 1.110 + expect = true; 1.111 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, {})).getUTCMilliseconds()); 1.112 + reportCompare(expect, actual, summary + ': milliseconds {}'); 1.113 + 1.114 + // 1.115 + 1.116 + expect = 31; 1.117 + actual = (new Date(Date.UTC(2006, 0, null)).getUTCDate()); 1.118 + reportCompare(expect, actual, summary + ': date null'); 1.119 + 1.120 + expect = 0; 1.121 + actual = (new Date(Date.UTC(2006, 0, 0, null)).getUTCHours()); 1.122 + reportCompare(expect, actual, summary + ': hours null'); 1.123 + 1.124 + expect = 0; 1.125 + actual = (new Date(Date.UTC(2006, 0, 0, 0, null)).getUTCMinutes()); 1.126 + reportCompare(expect, actual, summary + ': minutes null'); 1.127 + 1.128 + expect = 0; 1.129 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, null)).getUTCSeconds()); 1.130 + reportCompare(expect, actual, summary + ': seconds null'); 1.131 + 1.132 + expect = 0; 1.133 + actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, null)).getUTCMilliseconds()); 1.134 + reportCompare(expect, actual, summary + ': milliseconds null'); 1.135 + 1.136 + // 1.137 + 1.138 + expect = true; 1.139 + actual = isNaN(new Date(Date.UTC(2006, 0, Infinity)).getUTCDate()); 1.140 + reportCompare(expect, actual, summary + ': date Infinity'); 1.141 + 1.142 + expect = true; 1.143 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, Infinity)).getUTCHours()); 1.144 + reportCompare(expect, actual, summary + ': hours Infinity'); 1.145 + 1.146 + expect = true; 1.147 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, Infinity)).getUTCMinutes()); 1.148 + reportCompare(expect, actual, summary + ': minutes Infinity'); 1.149 + 1.150 + expect = true; 1.151 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, Infinity)).getUTCSeconds()); 1.152 + reportCompare(expect, actual, summary + ': seconds Infinity'); 1.153 + 1.154 + expect = true; 1.155 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, Infinity)).getUTCMilliseconds()); 1.156 + reportCompare(expect, actual, summary + ': milliseconds Infinity'); 1.157 + 1.158 + // 1.159 + 1.160 + expect = true; 1.161 + actual = isNaN(new Date(Date.UTC(2006, 0, -Infinity)).getUTCDate()); 1.162 + reportCompare(expect, actual, summary + ': date -Infinity'); 1.163 + 1.164 + expect = true; 1.165 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, -Infinity)).getUTCHours()); 1.166 + reportCompare(expect, actual, summary + ': hours -Infinity'); 1.167 + 1.168 + expect = true; 1.169 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, -Infinity)).getUTCMinutes()); 1.170 + reportCompare(expect, actual, summary + ': minutes -Infinity'); 1.171 + 1.172 + expect = true; 1.173 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, -Infinity)).getUTCSeconds()); 1.174 + reportCompare(expect, actual, summary + ': seconds -Infinity'); 1.175 + 1.176 + expect = true; 1.177 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, -Infinity)).getUTCMilliseconds()); 1.178 + reportCompare(expect, actual, summary + ': milliseconds -Infinity'); 1.179 + 1.180 + // 1.181 + 1.182 + expect = true; 1.183 + actual = isNaN(new Date(Date.UTC(2006, 0, NaN)).getUTCDate()); 1.184 + reportCompare(expect, actual, summary + ': date NaN'); 1.185 + 1.186 + expect = true; 1.187 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, NaN)).getUTCHours()); 1.188 + reportCompare(expect, actual, summary + ': hours NaN'); 1.189 + 1.190 + expect = true; 1.191 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, NaN)).getUTCMinutes()); 1.192 + reportCompare(expect, actual, summary + ': minutes NaN'); 1.193 + 1.194 + expect = true; 1.195 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, NaN)).getUTCSeconds()); 1.196 + reportCompare(expect, actual, summary + ': seconds NaN'); 1.197 + 1.198 + expect = true; 1.199 + actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, NaN)).getUTCMilliseconds()); 1.200 + reportCompare(expect, actual, summary + ': milliseconds NaN'); 1.201 + 1.202 + exitFunc ('test'); 1.203 +}