| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var gTestfile = '15.10.2-1.js'; |
| 17 |
var i = 0; |
| 18 |
var BUGNUMBER = '(none)'; |
| 19 |
var summary = 'RegExp conformance test'; |
| 20 |
var status = ''; |
| 21 |
var statusmessages = new Array(); |
| 22 |
var pattern = ''; |
| 23 |
var patterns = new Array(); |
| 24 |
var string = ''; |
| 25 |
var strings = new Array(); |
| 26 |
var actualmatch = ''; |
| 27 |
var actualmatches = new Array(); |
| 28 |
var expectedmatch = ''; |
| 29 |
var expectedmatches = new Array(); |
| 30 |
|
| 31 |
|
| 32 |
status = inSection(1); |
| 33 |
pattern = /a|ab/; |
| 34 |
string = 'abc'; |
| 35 |
actualmatch = string.match(pattern); |
| 36 |
expectedmatch = Array('a'); |
| 37 |
addThis(); |
| 38 |
|
| 39 |
status = inSection(2); |
| 40 |
pattern = /((a)|(ab))((c)|(bc))/; |
| 41 |
string = 'abc'; |
| 42 |
actualmatch = string.match(pattern); |
| 43 |
expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc'); |
| 44 |
addThis(); |
| 45 |
|
| 46 |
status = inSection(3); |
| 47 |
pattern = /a[a-z]{2,4}/; |
| 48 |
string = 'abcdefghi'; |
| 49 |
actualmatch = string.match(pattern); |
| 50 |
expectedmatch = Array('abcde'); |
| 51 |
addThis(); |
| 52 |
|
| 53 |
status = inSection(4); |
| 54 |
pattern = /a[a-z]{2,4}?/; |
| 55 |
string = 'abcdefghi'; |
| 56 |
actualmatch = string.match(pattern); |
| 57 |
expectedmatch = Array('abc'); |
| 58 |
addThis(); |
| 59 |
|
| 60 |
status = inSection(5); |
| 61 |
pattern = /(aa|aabaac|ba|b|c)*/; |
| 62 |
string = 'aabaac'; |
| 63 |
actualmatch = string.match(pattern); |
| 64 |
expectedmatch = Array('aaba', 'ba'); |
| 65 |
addThis(); |
| 66 |
|
| 67 |
status = inSection(6); |
| 68 |
pattern = /^(a+)\1*,\1+$/; |
| 69 |
string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa'; |
| 70 |
actualmatch = string.match(pattern); |
| 71 |
expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa'); |
| 72 |
addThis(); |
| 73 |
|
| 74 |
status = inSection(7); |
| 75 |
pattern = /(z)((a+)?(b+)?(c))*/; |
| 76 |
string = 'zaacbbbcac'; |
| 77 |
actualmatch = string.match(pattern); |
| 78 |
expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c'); |
| 79 |
addThis(); |
| 80 |
|
| 81 |
status = inSection(8); |
| 82 |
pattern = /(a*)*/; |
| 83 |
string = 'b'; |
| 84 |
actualmatch = string.match(pattern); |
| 85 |
expectedmatch = Array('', undefined); |
| 86 |
addThis(); |
| 87 |
|
| 88 |
status = inSection(9); |
| 89 |
pattern = /(a*)b\1+/; |
| 90 |
string = 'baaaac'; |
| 91 |
actualmatch = string.match(pattern); |
| 92 |
expectedmatch = Array('b', ''); |
| 93 |
addThis(); |
| 94 |
|
| 95 |
status = inSection(10); |
| 96 |
pattern = /(?=(a+))/; |
| 97 |
string = 'baaabac'; |
| 98 |
actualmatch = string.match(pattern); |
| 99 |
expectedmatch = Array('', 'aaa'); |
| 100 |
addThis(); |
| 101 |
|
| 102 |
status = inSection(11); |
| 103 |
pattern = /(?=(a+))a*b\1/; |
| 104 |
string = 'baaabac'; |
| 105 |
actualmatch = string.match(pattern); |
| 106 |
expectedmatch = Array('aba', 'a'); |
| 107 |
addThis(); |
| 108 |
|
| 109 |
status = inSection(12); |
| 110 |
pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/; |
| 111 |
string = 'baaabaac'; |
| 112 |
actualmatch = string.match(pattern); |
| 113 |
expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac'); |
| 114 |
addThis(); |
| 115 |
|
| 116 |
status = inSection(13); |
| 117 |
pattern = /(?=(a+))/; |
| 118 |
string = 'baaabac'; |
| 119 |
actualmatch = string.match(pattern); |
| 120 |
expectedmatch = Array('', 'aaa'); |
| 121 |
addThis(); |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
test(); |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
function addThis() |
| 131 |
{ |
| 132 |
statusmessages[i] = status; |
| 133 |
patterns[i] = pattern; |
| 134 |
strings[i] = string; |
| 135 |
actualmatches[i] = actualmatch; |
| 136 |
expectedmatches[i] = expectedmatch; |
| 137 |
i++; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
function test() |
| 142 |
{ |
| 143 |
enterFunc ('test'); |
| 144 |
printBugNumber(BUGNUMBER); |
| 145 |
printStatus (summary); |
| 146 |
testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
| 147 |
exitFunc ('test'); |
| 148 |
} |