]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/ecma_3/RegExp/regress-78156.js
JavaScriptCore-521.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_3 / RegExp / regress-78156.js
CommitLineData
b37bf2e1
A
1/*
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/
6*
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.
11*
12* The Original Code is mozilla.org code.
13*
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.
18*
19* Contributor(s): pschwartau@netscape.com
20* Date: 06 February 2001
21*
22* SUMMARY: Arose from Bugzilla bug 78156:
23* "m flag of regular expression does not work with $"
24*
25* See http://bugzilla.mozilla.org/show_bug.cgi?id=78156
26*
27* The m flag means a regular expression should search strings
28* across multiple lines, i.e. across '\n', '\r'.
29*/
30//-------------------------------------------------------------------------------------------------
31var i = 0;
32var bug = 78156;
33var summary = 'Testing regular expressions with ^, $, and the m flag -';
34var status = '';
35var statusmessages = new Array();
36var pattern = '';
37var patterns = new Array();
38var string = '';
39var strings = new Array();
40var actualmatch = '';
41var actualmatches = new Array();
42var expectedmatch = '';
43var expectedmatches = new Array();
44
45/*
46 * All patterns have an m flag; all strings are multiline.
47 * Looking for digit characters at beginning/end of lines.
48 */
49
50string = 'aaa\n789\r\nccc\r\n345';
51 status = inSection(1);
52 pattern = /^\d/gm;
53 actualmatch = string.match(pattern);
54 expectedmatch = ['7','3'];
55 addThis();
56
57 status = inSection(2);
58 pattern = /\d$/gm;
59 actualmatch = string.match(pattern);
60 expectedmatch = ['9','5'];
61 addThis();
62
63string = 'aaa\n789\r\nccc\r\nddd';
64 status = inSection(3);
65 pattern = /^\d/gm;
66 actualmatch = string.match(pattern);
67 expectedmatch = ['7'];
68 addThis();
69
70 status = inSection(4);
71 pattern = /\d$/gm;
72 actualmatch = string.match(pattern);
73 expectedmatch = ['9'];
74 addThis();
75
76
77
78//-------------------------------------------------------------------------------------------------
79test();
80//-------------------------------------------------------------------------------------------------
81
82
83
84function addThis()
85{
86 statusmessages[i] = status;
87 patterns[i] = pattern;
88 strings[i] = string;
89 actualmatches[i] = actualmatch;
90 expectedmatches[i] = expectedmatch;
91 i++;
92}
93
94
95function test()
96{
97 enterFunc ('test');
98 printBugNumber (bug);
99 printStatus (summary);
100 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
101 exitFunc ('test');
102}