summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/character-class-escape-non-whitespace.js
blob: 0db2ab6ae31c165d046201b6f1f722ff7f10fe44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2018 Leonardo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-characterclassescape
description: Detect non WhiteSpace using \S+
info: |
    The production CharacterClassEscape :: S evaluates by returning
    the set of all characters not included in the set returned by
    CharacterClassEscape :: s
---*/

var j;
var i;
var str;
var res;

var whitespaceChars = [
  0x0009,
  0x000A,
  0x000B,
  0x000C,
  0x000D,
  0x0020,
  0x00A0,
  0x1680,
  0x2000,
  0x2001,
  0x2002,
  0x2003,
  0x2004,
  0x2005,
  0x2006,
  0x2007,
  0x2008,
  0x2009,
  0x200A,
  0x2028,
  0x2029,
  0x202F,
  0x205F,
  0x3000,
];

for (j = 0x0000; j < 0x10000; j++) {
  if (j === 0x180E) { continue; } // Skip 0x180E, current test in a separate file
  if (j === 0xFEFF) { continue; } // Ignore BOM
  str = String.fromCharCode(j);
  res = str.replace(/\S+/g, "test262");
  if (whitespaceChars.indexOf(j) >= 0) {
    assert.sameValue(res, str, "WhiteSpace character, charCode: " + j);
  } else {
    assert.sameValue(res, "test262", "Non WhiteSpace character, charCode: " + j);
  }
}

reportCompare(0, 0);