| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var gTestfile = 'regress-57572.js'; |
| 17 |
var i = 0; |
| 18 |
var BUGNUMBER = 57572; |
| 19 |
var summary = 'Testing regular expressions containing "?"'; |
| 20 |
var cnEmptyString = ''; var cnSingleSpace = ' '; |
| 21 |
var status = ''; |
| 22 |
var statusmessages = new Array(); |
| 23 |
var pattern = ''; |
| 24 |
var patterns = new Array(); |
| 25 |
var string = ''; |
| 26 |
var strings = new Array(); |
| 27 |
var actualmatch = ''; |
| 28 |
var actualmatches = new Array(); |
| 29 |
var expectedmatch = ''; |
| 30 |
var expectedmatches = new Array(); |
| 31 |
|
| 32 |
|
| 33 |
status = inSection(1); |
| 34 |
pattern = /(\S+)?(.*)/; |
| 35 |
string = 'Test this'; |
| 36 |
actualmatch = string.match(pattern); |
| 37 |
expectedmatch = Array(string, 'Test', ' this'); |
| 38 |
addThis(); |
| 39 |
|
| 40 |
status = inSection(2); |
| 41 |
pattern = /(\S+)? ?(.*)/; |
| 42 |
string= 'Test this'; |
| 43 |
actualmatch = string.match(pattern); |
| 44 |
expectedmatch = Array(string, 'Test', 'this'); |
| 45 |
addThis(); |
| 46 |
|
| 47 |
status = inSection(3); |
| 48 |
pattern = /(\S+)?(.*)/; |
| 49 |
string = 'Stupid phrase, with six - (short) words'; |
| 50 |
actualmatch = string.match(pattern); |
| 51 |
expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); |
| 52 |
addThis(); |
| 53 |
|
| 54 |
status = inSection(4); |
| 55 |
pattern = /(\S+)? ?(.*)/; |
| 56 |
string = 'Stupid phrase, with six - (short) words'; |
| 57 |
actualmatch = string.match(pattern); |
| 58 |
expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); |
| 59 |
addThis(); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
status = inSection(5); |
| 64 |
pattern = /(\S+)?( ?)(.*)/; |
| 65 |
string = 'Stupid phrase, with six - (short) words'; |
| 66 |
actualmatch = string.match(pattern); |
| 67 |
expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); |
| 68 |
addThis(); |
| 69 |
|
| 70 |
status = inSection(6); |
| 71 |
pattern = /^(\S+)?( ?)(B+)$/; |
| 72 |
string = 'AAABBB'; |
| 73 |
actualmatch = string.match(pattern); |
| 74 |
expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); |
| 75 |
addThis(); |
| 76 |
|
| 77 |
status = inSection(7); |
| 78 |
pattern = /(\S+)?(!?)(.*)/; |
| 79 |
string = 'WOW !!! !!!'; |
| 80 |
actualmatch = string.match(pattern); |
| 81 |
expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); |
| 82 |
addThis(); |
| 83 |
|
| 84 |
status = inSection(8); |
| 85 |
pattern = /(.+)?(!?)(!+)/; |
| 86 |
string = 'WOW !!! !!!'; |
| 87 |
actualmatch = string.match(pattern); |
| 88 |
expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); |
| 89 |
addThis(); |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
test(); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
function addThis() |
| 100 |
{ |
| 101 |
statusmessages[i] = status; |
| 102 |
patterns[i] = pattern; |
| 103 |
strings[i] = string; |
| 104 |
actualmatches[i] = actualmatch; |
| 105 |
expectedmatches[i] = expectedmatch; |
| 106 |
i++; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
function test() |
| 111 |
{ |
| 112 |
enterFunc ('test'); |
| 113 |
printBugNumber(BUGNUMBER); |
| 114 |
printStatus (summary); |
| 115 |
testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
| 116 |
exitFunc ('test'); |
| 117 |
} |