Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/15.10.4.1-6.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 15.10.4.1 new RegExp(pattern, flags)
8
9 If F contains any character other than "g", "i", or" m", or if it
10 contains the same one more than once, then throw a SyntaxError
11 exception.
12 */
13
14 var gTestfile = '15.10.4.1-6.js';
15 //-----------------------------------------------------------------------------
16 var BUGNUMBER = 476940;
17 var summary = 'Section 15.10.4.1 - RegExp with invalid flags';
18 var actual = '';
19 var expect = '';
20
21
22 //-----------------------------------------------------------------------------
23 test();
24 //-----------------------------------------------------------------------------
25
26 function test()
27 {
28 enterFunc ('test');
29 printBugNumber(BUGNUMBER);
30 printStatus (summary);
31
32 var invalidflags = ['ii', 'gg', 'mm', 'a'];
33
34 for (var i = 0; i < invalidflags.length; i++)
35 {
36 var flag = invalidflags[i];
37 expect = 'SyntaxError: invalid regular expression flag ' + flag.charAt(0);
38 actual = '';
39 try
40 {
41 new RegExp('bar', flag);
42 }
43 catch(ex)
44 {
45 actual = ex + '';
46 }
47 reportCompare(expect, actual, summary +
48 ': new RegExp("bar", "' + flag + '")');
49
50 actual = '';
51 try
52 {
53 eval("/bar/" + flag);
54 }
55 catch(ex)
56 {
57 actual = ex + '';
58 }
59 reportCompare(expect, actual, summary + ': /bar/' + flag + ')');
60 }
61
62 exitFunc ('test');
63 }