2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9 * or implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
19 * Contributor(s): pschwartau@netscape.com
20 * Date: 06 February 2001
22 * SUMMARY: Arose from Bugzilla bug 78156:
23 * "m flag of regular expression does not work with $"
25 * See http://bugzilla.mozilla.org/show_bug.cgi?id=78156
27 * The m flag means a regular expression should search strings
28 * across multiple lines, i.e. across '\n', '\r'.
30 //-------------------------------------------------------------------------------------------------
33 var summary = 'Testing regular expressions with ^, $, and the m flag -';
35 var statusmessages = new Array();
37 var patterns = new Array();
39 var strings = new Array();
41 var actualmatches = new Array();
42 var expectedmatch = '';
43 var expectedmatches = new Array();
46 * All patterns have an m flag; all strings are multiline.
47 * Looking for digit characters at beginning/end of lines.
50 string = 'aaa\n789\r\nccc\r\n345';
51 status = inSection(1);
53 actualmatch = string.match(pattern);
54 expectedmatch = ['7','3'];
57 status = inSection(2);
59 actualmatch = string.match(pattern);
60 expectedmatch = ['9','5'];
63 string = 'aaa\n789\r\nccc\r\nddd';
64 status = inSection(3);
66 actualmatch = string.match(pattern);
67 expectedmatch = ['7'];
70 status = inSection(4);
72 actualmatch = string.match(pattern);
73 expectedmatch = ['9'];
78 //-------------------------------------------------------------------------------------------------
80 //-------------------------------------------------------------------------------------------------
86 statusmessages[i] = status;
87 patterns[i] = pattern;
89 actualmatches[i] = actualmatch;
90 expectedmatches[i] = expectedmatch;
99 printStatus (summary);
100 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);