Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-187133.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: 06 January 2003
9 * SUMMARY: RegExp conformance test
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=187133
11 *
12 * The tests here employ the regular expression construct:
13 *
14 * (?!pattern)
15 *
16 * This is a "zero-width lookahead negative assertion".
17 * From the Perl documentation:
18 *
19 * For example, /foo(?!bar)/ matches any occurrence
20 * of 'foo' that isn't followed by 'bar'.
21 *
22 * It is "zero-width" means that it does not consume any characters and that
23 * the parens are non-capturing. A non-null match array in the example above
24 * will have only have length 1, not 2.
25 *
26 */
27 //-----------------------------------------------------------------------------
28 var gTestfile = 'regress-187133.js';
29 var i = 0;
30 var BUGNUMBER = 187133;
31 var summary = 'RegExp conformance test';
32 var status = '';
33 var statusmessages = new Array();
34 var pattern = '';
35 var patterns = new Array();
36 var string = '';
37 var strings = new Array();
38 var actualmatch = '';
39 var actualmatches = new Array();
40 var expectedmatch = '';
41 var expectedmatches = new Array();
42
43
44 pattern = /(\.(?!com|org)|\/)/;
45 status = inSection(1);
46 string = 'ah.info';
47 actualmatch = string.match(pattern);
48 expectedmatch = ['.', '.'];
49 addThis();
50
51 status = inSection(2);
52 string = 'ah/info';
53 actualmatch = string.match(pattern);
54 expectedmatch = ['/', '/'];
55 addThis();
56
57 status = inSection(3);
58 string = 'ah.com';
59 actualmatch = string.match(pattern);
60 expectedmatch = null;
61 addThis();
62
63
64 pattern = /(?!a|b)|c/;
65 status = inSection(4);
66 string = '';
67 actualmatch = string.match(pattern);
68 expectedmatch = [''];
69 addThis();
70
71 status = inSection(5);
72 string = 'bc';
73 actualmatch = string.match(pattern);
74 expectedmatch = [''];
75 addThis();
76
77 status = inSection(6);
78 string = 'd';
79 actualmatch = string.match(pattern);
80 expectedmatch = [''];
81 addThis();
82
83
84
85
86 //-------------------------------------------------------------------------------------------------
87 test();
88 //-------------------------------------------------------------------------------------------------
89
90
91 function addThis()
92 {
93 statusmessages[i] = status;
94 patterns[i] = pattern;
95 strings[i] = string;
96 actualmatches[i] = actualmatch;
97 expectedmatches[i] = expectedmatch;
98 i++;
99 }
100
101
102 function test()
103 {
104 enterFunc ('test');
105 printBugNumber(BUGNUMBER);
106 printStatus (summary);
107 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
108 exitFunc ('test');
109 }