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