regress-224676.js (4289B)
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: 04 November 2003 9 * SUMMARY: Testing regexps with various disjunction + character class patterns 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=224676 12 * 13 */ 14 //----------------------------------------------------------------------------- 15 var i = 0; 16 var BUGNUMBER = 224676; 17 var summary = 'Regexps with various disjunction + character class patterns'; 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 = 'ZZZxZZZ'; 31 status = inSection(1); 32 pattern = /[x]|x/; 33 actualmatch = string.match(pattern); 34 expectedmatch = Array('x'); 35 addThis(); 36 37 status = inSection(2); 38 pattern = /x|[x]/; 39 actualmatch = string.match(pattern); 40 expectedmatch = Array('x'); 41 addThis(); 42 43 44 string = 'ZZZxbZZZ'; 45 status = inSection(3); 46 pattern = /a|[x]b/; 47 actualmatch = string.match(pattern); 48 expectedmatch = Array('xb'); 49 addThis(); 50 51 status = inSection(4); 52 pattern = /[x]b|a/; 53 actualmatch = string.match(pattern); 54 expectedmatch = Array('xb'); 55 addThis(); 56 57 status = inSection(5); 58 pattern = /([x]b|a)/; 59 actualmatch = string.match(pattern); 60 expectedmatch = Array('xb', 'xb'); 61 addThis(); 62 63 status = inSection(6); 64 pattern = /([x]b|a)|a/; 65 actualmatch = string.match(pattern); 66 expectedmatch = Array('xb', 'xb'); 67 addThis(); 68 69 status = inSection(7); 70 pattern = /^[x]b|a/; 71 actualmatch = string.match(pattern); 72 expectedmatch = null; 73 addThis(); 74 75 76 string = 'xb'; 77 status = inSection(8); 78 pattern = /^[x]b|a/; 79 actualmatch = string.match(pattern); 80 expectedmatch = Array('xb'); 81 addThis(); 82 83 84 string = 'ZZZxbZZZ'; 85 status = inSection(9); 86 pattern = /([x]b)|a/; 87 actualmatch = string.match(pattern); 88 expectedmatch = Array('xb', 'xb'); 89 addThis(); 90 91 status = inSection(10); 92 pattern = /()[x]b|a/; 93 actualmatch = string.match(pattern); 94 expectedmatch = Array('xb', ''); 95 addThis(); 96 97 status = inSection(11); 98 pattern = /x[b]|a/; 99 actualmatch = string.match(pattern); 100 expectedmatch = Array('xb'); 101 addThis(); 102 103 status = inSection(12); 104 pattern = /[x]{1}b|a/; 105 actualmatch = string.match(pattern); 106 expectedmatch = Array('xb'); 107 addThis(); 108 109 status = inSection(13); 110 pattern = /[x]b|a|a/; 111 actualmatch = string.match(pattern); 112 expectedmatch = Array('xb'); 113 addThis(); 114 115 status = inSection(14); 116 pattern = /[x]b|[a]/; 117 actualmatch = string.match(pattern); 118 expectedmatch = Array('xb'); 119 addThis(); 120 121 status = inSection(15); 122 pattern = /[x]b|a+/; 123 actualmatch = string.match(pattern); 124 expectedmatch = Array('xb'); 125 addThis(); 126 127 status = inSection(16); 128 pattern = /[x]b|a{1}/; 129 actualmatch = string.match(pattern); 130 expectedmatch = Array('xb'); 131 addThis(); 132 133 status = inSection(17); 134 pattern = /[x]b|(a)/; 135 actualmatch = string.match(pattern); 136 expectedmatch = Array('xb', undefined); 137 addThis(); 138 139 status = inSection(18); 140 pattern = /[x]b|()a/; 141 actualmatch = string.match(pattern); 142 expectedmatch = Array('xb', undefined); 143 addThis(); 144 145 status = inSection(19); 146 pattern = /[x]b|^a/; 147 actualmatch = string.match(pattern); 148 expectedmatch = Array('xb'); 149 addThis(); 150 151 status = inSection(20); 152 pattern = /a|[^b]b/; 153 actualmatch = string.match(pattern); 154 expectedmatch = Array('xb'); 155 addThis(); 156 157 status = inSection(21); 158 pattern = /a|[^b]{1}b/; 159 actualmatch = string.match(pattern); 160 expectedmatch = Array('xb'); 161 addThis(); 162 163 164 string = 'hallo\";'; 165 status = inSection(22); 166 pattern = /^((\\[^\x00-\x1f]|[^\x00-\x1f"\\])*)"/; 167 actualmatch = string.match(pattern); 168 expectedmatch = Array('hallo"', 'hallo', 'o'); 169 addThis(); 170 171 //---------------------------------------------------------------------------- 172 test(); 173 //---------------------------------------------------------------------------- 174 175 function addThis() 176 { 177 statusmessages[i] = status; 178 patterns[i] = pattern; 179 strings[i] = string; 180 actualmatches[i] = actualmatch; 181 expectedmatches[i] = expectedmatch; 182 i++; 183 } 184 185 function test() 186 { 187 printBugNumber(BUGNUMBER); 188 printStatus (summary); 189 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 190 }