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