|
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: exception-006 |
|
9 * ECMA Section: |
|
10 * Description: Tests for JavaScript Standard Exceptions |
|
11 * |
|
12 * ToPrimitive error. |
|
13 * |
|
14 * Author: christine@netscape.com |
|
15 * Date: 31 August 1998 |
|
16 */ |
|
17 var SECTION = "exception-006"; |
|
18 var VERSION = "js1_4"; |
|
19 var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; |
|
20 |
|
21 startTest(); |
|
22 writeHeaderToLog( SECTION + " "+ TITLE); |
|
23 |
|
24 ToPrimitive_1(); |
|
25 |
|
26 test(); |
|
27 |
|
28 |
|
29 /** |
|
30 * Getting the [[DefaultValue]] of any instances of MyObject |
|
31 * should result in a runtime error in ToPrimitive. |
|
32 */ |
|
33 |
|
34 function MyObject() { |
|
35 this.toString = void 0; |
|
36 this.valueOf = void 0; |
|
37 } |
|
38 |
|
39 function ToPrimitive_1() { |
|
40 result = "failed: no exception thrown"; |
|
41 exception = null; |
|
42 |
|
43 try { |
|
44 result = new MyObject() + new MyObject(); |
|
45 } catch ( e ) { |
|
46 result = "passed: threw exception", |
|
47 exception = e.toString(); |
|
48 } finally { |
|
49 new TestCase( |
|
50 SECTION, |
|
51 "new MyObject() + new MyObject() [ exception is " + exception +" ]", |
|
52 "passed: threw exception", |
|
53 result ); |
|
54 } |
|
55 } |
|
56 |