1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * Date: 06 February 2001
42 * SUMMARY: Arose from Bugzilla bug 78156:
43 * "m flag of regular expression does not work with $"
45 * See http://bugzilla.mozilla.org/show_bug.cgi?id=78156
47 * The m flag means a regular expression should search strings
48 * across multiple lines, i.e. across '\n', '\r'.
50 //-----------------------------------------------------------------------------
52 var BUGNUMBER = 78156;
53 var summary = 'Testing regular expressions with ^, $, and the m flag -';
55 var statusmessages = new Array();
57 var patterns = new Array();
59 var strings = new Array();
61 var actualmatches = new Array();
62 var expectedmatch = '';
63 var expectedmatches = new Array();
66 * All patterns have an m flag; all strings are multiline.
67 * Looking for digit characters at beginning/end of lines.
70 string = 'aaa\n789\r\nccc\r\n345';
71 status = inSection(1);
73 actualmatch = string.match(pattern);
74 expectedmatch = ['7','3'];
77 status = inSection(2);
79 actualmatch = string.match(pattern);
80 expectedmatch = ['9','5'];
83 string = 'aaa\n789\r\nccc\r\nddd';
84 status = inSection(3);
86 actualmatch = string.match(pattern);
87 expectedmatch = ['7'];
90 status = inSection(4);
92 actualmatch = string.match(pattern);
93 expectedmatch = ['9'];
98 //-------------------------------------------------------------------------------------------------
100 //-------------------------------------------------------------------------------------------------
106 statusmessages[i] = status;
107 patterns[i] = pattern;
109 actualmatches[i] = actualmatch;
110 expectedmatches[i] = expectedmatch;
118 printBugNumber(BUGNUMBER);
119 printStatus (summary);
120 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);