regress-225343.js (2242B)
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: 11 November 2003 9 * SUMMARY: Testing regexp character classes and the case-insensitive flag 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=225343 12 * 13 */ 14 //----------------------------------------------------------------------------- 15 var i = 0; 16 var BUGNUMBER = 225343; 17 var summary = 'Testing regexp character classes and the case-insensitive flag'; 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 status = inSection(1); 31 string = 'a'; 32 pattern = /[A]/i; 33 actualmatch = string.match(pattern); 34 expectedmatch = Array('a'); 35 addThis(); 36 37 status = inSection(2); 38 string = 'A'; 39 pattern = /[a]/i; 40 actualmatch = string.match(pattern); 41 expectedmatch = Array('A'); 42 addThis(); 43 44 status = inSection(3); 45 string = '123abc123'; 46 pattern = /([A-Z]+)/i; 47 actualmatch = string.match(pattern); 48 expectedmatch = Array('abc', 'abc'); 49 addThis(); 50 51 status = inSection(4); 52 string = '123abc123'; 53 pattern = /([A-Z])+/i; 54 actualmatch = string.match(pattern); 55 expectedmatch = Array('abc', 'c'); 56 addThis(); 57 58 status = inSection(5); 59 string = 'abc@test.com'; 60 pattern = /^[-!#$%&\'*+\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i; 61 actualmatch = string.match(pattern); 62 expectedmatch = Array('abc@test.com', 'test.', 'm'); 63 addThis(); 64 65 66 67 //------------------------------------------------------------------------------------------------- 68 test(); 69 //------------------------------------------------------------------------------------------------- 70 71 72 73 function addThis() 74 { 75 statusmessages[i] = status; 76 patterns[i] = pattern; 77 strings[i] = string; 78 actualmatches[i] = actualmatch; 79 expectedmatches[i] = expectedmatch; 80 i++; 81 } 82 83 84 function test() 85 { 86 printBugNumber(BUGNUMBER); 87 printStatus (summary); 88 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 89 }