Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-240317.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-240317.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 240317;
9 var summary = 'Using Reserved identifiers warns';
10 var actual = '';
11 var expect = 'no error';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 function testvar(words)
17 {
18 var e;
19 expect = 'no error';
20 for (var i = 0; i < words.length; i++)
21 {
22 var word = words[i];
23
24 actual = '';
25 status = summary + ': ' + word;
26 try
27 {
28 eval('var ' + word + ';');
29 actual = 'no error';
30 }
31 catch(e)
32 {
33 actual = 'error';
34 status += ', ' + e.name + ': ' + e.message + ' ';
35 }
36 reportCompare(expect, actual, status);
37
38 actual = '';
39 status = summary + ': ' + word;
40 try
41 {
42 eval(word + ' = "foo";');
43 actual = 'no error';
44 }
45 catch(e)
46 {
47 actual = 'error';
48 status += ', ' + e.name + ': ' + e.message + ' ';
49 }
50 reportCompare(expect, actual, status);
51
52 }
53 }
54
55 // future reserved words
56 var reserved =
57 ['abstract', 'enum', 'int', 'short', 'boolean',
58 'interface', 'static', 'byte', 'extends',
59 'long', 'super', 'char', 'final', 'native',
60 'synchronized', 'class', 'float', 'package', 'throws',
61 'goto', 'private', 'transient',
62 'implements', 'protected', 'volatile', 'double',
63 'public'];
64
65 testvar(reserved);
66
67