-
Notifications
You must be signed in to change notification settings - Fork 556
Expand file tree
/
Copy pathtv-utf16-escape-sequence-supplementary.js
More file actions
95 lines (86 loc) · 2.38 KB
/
Copy pathtv-utf16-escape-sequence-supplementary.js
File metadata and controls
95 lines (86 loc) · 2.38 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (C) 2026 hexbinoct. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-tv
description: >
Template values of \u{} escape sequences for code points above U+FFFF
info: |
The TV of TemplateCharacter :: \ TemplateEscapeSequence is the SV of
TemplateEscapeSequence.
The SV of UnicodeEscapeSequence :: u{ CodePoint } is the result of
performing UTF16EncodeCodePoint on the MV of CodePoint.
UTF16EncodeCodePoint ( cp )
1. Assert: 0 <= cp <= 0x10FFFF.
2. If cp <= 0xFFFF, return the String value consisting of the code unit
whose numeric value is cp.
3. Let cu1 be the code unit whose numeric value is
floor((cp - 0x10000) / 0x400) + 0xD800.
4. Let cu2 be the code unit whose numeric value is
((cp - 0x10000) modulo 0x400) + 0xDC00.
5. Return the string-concatenation of cu1 and cu2.
Steps 3 through 5 are reached only for code points in the range 0x10000
through 0x10FFFF, which encode as a surrogate pair.
---*/
var calls;
calls = 0;
(function(s) {
calls++;
assert.sameValue(
s[0],
'\uD800\uDC00',
'template value of U+10000, the least code point encoded as a surrogate pair'
);
assert.sameValue(
s.raw[0], '\\u{10000}', 'template raw value of \\u{10000}'
);
})`\u{10000}`;
assert.sameValue(calls, 1);
calls = 0;
(function(s) {
calls++;
assert.sameValue(
s[0],
'\uD801\uDC37',
'template value of U+10437'
);
assert.sameValue(
s.raw[0], '\\u{10437}', 'template raw value of \\u{10437}'
);
})`\u{10437}`;
assert.sameValue(calls, 1);
calls = 0;
(function(s) {
calls++;
assert.sameValue(
s[0],
'\uDBFF\uDFFF',
'template value of U+10FFFF, the greatest code point'
);
assert.sameValue(
s.raw[0], '\\u{10FFFF}', 'template raw value of \\u{10FFFF}'
);
})`\u{10FFFF}`;
assert.sameValue(calls, 1);
calls = 0;
(function(s) {
calls++;
assert.sameValue(
s[0],
'\uD800\uDC00',
'template value of U+10000 (with leading zeros)'
);
assert.sameValue(
s.raw[0], '\\u{010000}', 'template raw value of \\u{010000}'
);
})`\u{010000}`;
assert.sameValue(calls, 1);
assert.sameValue(
`\u{10437}`,
'\uD801\uDC37',
'template value in an untagged template literal'
);
assert.sameValue(
`a\u{10437}b`,
'a\uD801\uDC37b',
'surrogate pair concatenates with adjacent template characters'
);