Debian Codegraph @

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