js/src/tests/ecma/Date/15.9.5.23-2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Date/15.9.5.23-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     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.5.23-2.js
    1.12 +   ECMA Section:       15.9.5.23
    1.13 +   Description:        Date.prototype.setTime
    1.14 +
    1.15 +   1.  If the this value is not a Date object, generate a runtime error.
    1.16 +   2.  Call ToNumber(time).
    1.17 +   3.  Call TimeClip(Result(1)).
    1.18 +   4.  Set the [[Value]] property of the this value to Result(2).
    1.19 +   5.  Return the value of the [[Value]] property of the this value.
    1.20 +
    1.21 +   Author:             christine@netscape.com
    1.22 +   Date:               12 november 1997
    1.23 +*/
    1.24 +var SECTION = "15.9.5.23-2";
    1.25 +var VERSION = "ECMA_1";
    1.26 +startTest();
    1.27 +var TITLE   = "Date.prototype.setTime()";
    1.28 +
    1.29 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.30 +
    1.31 +test_times = new Array( TIME_NOW, TIME_1970, TIME_1900, TIME_2000 );
    1.32 +
    1.33 +for ( var j = 0; j < test_times.length; j++ ) {
    1.34 +  addTestCase( new Date(TIME_NOW), test_times[j] );
    1.35 +}
    1.36 +
    1.37 +new TestCase( SECTION,
    1.38 +	      "(new Date(NaN)).setTime()",
    1.39 +	      NaN,
    1.40 +	      (new Date(NaN)).setTime() );
    1.41 +
    1.42 +new TestCase( SECTION,
    1.43 +	      "Date.prototype.setTime.length",
    1.44 +	      1,
    1.45 +	      Date.prototype.setTime.length );
    1.46 +test();
    1.47 +
    1.48 +function addTestCase( d, t ) {
    1.49 +  new TestCase( SECTION,
    1.50 +		"( "+d+" ).setTime("+t+")",
    1.51 +		t,
    1.52 +		d.setTime(t) );
    1.53 +
    1.54 +  new TestCase( SECTION,
    1.55 +		"( "+d+" ).setTime("+(t+1.1)+")",
    1.56 +		TimeClip(t+1.1),
    1.57 +		d.setTime(t+1.1) );
    1.58 +
    1.59 +  new TestCase( SECTION,
    1.60 +		"( "+d+" ).setTime("+(t+1)+")",
    1.61 +		t+1,
    1.62 +		d.setTime(t+1) );
    1.63 +
    1.64 +  new TestCase( SECTION,
    1.65 +		"( "+d+" ).setTime("+(t-1)+")",
    1.66 +		t-1,
    1.67 +		d.setTime(t-1) );
    1.68 +
    1.69 +  new TestCase( SECTION,
    1.70 +		"( "+d+" ).setTime("+(t-TZ_ADJUST)+")",
    1.71 +		t-TZ_ADJUST,
    1.72 +		d.setTime(t-TZ_ADJUST) );
    1.73 +
    1.74 +  new TestCase( SECTION,
    1.75 +		"( "+d+" ).setTime("+(t+TZ_ADJUST)+")",
    1.76 +		t+TZ_ADJUST,
    1.77 +		d.setTime(t+TZ_ADJUST) );
    1.78 +}

mercurial