character-class-escape-non-whitespace.js (1163B)
1 // Copyright 2018 Leonardo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-characterclassescape 6 description: Detect non WhiteSpace using \S+ 7 info: | 8 The production CharacterClassEscape :: S evaluates by returning 9 the set of all characters not included in the set returned by 10 CharacterClassEscape :: s 11 ---*/ 12 13 var j; 14 var i; 15 var str; 16 var res; 17 18 var whitespaceChars = [ 19 0x0009, 20 0x000A, 21 0x000B, 22 0x000C, 23 0x000D, 24 0x0020, 25 0x00A0, 26 0x1680, 27 0x2000, 28 0x2001, 29 0x2002, 30 0x2003, 31 0x2004, 32 0x2005, 33 0x2006, 34 0x2007, 35 0x2008, 36 0x2009, 37 0x200A, 38 0x2028, 39 0x2029, 40 0x202F, 41 0x205F, 42 0x3000, 43 ]; 44 45 for (j = 0x0000; j < 0x10000; j++) { 46 if (j === 0x180E) { continue; } // Skip 0x180E, current test in a separate file 47 if (j === 0xFEFF) { continue; } // Ignore BOM 48 str = String.fromCharCode(j); 49 res = str.replace(/\S+/g, "test262"); 50 if (whitespaceChars.indexOf(j) >= 0) { 51 assert.sameValue(res, str, "WhiteSpace character, charCode: " + j); 52 } else { 53 assert.sameValue(res, "test262", "Non WhiteSpace character, charCode: " + j); 54 } 55 } 56 57 reportCompare(0, 0);