| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var gTestfile = 'regress-67773.js'; |
| 17 |
var i = 0; |
| 18 |
var BUGNUMBER = 67773; |
| 19 |
var summary = 'Testing regular subexpressions followed by ? or +\n'; |
| 20 |
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 |
pattern = /^(\S+)?( ?)(B+)$/; |
| 34 |
status = inSection(1); |
| 35 |
string = 'AAABBB AAABBB '; |
| 36 |
actualmatch = string.match(pattern); |
| 37 |
expectedmatch = null; |
| 38 |
addThis(); |
| 39 |
|
| 40 |
status = inSection(2); |
| 41 |
string = 'AAABBB BBB'; |
| 42 |
actualmatch = string.match(pattern); |
| 43 |
expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); |
| 44 |
addThis(); |
| 45 |
|
| 46 |
status = inSection(3); |
| 47 |
string = 'AAABBB AAABBB'; |
| 48 |
actualmatch = string.match(pattern); |
| 49 |
expectedmatch = null; |
| 50 |
addThis(); |
| 51 |
|
| 52 |
|
| 53 |
pattern = /^(A+B)+$/; |
| 54 |
status = inSection(4); |
| 55 |
string = 'AABAAB'; |
| 56 |
actualmatch = string.match(pattern); |
| 57 |
expectedmatch = Array(string, 'AAB'); |
| 58 |
addThis(); |
| 59 |
|
| 60 |
status = inSection(5); |
| 61 |
string = 'ABAABAAAAAAB'; |
| 62 |
actualmatch = string.match(pattern); |
| 63 |
expectedmatch = Array(string, 'AAAAAAB'); |
| 64 |
addThis(); |
| 65 |
|
| 66 |
status = inSection(6); |
| 67 |
string = 'ABAABAABAB'; |
| 68 |
actualmatch = string.match(pattern); |
| 69 |
expectedmatch = Array(string, 'AB'); |
| 70 |
addThis(); |
| 71 |
|
| 72 |
status = inSection(7); |
| 73 |
string = 'ABAABAABABB'; |
| 74 |
actualmatch = string.match(pattern); |
| 75 |
expectedmatch = null; |
| 76 |
addThis(); |
| 77 |
|
| 78 |
|
| 79 |
pattern = /^(A+1)+$/; |
| 80 |
status = inSection(8); |
| 81 |
string = 'AA1AA1'; |
| 82 |
actualmatch = string.match(pattern); |
| 83 |
expectedmatch = Array(string, 'AA1'); |
| 84 |
addThis(); |
| 85 |
|
| 86 |
|
| 87 |
pattern = /^(\w+\-)+$/; |
| 88 |
status = inSection(9); |
| 89 |
string = ''; |
| 90 |
actualmatch = string.match(pattern); |
| 91 |
expectedmatch = null; |
| 92 |
addThis(); |
| 93 |
|
| 94 |
status = inSection(10); |
| 95 |
string = 'bla-'; |
| 96 |
actualmatch = string.match(pattern); |
| 97 |
expectedmatch = Array(string, string); |
| 98 |
addThis(); |
| 99 |
|
| 100 |
status = inSection(11); |
| 101 |
string = 'bla-bla'; |
| 102 |
actualmatch = string.match(pattern); |
| 103 |
expectedmatch = null; |
| 104 |
addThis(); |
| 105 |
|
| 106 |
status = inSection(12); |
| 107 |
string = 'bla-bla-'; |
| 108 |
actualmatch = string.match(pattern); |
| 109 |
expectedmatch = Array(string, 'bla-'); |
| 110 |
addThis(); |
| 111 |
|
| 112 |
|
| 113 |
pattern = /^(\S+)+(A+)$/; |
| 114 |
status = inSection(13); |
| 115 |
string = 'asdldflkjAAA'; |
| 116 |
actualmatch = string.match(pattern); |
| 117 |
expectedmatch = Array(string, 'asdldflkjAA', 'A'); |
| 118 |
addThis(); |
| 119 |
|
| 120 |
status = inSection(14); |
| 121 |
string = 'asdldflkj AAA'; |
| 122 |
actualmatch = string.match(pattern); |
| 123 |
expectedmatch = null; |
| 124 |
addThis(); |
| 125 |
|
| 126 |
|
| 127 |
pattern = /^(\S+)+(\d+)$/; |
| 128 |
status = inSection(15); |
| 129 |
string = 'asdldflkj122211'; |
| 130 |
actualmatch = string.match(pattern); |
| 131 |
expectedmatch = Array(string, 'asdldflkj12221', '1'); |
| 132 |
addThis(); |
| 133 |
|
| 134 |
status = inSection(16); |
| 135 |
string = 'asdldflkj1111111aaa1'; |
| 136 |
actualmatch = string.match(pattern); |
| 137 |
expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); |
| 138 |
addThis(); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; |
| 146 |
status = inSection(17); |
| 147 |
string = 'some.host.tld'; |
| 148 |
actualmatch = string.match(pattern); |
| 149 |
expectedmatch = Array(string, '.tld', '.'); |
| 150 |
addThis(); |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
test(); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
function addThis() |
| 161 |
{ |
| 162 |
statusmessages[i] = status; |
| 163 |
patterns[i] = pattern; |
| 164 |
strings[i] = string; |
| 165 |
actualmatches[i] = actualmatch; |
| 166 |
expectedmatches[i] = expectedmatch; |
| 167 |
i++; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
function test() |
| 172 |
{ |
| 173 |
enterFunc ('test'); |
| 174 |
printBugNumber(BUGNUMBER); |
| 175 |
printStatus (summary); |
| 176 |
testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
| 177 |
exitFunc ('test'); |
| 178 |
} |