js/src/tests/ecma/Date/15.9.5.23-9.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-9.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     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 +
    1.25 +var SECTION = "15.9.5.23-2";
    1.26 +var VERSION = "ECMA_1";
    1.27 +startTest();
    1.28 +var TITLE   = "Date.prototype.setTime()";
    1.29 +
    1.30 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.31 +
    1.32 +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000,
    1.33 +			UTC_FEB_29_2000, UTC_JAN_1_2005 );
    1.34 +
    1.35 +
    1.36 +for ( var j = 0; j < test_times.length; j++ ) {
    1.37 +  addTestCase( new Date(UTC_JAN_1_2005), test_times[j] );
    1.38 +}
    1.39 +
    1.40 +test();
    1.41 +
    1.42 +function addTestCase( d, t ) {
    1.43 +  new TestCase( SECTION,
    1.44 +		"( "+d+" ).setTime("+t+")",
    1.45 +		t,
    1.46 +		d.setTime(t) );
    1.47 +
    1.48 +  new TestCase( SECTION,
    1.49 +		"( "+d+" ).setTime("+(t+1.1)+")",
    1.50 +		TimeClip(t+1.1),
    1.51 +		d.setTime(t+1.1) );
    1.52 +
    1.53 +  new TestCase( SECTION,
    1.54 +		"( "+d+" ).setTime("+(t+1)+")",
    1.55 +		t+1,
    1.56 +		d.setTime(t+1) );
    1.57 +
    1.58 +  new TestCase( SECTION,
    1.59 +		"( "+d+" ).setTime("+(t-1)+")",
    1.60 +		t-1,
    1.61 +		d.setTime(t-1) );
    1.62 +
    1.63 +  new TestCase( SECTION,
    1.64 +		"( "+d+" ).setTime("+(t-TZ_ADJUST)+")",
    1.65 +		t-TZ_ADJUST,
    1.66 +		d.setTime(t-TZ_ADJUST) );
    1.67 +
    1.68 +  new TestCase( SECTION,
    1.69 +		"( "+d+" ).setTime("+(t+TZ_ADJUST)+")",
    1.70 +		t+TZ_ADJUST,
    1.71 +		d.setTime(t+TZ_ADJUST) );
    1.72 +}

mercurial