summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/escape/escape-below.js
blob: 197fcf70e89dba8d038f4f1c75a2f3cf1e870217 (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-escape-string
es6id: B.2.1.1
description: Escaping of code units below 255
info: |
    [...]
    5. Repeat, while k < length,
       a. Let char be the code unit (represented as a 16-bit unsigned integer)
          at index k within string.
       [...]
       d. Else char < 256,
          i. Let S be a String containing three code units "%xy" where xy are
             the code units of two uppercase hexadecimal digits encoding the
             value of char.
       [...]
---*/

assert.sameValue(
  escape('\x00\x01\x02\x03'),
  '%00%01%02%03',
  'characters: \\x00\\x01\\x02\\x03'
);

assert.sameValue(
  escape('!"#$%&\'()'),
  '%21%22%23%24%25%26%27%28%29',
  'characters preceding "*": !"#$%&\'()'
);

assert.sameValue(escape(','), '%2C', 'character between "+" and "-": ,');

assert.sameValue(
  escape(':;<=>?'),
  '%3A%3B%3C%3D%3E%3F',
  'characters between "9" and "@": :;<=>?'
);

assert.sameValue(
  escape('[\\]^'), '%5B%5C%5D%5E', 'characters between "Z" and "_": [\\]^'
);

assert.sameValue(escape('`'), '%60', 'character between "_" and "a": `');

assert.sameValue(
  escape('{|}~\x7f\x80'),
  '%7B%7C%7D%7E%7F%80',
  'characters following "z": {|}~\\x7f\\x80'
);

assert.sameValue(
  escape('\xfd\xfe\xff'), '%FD%FE%FF', '\\xfd\\xfe\\xff'
);

reportCompare(0, 0);