js/src/tests/ecma/Date/15.9.5.29-1.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // |reftest| random-if(Android)
     2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 /**
     9    File Name:          15.9.5.29-1.js
    10    ECMA Section:       15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] )
    11    Description:
    12    If sec is not specified, this behaves as if sec were specified with the
    13    value getUTCSeconds ( ).
    15    If ms is not specified, this behaves as if ms were specified with the value
    16    getUTCMilliseconds( ).
    18    1.  Let t be this time value.
    19    2.  Call ToNumber(min).
    20    3.  If sec is not specified, compute SecFromTime(t); otherwise, call
    21    ToNumber(sec).
    22    4.  If ms is not specified, compute msFromTime(t); otherwise, call
    23    ToNumber(ms).
    24    5.  Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)).
    25    6.  Compute MakeDate(Day(t), Result(5)).
    26    7.  Set the [[Value]] property of the this value to TimeClip(Result(6)).
    27    8.  Return the value of the [[Value]] property of the this value.
    29    Author:             christine@netscape.com
    30    Date:               12 november 1997
    31 */
    32 var SECTION = "15.9.5.29-1";
    33 var VERSION = "ECMA_1";
    34 startTest();
    36 writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )");
    38 addNewTestCase( 0, 0, void 0, void 0,
    39 		"TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE",
    40 		UTCDateFromTime(SetUTCMinutes(0,0,0,0)),
    41 		LocalDateFromTime(SetUTCMinutes(0,0,0,0)) );
    43 addNewTestCase( 28800000, 59, 59, void 0,
    44 		"TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE",
    45 		UTCDateFromTime(SetUTCMinutes(28800000,59,59)),
    46 		LocalDateFromTime(SetUTCMinutes(28800000,59,59)) );
    48 addNewTestCase( 28800000, 59, 59, 999,
    49 		"TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE",
    50 		UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)),
    51 		LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) );
    53 addNewTestCase( 28800000, 59, void 0, void 0,
    54 		"TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE",
    55 		UTCDateFromTime(SetUTCMinutes(28800000,59)),
    56 		LocalDateFromTime(SetUTCMinutes(28800000,59)) );
    58 addNewTestCase( 28800000, -480, 0, 0,
    59 		"TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE",
    60 		UTCDateFromTime(SetUTCMinutes(28800000,-480)),
    61 		LocalDateFromTime(SetUTCMinutes(28800000,-480)) );
    63 addNewTestCase( 946684800000, 1234567, void 0, void 0,
    64 		"TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE",
    65 		UTCDateFromTime(SetUTCMinutes(946684800000,1234567)),
    66 		LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) );
    68 addNewTestCase( -2208988800000, 59, 999, void 0,
    69 		"TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE",
    70 		UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)),
    71 		LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) );
    73 test();
    75 function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) {
    76   var DateCase = new Date( time );
    78   if ( sec == void 0 ) {
    79     DateCase.setUTCMinutes( min );
    80   } else {
    81     if ( ms == void 0 ) {
    82       DateCase.setUTCMinutes( min, sec );
    83     } else {
    84       DateCase.setUTCMinutes( min, sec, ms );
    85     }
    86   }
    88   new TestCase( SECTION, DateString+".getTime()",             UTCDate.value,       DateCase.getTime() );
    89   new TestCase( SECTION, DateString+".valueOf()",             UTCDate.value,       DateCase.valueOf() );
    91   new TestCase( SECTION, DateString+".getUTCFullYear()",      UTCDate.year,    DateCase.getUTCFullYear() );
    92   new TestCase( SECTION, DateString+".getUTCMonth()",         UTCDate.month,  DateCase.getUTCMonth() );
    93   new TestCase( SECTION, DateString+".getUTCDate()",          UTCDate.date,   DateCase.getUTCDate() );
    95   new TestCase( SECTION, DateString+".getUTCHours()",         UTCDate.hours,  DateCase.getUTCHours() );
    96   new TestCase( SECTION, DateString+".getUTCMinutes()",       UTCDate.minutes,DateCase.getUTCMinutes() );
    97   new TestCase( SECTION, DateString+".getUTCSeconds()",       UTCDate.seconds,DateCase.getUTCSeconds() );
    98   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  UTCDate.ms,     DateCase.getUTCMilliseconds() );
   100   new TestCase( SECTION, DateString+".getFullYear()",         LocalDate.year,       DateCase.getFullYear() );
   101   new TestCase( SECTION, DateString+".getMonth()",            LocalDate.month,      DateCase.getMonth() );
   102   new TestCase( SECTION, DateString+".getDate()",             LocalDate.date,       DateCase.getDate() );
   104   new TestCase( SECTION, DateString+".getHours()",            LocalDate.hours,      DateCase.getHours() );
   105   new TestCase( SECTION, DateString+".getMinutes()",          LocalDate.minutes,    DateCase.getMinutes() );
   106   new TestCase( SECTION, DateString+".getSeconds()",          LocalDate.seconds,    DateCase.getSeconds() );
   107   new TestCase( SECTION, DateString+".getMilliseconds()",     LocalDate.ms,         DateCase.getMilliseconds() );
   109   DateCase.toString = Object.prototype.toString;
   111   new TestCase( SECTION,
   112 		DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
   113 		"[object Date]",
   114 		DateCase.toString() );
   115 }
   116 function MyDate() {
   117   this.year = 0;
   118   this.month = 0;
   119   this.date = 0;
   120   this.hours = 0;
   121   this.minutes = 0;
   122   this.seconds = 0;
   123   this.ms = 0;
   124 }
   125 function LocalDateFromTime(t) {
   126   t = LocalTime(t);
   127   return ( MyDateFromTime(t) );
   128 }
   129 function UTCDateFromTime(t) {
   130   return ( MyDateFromTime(t) );
   131 }
   132 function MyDateFromTime( t ) {
   133   var d = new MyDate();
   134   d.year = YearFromTime(t);
   135   d.month = MonthFromTime(t);
   136   d.date = DateFromTime(t);
   137   d.hours = HourFromTime(t);
   138   d.minutes = MinFromTime(t);
   139   d.seconds = SecFromTime(t);
   140   d.ms = msFromTime(t);
   142   d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
   143   d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
   144   d.day = WeekDay( d.value );
   146   return (d);
   147 }
   148 function SetUTCMinutes( t, min, sec, ms ) {
   149   var TIME = t;
   150   var MIN =  Number(min);
   151   var SEC  = ( sec == void 0) ? SecFromTime(TIME) : Number(sec);
   152   var MS   = ( ms == void 0 ) ? msFromTime(TIME)  : Number(ms);
   153   var RESULT5 = MakeTime( HourFromTime( TIME ),
   154 			  MIN,
   155 			  SEC,
   156 			  MS );
   157   return ( TimeClip(MakeDate(Day(TIME),RESULT5)) );
   158 }

mercurial