1/* 2* The contents of this file are subject to the Netscape Public 3* License Version 1.1 (the "License"); you may not use this file 4* except in compliance with the License. You may obtain a copy of 5* the License at http://www.mozilla.org/NPL/ 6* 7* Software distributed under the License is distributed on an "AS IS" 8* basis, WITHOUT WARRANTY OF ANY KIND, either expressed 9* or implied. See the License for the specific language governing 10* rights and limitations under the License. 11* 12* The Original Code is mozilla.org code. 13* 14* The Initial Developer of the Original Code is Netscape 15* Communications Corporation. Portions created by Netscape are 16* Copyright (C) 1998 Netscape Communications Corporation. 17* All Rights Reserved. 18* 19* Contributor(s): pschwartau@netscape.com 20* Date: 2001-07-17 21* 22* SUMMARY: Regression test for Bugzilla bug 72964: 23* "String method for pattern matching failed for Chinese Simplified (GB2312)" 24* 25* See http://bugzilla.mozilla.org/show_bug.cgi?id=72964 26*/ 27//----------------------------------------------------------------------------- 28var i = 0; 29var bug = 72964; 30var summary = 'Testing regular expressions containing non-Latin1 characters'; 31var cnSingleSpace = ' '; 32var status = ''; 33var statusmessages = new Array(); 34var pattern = ''; 35var patterns = new Array(); 36var string = ''; 37var strings = new Array(); 38var actualmatch = ''; 39var actualmatches = new Array(); 40var expectedmatch = ''; 41var expectedmatches = new Array(); 42 43 44pattern = /[\S]+/; 45 // 4 low Unicode chars = Latin1; whole string should match 46 status = inSection(1); 47 string = '\u00BF\u00CD\u00BB\u00A7'; 48 actualmatch = string.match(pattern); 49 expectedmatch = Array(string); 50 addThis(); 51 52 // Now put a space in the middle; first half of string should match 53 status = inSection(2); 54 string = '\u00BF\u00CD \u00BB\u00A7'; 55 actualmatch = string.match(pattern); 56 expectedmatch = Array('\u00BF\u00CD'); 57 addThis(); 58 59 60 // 4 high Unicode chars = non-Latin1; whole string should match 61 status = inSection(3); 62 string = '\u4e00\uac00\u4e03\u4e00'; 63 actualmatch = string.match(pattern); 64 expectedmatch = Array(string); 65 addThis(); 66 67 // Now put a space in the middle; first half of string should match 68 status = inSection(4); 69 string = '\u4e00\uac00 \u4e03\u4e00'; 70 actualmatch = string.match(pattern); 71 expectedmatch = Array('\u4e00\uac00'); 72 addThis(); 73 74 75 76//----------------------------------------------------------------------------- 77test(); 78//----------------------------------------------------------------------------- 79 80 81 82function addThis() 83{ 84 statusmessages[i] = status; 85 patterns[i] = pattern; 86 strings[i] = string; 87 actualmatches[i] = actualmatch; 88 expectedmatches[i] = expectedmatch; 89 i++; 90} 91 92 93function test() 94{ 95 enterFunc ('test'); 96 printBugNumber (bug); 97 printStatus (summary); 98 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 99 exitFunc ('test'); 100} 101