Debian Codegraph @

rhino/testsrc/tests/js1_5/Error/regress-465377.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 var gTestfile = 'regress-465377.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 465377;
9 var summary = 'instanceof relations between Error objects';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 expect = actual = 'No Exception';
25
26 try
27 {
28 var list = [
29 "Error",
30 "InternalError",
31 "EvalError",
32 "RangeError",
33 "ReferenceError",
34 "SyntaxError",
35 "TypeError",
36 "URIError"
37 ];
38 var instances = [];
39
40 for (var i = 0; i != list.length; ++i) {
41 var name = list[i];
42 var constructor = this[name];
43 var tmp = constructor.name;
44 if (tmp !== name)
45 throw "Bad value for "+name+".name: "+uneval(tmp);
46 instances[i] = new constructor();
47 }
48
49 for (var i = 0; i != instances.length; ++i) {
50 var instance = instances[i];
51 var name = instance.name;
52 var constructor = instance.constructor;
53 if (constructor !== this[name])
54 throw "Bad value of (new "+name+").constructor: "+uneval(tmp);
55 var tmp = constructor.name;
56 if (tmp !== name)
57 throw "Bad value for constructor.name: "+uneval(tmp);
58 if (!(instance instanceof Object))
59 throw "Bad instanceof Object for "+name;
60 if (!(instance instanceof Error))
61 throw "Bad instanceof Error for "+name;
62 if (!(instance instanceof constructor))
63 throw "Bad instanceof constructor for "+name;
64 if (instance instanceof Function)
65 throw "Bad instanceof Function for "+name;
66 for (var j = 1; j != instances.length; ++j) {
67 if (i != j && instance instanceof instances[j].constructor) {
68 throw "Unexpected (new "+name+") instanceof "+ instances[j].name;
69 }
70 }
71 }
72
73 print("OK");
74 }
75 catch(ex)
76 {
77 actual = ex + '';
78 }
79 reportCompare(expect, actual, summary);
80
81 exitFunc ('test');
82 }