|
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: date-001.js |
|
9 Corresponds To: 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: christine@netscape.com |
|
25 Date: 12 november 1997 |
|
26 */ |
|
27 var SECTION = "date-001"; |
|
28 var VERSION = "JS1_4"; |
|
29 var TITLE = "Date.prototype.toString"; |
|
30 |
|
31 startTest(); |
|
32 writeHeaderToLog( SECTION + " "+ TITLE); |
|
33 |
|
34 var result = "Failed"; |
|
35 var exception = "No exception thrown"; |
|
36 var expect = "Passed"; |
|
37 |
|
38 try { |
|
39 var OBJ = new MyObject( new Date(0) ); |
|
40 result = OBJ.toString(); |
|
41 } catch ( e ) { |
|
42 result = expect; |
|
43 exception = e.toString(); |
|
44 } |
|
45 |
|
46 new TestCase( |
|
47 SECTION, |
|
48 "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + |
|
49 " (threw " + exception +")", |
|
50 expect, |
|
51 result ); |
|
52 |
|
53 test(); |
|
54 |
|
55 function MyObject( value ) { |
|
56 this.value = value; |
|
57 this.valueOf = new Function( "return this.value" ); |
|
58 this.toString = Date.prototype.toString; |
|
59 return this; |
|
60 } |