1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Date/15.9.3.2-4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,108 @@ 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 +/** 1.11 + File Name: 15.9.3.1.js 1.12 + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) 1.13 + Description: The [[Prototype]] property of the newly constructed 1.14 + object is set to the original Date prototype object, 1.15 + the one that is the initial value of Date.prototype. 1.16 + 1.17 + The [[Class]] property of the newly constructed object 1.18 + is set as follows: 1.19 + 1. Call ToNumber(year) 1.20 + 2. Call ToNumber(month) 1.21 + 3. Call ToNumber(date) 1.22 + 4. Call ToNumber(hours) 1.23 + 5. Call ToNumber(minutes) 1.24 + 6. Call ToNumber(seconds) 1.25 + 7. Call ToNumber(ms) 1.26 + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= 1.27 + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, 1.28 + Result(8) is Result(1) 1.29 + 9. Compute MakeDay(Result(8), Result(2), Result(3) 1.30 + 10. Compute MakeTime(Result(4), Result(5), Result(6), 1.31 + Result(7) 1.32 + 11. Compute MakeDate(Result(9), Result(10)) 1.33 + 12. Set the [[Value]] property of the newly constructed 1.34 + object to TimeClip(UTC(Result(11))). 1.35 + 1.36 + 1.37 + This tests the returned value of a newly constructed 1.38 + Date object. 1.39 + 1.40 + Author: christine@netscape.com 1.41 + Date: 7 july 1997 1.42 +*/ 1.43 + 1.44 +var TIME = 0; 1.45 +var UTC_YEAR = 1; 1.46 +var UTC_MONTH = 2; 1.47 +var UTC_DATE = 3; 1.48 +var UTC_DAY = 4; 1.49 +var UTC_HOURS = 5; 1.50 +var UTC_MINUTES = 6; 1.51 +var UTC_SECONDS = 7; 1.52 +var UTC_MS = 8; 1.53 + 1.54 +var YEAR = 9; 1.55 +var MONTH = 10; 1.56 +var DATE = 11; 1.57 +var DAY = 12; 1.58 +var HOURS = 13; 1.59 +var MINUTES = 14; 1.60 +var SECONDS = 15; 1.61 +var MS = 16; 1.62 + 1.63 +// for TCMS, the gTestcases array must be global. 1.64 +var SECTION = "15.9.3.1"; 1.65 +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; 1.66 + 1.67 +writeHeaderToLog( SECTION+" " +TITLE ); 1.68 + 1.69 +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; 1.70 + 1.71 +// Dates around Feb 29, 2000 1.72 +addNewTestCase( new Date(2000,1,28,16,0,0,0), 1.73 + "new Date(2000,1,28,16,0,0,0)", 1.74 + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); 1.75 + 1.76 +addNewTestCase( new Date(2000,1,29,0,0,0,0), 1.77 + "new Date(2000,1,29,0,0,0,0)", 1.78 + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); 1.79 + 1.80 +addNewTestCase( new Date(2000,1,29,24,0,0,0), 1.81 + "new Date(2000,1,29,24,0,0,0)", 1.82 + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); 1.83 + 1.84 +test(); 1.85 + 1.86 +function addNewTestCase( DateCase, DateString, ResultArray ) { 1.87 + //adjust hard-coded ResultArray for tester's timezone instead of PST 1.88 + adjustResultArray(ResultArray); 1.89 + 1.90 + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); 1.91 + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); 1.92 + 1.93 + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); 1.94 + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); 1.95 + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); 1.96 + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); 1.97 + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); 1.98 + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); 1.99 + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); 1.100 + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); 1.101 + 1.102 + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); 1.103 + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); 1.104 + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); 1.105 + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); 1.106 + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); 1.107 + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); 1.108 + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); 1.109 + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); 1.110 + 1.111 +}