summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/template-literal/tv-character-escape-sequence.js
blob: 56d27f20a53935f57a7dd5f777ce5957ed416f98 (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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 11.8.6.1
description: Template values of character escape sequences
info: |
    The TV of TemplateCharacter :: \ EscapeSequence is the SV of
    EscapeSequence.
    The TRV of TemplateCharacter :: \ EscapeSequence is the sequence consisting
    of the code unit value 0x005C followed by the code units of TRV of
    EscapeSequence.
    The TRV of CharacterEscapeSequence :: SingleEscapeCharacter is the TRV of
    the SingleEscapeCharacter.
    The TRV of CharacterEscapeSequence :: NonEscapeCharacter is the SV of the
    NonEscapeCharacter.
---*/
var calls;

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "'", "TV of NonEscapeCharacter");
  assert.sameValue(s.raw[0], "\u005C\u0027", "TRV of NonEscapeCharacter");
})`\'`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "\"", "TV of SingleEscapeCharacter (double quote)");
  assert.sameValue(
    s.raw[0], "\u005C\u0022", "TRV of SingleEscapeCharacter (double quote)"
  );
})`\"`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "\\", "TV of SingleEscapeCharacter (backslash)");
  assert.sameValue(
    s.raw[0], "\u005C\u005C", "TRV of SingleEscapeCharacter (backslash)"
  );
})`\\`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "\b", "TV of SingleEscapeCharacter (backspace)");
  assert.sameValue(
    s.raw[0], "\u005Cb", "TRV of SingleEscapeCharacter (backspace)"
  );
})`\b`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "\f", "TV of SingleEscapeCharacter (form feed)");
  assert.sameValue(
    s.raw[0], "\u005Cf", "TRV of SingleEscapeCharacter (form feed)"
  );
})`\f`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "\n", "TV of SingleEscapeCharacter (new line)");
  assert.sameValue(
    s.raw[0], "\u005Cn", "TRV of SingleEscapeCharacter (new line)"
  );
})`\n`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(
    s[0], "\r", "TV of SingleEscapeCharacter (carriage return)"
  );
  assert.sameValue(
    s.raw[0], "\u005Cr", "TRV of SingleEscapeCharacter (carriage return)"
  );
})`\r`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "	", "TV of SingleEscapeCharacter (tab)");
  assert.sameValue(s.raw[0], "\u005Ct", "TRV of SingleEscapeCharacter (tab)");
})`\t`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(
    s[0], "\v", "TV of SingleEscapeCharacter (line tabulation)"
  );
  assert.sameValue(
    s.raw[0], "\u005Cv", "TRV of SingleEscapeCharacter (line tabulation)"
  );
})`\v`;
assert.sameValue(calls, 1);

calls = 0;
(function(s) {
  calls++;
  assert.sameValue(s[0], "`", "TV of SingleEscapeCharacter (backtick)");
  assert.sameValue(
    s.raw[0], "\u005C`", "TRV of SingleEscapeCharacter (backtick)"
  );
})`\``;
assert.sameValue(calls, 1);

reportCompare(0, 0);