| 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: 24 October 2003 |
| 9 |
* SUMMARY: Testing regexps with empty alternatives |
| 10 |
* |
| 11 |
* See http://bugzilla.mozilla.org/show_bug.cgi?id=223535 |
| 12 |
* |
| 13 |
*/ |
| 14 |
//----------------------------------------------------------------------------- |
| 15 |
var i = 0; |
| 16 |
var BUGNUMBER = 223535; |
| 17 |
var summary = 'Testing regexps with empty alternatives'; |
| 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 |
string = 'a'; |
| 31 |
status = inSection(1); |
| 32 |
pattern = /a|/; |
| 33 |
actualmatch = string.match(pattern); |
| 34 |
expectedmatch = Array('a'); |
| 35 |
addThis(); |
| 36 |
|
| 37 |
status = inSection(2); |
| 38 |
pattern = /|a/; |
| 39 |
actualmatch = string.match(pattern); |
| 40 |
expectedmatch = Array(''); |
| 41 |
addThis(); |
| 42 |
|
| 43 |
status = inSection(3); |
| 44 |
pattern = /|/; |
| 45 |
actualmatch = string.match(pattern); |
| 46 |
expectedmatch = Array(''); |
| 47 |
addThis(); |
| 48 |
|
| 49 |
status = inSection(4); |
| 50 |
pattern = /(a|)/; |
| 51 |
actualmatch = string.match(pattern); |
| 52 |
expectedmatch = Array('a', 'a'); |
| 53 |
addThis(); |
| 54 |
|
| 55 |
status = inSection(5); |
| 56 |
pattern = /(a||)/; |
| 57 |
actualmatch = string.match(pattern); |
| 58 |
expectedmatch = Array('a', 'a'); |
| 59 |
addThis(); |
| 60 |
|
| 61 |
status = inSection(6); |
| 62 |
pattern = /(|a)/; |
| 63 |
actualmatch = string.match(pattern); |
| 64 |
expectedmatch = Array('', ''); |
| 65 |
addThis(); |
| 66 |
|
| 67 |
status = inSection(7); |
| 68 |
pattern = /(|a|)/; |
| 69 |
actualmatch = string.match(pattern); |
| 70 |
expectedmatch = Array('', ''); |
| 71 |
addThis(); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
//------------------------------------------------------------------------------------------------- |
| 76 |
test(); |
| 77 |
//------------------------------------------------------------------------------------------------- |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
function addThis() |
| 82 |
{ |
| 83 |
statusmessages[i] = status; |
| 84 |
patterns[i] = pattern; |
| 85 |
strings[i] = string; |
| 86 |
actualmatches[i] = actualmatch; |
| 87 |
expectedmatches[i] = expectedmatch; |
| 88 |
i++; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
function test() |
| 93 |
{ |
| 94 |
printBugNumber(BUGNUMBER); |
| 95 |
printStatus (summary); |
| 96 |
testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
| 97 |
} |