1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Date/15.9.5.35-1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,106 @@ 1.4 +// |reftest| random-if(Android) 1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 + 1.11 +/** 1.12 + File Name: 15.9.5.35-1.js 1.13 + ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) 1.14 + Description: 1.15 + Author: christine@netscape.com 1.16 + Date: 12 november 1997 1.17 +*/ 1.18 +var SECTION = "15.9.5.35-1"; 1.19 +var VERSION = "ECMA_1"; 1.20 +startTest(); 1.21 + 1.22 +writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); 1.23 +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", 1.24 + UTCDateFromTime(SetUTCMonth(0,0)), 1.25 + LocalDateFromTime(SetUTCMonth(0,0)) ); 1.26 + 1.27 +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", 1.28 + UTCDateFromTime(SetUTCMonth(0,11)), 1.29 + LocalDateFromTime(SetUTCMonth(0,11)) ); 1.30 + 1.31 +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(5,4);TDATE", 1.32 + UTCDateFromTime(SetUTCMonth(0,5,4)), 1.33 + LocalDateFromTime(SetUTCMonth(0,5,4)) ); 1.34 + 1.35 +test(); 1.36 + 1.37 +function addNewTestCase( DateString, UTCDate, LocalDate) { 1.38 + DateCase = eval( DateString ); 1.39 + 1.40 + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); 1.41 + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); 1.42 + 1.43 + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); 1.44 + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); 1.45 + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); 1.46 + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); 1.47 + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); 1.48 + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); 1.49 + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); 1.50 + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); 1.51 + 1.52 + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); 1.53 + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); 1.54 + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); 1.55 + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); 1.56 + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); 1.57 + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); 1.58 + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); 1.59 + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); 1.60 + 1.61 + DateCase.toString = Object.prototype.toString; 1.62 + 1.63 + new TestCase( SECTION, 1.64 + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", 1.65 + "[object Date]", 1.66 + DateCase.toString() ); 1.67 +} 1.68 +function MyDate() { 1.69 + this.year = 0; 1.70 + this.month = 0; 1.71 + this.date = 0; 1.72 + this.hours = 0; 1.73 + this.minutes = 0; 1.74 + this.seconds = 0; 1.75 + this.ms = 0; 1.76 +} 1.77 +function LocalDateFromTime(t) { 1.78 + t = LocalTime(t); 1.79 + return ( MyDateFromTime(t) ); 1.80 +} 1.81 +function UTCDateFromTime(t) { 1.82 + return ( MyDateFromTime(t) ); 1.83 +} 1.84 +function MyDateFromTime( t ) { 1.85 + var d = new MyDate(); 1.86 + d.year = YearFromTime(t); 1.87 + d.month = MonthFromTime(t); 1.88 + d.date = DateFromTime(t); 1.89 + d.hours = HourFromTime(t); 1.90 + d.minutes = MinFromTime(t); 1.91 + d.seconds = SecFromTime(t); 1.92 + d.ms = msFromTime(t); 1.93 + 1.94 + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); 1.95 + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); 1.96 + d.day = WeekDay( d.value ); 1.97 + 1.98 + return (d); 1.99 +} 1.100 +function SetUTCMonth( t, month, date ) { 1.101 + var T = t; 1.102 + var MONTH = Number( month ); 1.103 + var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); 1.104 + 1.105 + var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); 1.106 + var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); 1.107 + 1.108 + return ( TimeClip(RESULT5) ); 1.109 +}