js/src/tests/ecma_2/Exceptions/exception-007.js

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

mercurial