Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/exception-006.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 = 'exception-006.js';
7
8 /**
9 * File Name: exception-006
10 * ECMA Section:
11 * Description: Tests for JavaScript Standard Exceptions
12 *
13 * ToPrimitive error.
14 *
15 * Author: [email protected]
16 * Date: 31 August 1998
17 */
18 var SECTION = "exception-006";
19 var VERSION = "js1_4";
20 var TITLE = "Tests for JavaScript Standard Exceptions: TypeError";
21
22 startTest();
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25 ToPrimitive_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 = void 0;
38 }
39
40 function ToPrimitive_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