Debian Codegraph @

js/src/tests/non262/RegExp/regress-165353.js

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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: 31 August 2002
9 * SUMMARY: RegExp conformance test
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=165353
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var i = 0;
15 var BUGNUMBER = 165353;
16 var summary = 'RegExp conformance test';
17 var status = '';
18 var statusmessages = new Array();
19 var pattern = '';
20 var patterns = new Array();
21 var string = '';
22 var strings = new Array();
23 var actualmatch = '';
24 var actualmatches = new Array();
25 var expectedmatch = '';
26 var expectedmatches = new Array();
27
28
29 pattern = /^([a-z]+)*[a-z]$/;
30 status = inSection(1);
31 string = 'a';
32 actualmatch = string.match(pattern);
33 expectedmatch = Array('a', undefined);
34 addThis();
35
36 status = inSection(2);
37 string = 'ab';
38 actualmatch = string.match(pattern);
39 expectedmatch = Array('ab', 'a');
40 addThis();
41
42 status = inSection(3);
43 string = 'abc';
44 actualmatch = string.match(pattern);
45 expectedmatch = Array('abc', 'ab');
46 addThis();
47
48
49 string = 'www.netscape.com';
50 status = inSection(4);
51 pattern = /^(([a-z]+)*[a-z]\.)+[a-z]{2,}$/;
52 actualmatch = string.match(pattern);
53 expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap');
54 addThis();
55
56 // add one more capturing parens to the previous regexp -
57 status = inSection(5);
58 pattern = /^(([a-z]+)*([a-z])\.)+[a-z]{2,}$/;
59 actualmatch = string.match(pattern);
60 expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap', 'e');
61 addThis();
62
63
64
65 //-------------------------------------------------------------------------------------------------
66 test();
67 //-------------------------------------------------------------------------------------------------
68
69
70 function addThis()
71 {
72 statusmessages[i] = status;
73 patterns[i] = pattern;
74 strings[i] = string;
75 actualmatches[i] = actualmatch;
76 expectedmatches[i] = expectedmatch;
77 i++;
78 }
79
80
81 function test()
82 {
83 printBugNumber(BUGNUMBER);
84 printStatus (summary);
85 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
86 }