aboutsummaryrefslogtreecommitdiff
path: root/integration/snapshots/latin1-chars-in-regexp.debug.js
blob: 42217319b2affdc3c1a0a4a347227b60786590bf (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var re_btou = new RegExp([
  "[\xC0-\xDF][\x80-\xBF]",
  "[\xE0-\xEF][\x80-\xBF]{2}",
  "[\xF0-\xF7][\x80-\xBF]{3}"
].join("|"), "g");
const encoder = new TextEncoder;
const realLines = [
  "[\xC0-\xDF][\x80-\xBF]",
  "[\xE0-\xEF][\x80-\xBF]{2}",
  "[\xF0-\xF7][\x80-\xBF]{3}"
];
const real = realLines.map((input) => Array.from(encoder.encode(input)));
const expected = [
  [91, 195, 128, 45, 195, 159, 93, 91, 194, 128, 45, 194, 191, 93],
  [
    91,
    195,
    160,
    45,
    195,
    175,
    93,
    91,
    194,
    128,
    45,
    194,
    191,
    93,
    123,
    50,
    125
  ],
  [
    91,
    195,
    176,
    45,
    195,
    183,
    93,
    91,
    194,
    128,
    45,
    194,
    191,
    93,
    123,
    51,
    125
  ]
];
const newlinePreserved = `\n`;
export function test() {
  if (!real.every((point, i) => point.every((val, j) => val === expected[i][j])))
    throw new Error(`test failed
${JSON.stringify({expected, real }, null, 2)}`);
  if (newlinePreserved.length !== 1 || newlinePreserved.charCodeAt(0) !== 10)
    throw new Error("Newline was not preserved");
  const decoder = new TextDecoder("utf8");
  if (!realLines.every((line, i) => decoder.decode(Uint8Array.from(expected[i])) === line))
    throw new Error(`test failed. Lines did not match.
${JSON.stringify({expected, real }, null, 2)}`);
  testDone(import.meta.url);
}