Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
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();
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();
36 status = inSection(2);
37 string = 'ab';
38 actualmatch = string.match(pattern);
39 expectedmatch = Array('ab', 'a');
40 addThis();
42 status = inSection(3);
43 string = 'abc';
44 actualmatch = string.match(pattern);
45 expectedmatch = Array('abc', 'ab');
46 addThis();
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();
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();
65 //-------------------------------------------------------------------------------------------------
66 test();
67 //-------------------------------------------------------------------------------------------------
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 }
81 function test()
82 {
83 enterFunc ('test');
84 printBugNumber(BUGNUMBER);
85 printStatus (summary);
86 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
87 exitFunc ('test');
88 }