js/src/tests/ecma_3/RegExp/15.10.4.1-6.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:7e6b8da36769
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 //-----------------------------------------------------------------------------
15 var BUGNUMBER = 476940;
16 var summary = 'Section 15.10.4.1 - RegExp with invalid flags';
17 var actual = '';
18 var expect = '';
19
20
21 //-----------------------------------------------------------------------------
22 test();
23 //-----------------------------------------------------------------------------
24
25 function test()
26 {
27 enterFunc ('test');
28 printBugNumber(BUGNUMBER);
29 printStatus (summary);
30
31 var invalidflags = ['ii', 'gg', 'mm', 'a'];
32
33 for (var i = 0; i < invalidflags.length; i++)
34 {
35 var flag = invalidflags[i];
36 expect = 'SyntaxError: invalid regular expression flag ' + flag.charAt(0);
37 actual = '';
38 try
39 {
40 new RegExp('bar', flag);
41 }
42 catch(ex)
43 {
44 actual = ex + '';
45 }
46 reportCompare(expect, actual, summary +
47 ': new RegExp("bar", "' + flag + '")');
48
49 actual = '';
50 try
51 {
52 eval("/bar/" + flag);
53 }
54 catch(ex)
55 {
56 actual = ex + '';
57 }
58 reportCompare(expect, actual, summary + ': /bar/' + flag + ')');
59 }
60
61 exitFunc ('test');
62 }

mercurial