Debian Codegraph @

rhino/testsrc/tests/ecma_3/Exceptions/15.11.1.1.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 /*
7 *
8 * Date: 27 Nov 2002
9 * SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1).
10 */
11 //-----------------------------------------------------------------------------
12 var gTestfile = '15.11.1.1.js';
13 var UBound = 0;
14 var BUGNUMBER = '';
15 var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)';
16 var status = '';
17 var statusitems = [];
18 var actual = '';
19 var actualvalues = [];
20 var expect= '';
21 var expectedvalues = [];
22 var EMPTY_STRING = '';
23 var EXPECTED_FORMAT = 0;
24
25
26 function otherScope(msg)
27 {
28 return Error(msg);
29 }
30
31
32 status = inSection(1);
33 var err1 = Error('msg1');
34 actual = examineThis(err1, 'msg1');
35 expect = EXPECTED_FORMAT;
36 addThis();
37
38 status = inSection(2);
39 var err2 = otherScope('msg2');
40 actual = examineThis(err2, 'msg2');
41 expect = EXPECTED_FORMAT;
42 addThis();
43
44 status = inSection(3);
45 var err3 = otherScope();
46 actual = examineThis(err3, EMPTY_STRING);
47 expect = EXPECTED_FORMAT;
48 addThis();
49
50 status = inSection(4);
51 var err4 = eval("Error('msg4')");
52 actual = examineThis(err4, 'msg4');
53 expect = EXPECTED_FORMAT;
54 addThis();
55
56
57
58 //-----------------------------------------------------------------------------
59 test();
60 //-----------------------------------------------------------------------------
61
62
63
64 /*
65 * Searches err.toString() for err.name + ':' + err.message,
66 * with possible whitespace on each side of the colon sign.
67 *
68 * We allow for no colon in case err.message was not provided by the user.
69 * In such a case, SpiderMonkey and Rhino currently set err.message = '',
70 * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case.
71 *
72 * If this is ever changed to a non-empty string, e.g. 'undefined',
73 * you may have to modify |pattern| to take that into account -
74 *
75 */
76 function examineThis(err, msg)
77 {
78 var pattern = err.name + '\\s*:?\\s*' + msg;
79 return err.toString().search(RegExp(pattern));
80 }
81
82
83 function addThis()
84 {
85 statusitems[UBound] = status;
86 actualvalues[UBound] = actual;
87 expectedvalues[UBound] = expect;
88 UBound++;
89 }
90
91
92 function test()
93 {
94 enterFunc ('test');
95 printBugNumber(BUGNUMBER);
96 printStatus (summary);
97
98 for (var i = 0; i < UBound; i++)
99 {
100 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
101 }
102
103 exitFunc ('test');
104 }