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
120
|
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
var BUGNUMBER = 1434429;
var summary =
"Report unterminated string/template literal errors with the line/column " +
"number of the point of non-termination";
function test(f, quotes, [line, col])
{
var caught = false;
try
{
f();
}
catch (e)
{
caught = true;
assertEq(e.lineNumber, line, "line number");
assertEq(e.columnNumber, col, "column number");
assertEq(e.message.includes(quotes), true,
"message must contain delimiter");
}
assertEq(caught, true);
}
test(function() {
//1234
eval("'hi");
}, "''", [1, 4]);
test(function() {
//1234 5
eval("'hi\\");
}, "''", [1, 5]);
test(function() {
//1234567
eval(" 'hi");
}, "''", [1, 7]);
test(function() {
//1234567 8
eval(" 'hi\\");
}, "''", [1, 8]);
test(function() {
//12345678 12345678
eval('var x =\n "hi');
}, '""', [2, 8]);
test(function() {
//1234567 12345678 9
eval('var x =\n "hi\\');
}, '""', [2, 9]);
test(function() {
// 1
//1234567 12345678 123456789 12345678901234
eval('var x =\n "hi\\\n bye\\\n no really');
}, '""', [4, 14]);
test(function() {
// 1
//1234567 12345678 123456789 12345678901234 5
eval('var x =\n "hi\\\n bye\\\n no really\\');
}, '""', [4, 15]);
test(function() {
//1234567 12345678 123456789
eval('var x =\n "hi\\\n bye\n');
}, '""', [3, 9]);
test(function() {
// 1
//1234567 12345678 123456789 0
eval('var x =\n "hi\\\n bye\\');
}, '""', [3, 10]);
test(function() {
//1234567 12345678
eval('var x =\n `');
}, '``', [2, 8]);
test(function() {
//1234567 12345678 9
eval('var x =\n `\\');
}, '``', [2, 9]);
test(function() {
// 1
//1234567 1234567890123456
eval('var x =\n htmlEscape`');
}, '``', [2, 16]);
test(function() {
// 1
//1234567 1234567890123456 7
eval('var x =\n htmlEscape`\\');
}, '``', [2, 17]);
test(function() {
// 1
//1234567 12345678901234 12345
eval('var x =\n htmlEscape\n `');
}, '``', [3, 5]);
test(function() {
// 1
//1234567 12345678901234 12345 6
eval('var x =\n htmlEscape\n `\\');
}, '``', [3, 6]);
if (typeof reportCompare === "function")
reportCompare(0, 0, "ok");
print("Tests complete");
|