Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.5.2-2-n.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.2-2-n.js';
7
8 /**
9 File Name: 15.9.5.2-2.js
10 ECMA Section: 15.9.5.2 Date.prototype.toString
11 Description:
12 This function returns a string value. The contents of the string are
13 implementation dependent, but are intended to represent the Date in a
14 convenient, human-readable form in the current time zone.
15
16 The toString function is not generic; it generates a runtime error if its
17 this value is not a Date object. Therefore it cannot be transferred to
18 other kinds of objects for use as a method.
19
20
21 This verifies that calling toString on an object that is not a string
22 generates a runtime error.
23
24 Author: [email protected]
25 Date: 12 november 1997
26 */
27
28 var SECTION = "15.9.5.2-2";
29 var VERSION = "ECMA_1";
30 startTest();
31 var TITLE = "Date.prototype.toString";
32
33 writeHeaderToLog( SECTION + " "+ TITLE);
34
35 var OBJ = new MyObject( new Date(0) );
36
37 DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.toString()";
38 EXPECTED = "error";
39
40 new TestCase( SECTION,
41 "var OBJ = new MyObject( new Date(0) ); OBJ.toString()",
42 "error",
43 eval("OBJ.toString()") );
44 test();
45
46 function MyObject( value ) {
47 this.value = value;
48 this.valueOf = new Function( "return this.value" );
49 this.toString = Date.prototype.toString;
50 return this;
51 }