Debian Codegraph @

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