Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.5.23-2.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = '15.9.5.23-2.js';
7
8 /**
9 File Name: 15.9.5.23-2.js
10 ECMA Section: 15.9.5.23
11 Description: Date.prototype.setTime
12
13 1. If the this value is not a Date object, generate a runtime error.
14 2. Call ToNumber(time).
15 3. Call TimeClip(Result(1)).
16 4. Set the [[Value]] property of the this value to Result(2).
17 5. Return the value of the [[Value]] property of the this value.
18
19 Author: [email protected]
20 Date: 12 november 1997
21 */
22 var SECTION = "15.9.5.23-2";
23 var VERSION = "ECMA_1";
24 startTest();
25 var TITLE = "Date.prototype.setTime()";
26
27 writeHeaderToLog( SECTION + " "+ TITLE);
28
29 test_times = new Array( TIME_NOW, TIME_1970, TIME_1900, TIME_2000 );
30
31 for ( var j = 0; j < test_times.length; j++ ) {
32 addTestCase( new Date(TIME_NOW), test_times[j] );
33 }
34
35 new TestCase( SECTION,
36 "(new Date(NaN)).setTime()",
37 NaN,
38 (new Date(NaN)).setTime() );
39
40 new TestCase( SECTION,
41 "Date.prototype.setTime.length",
42 1,
43 Date.prototype.setTime.length );
44 test();
45
46 function addTestCase( d, t ) {
47 new TestCase( SECTION,
48 "( "+d+" ).setTime("+t+")",
49 t,
50 d.setTime(t) );
51
52 new TestCase( SECTION,
53 "( "+d+" ).setTime("+(t+1.1)+")",
54 TimeClip(t+1.1),
55 d.setTime(t+1.1) );
56
57 new TestCase( SECTION,
58 "( "+d+" ).setTime("+(t+1)+")",
59 t+1,
60 d.setTime(t+1) );
61
62 new TestCase( SECTION,
63 "( "+d+" ).setTime("+(t-1)+")",
64 t-1,
65 d.setTime(t-1) );
66
67 new TestCase( SECTION,
68 "( "+d+" ).setTime("+(t-TZ_ADJUST)+")",
69 t-TZ_ADJUST,
70 d.setTime(t-TZ_ADJUST) );
71
72 new TestCase( SECTION,
73 "( "+d+" ).setTime("+(t+TZ_ADJUST)+")",
74 t+TZ_ADJUST,
75 d.setTime(t+TZ_ADJUST) );
76 }