Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 13d607f

Browse files
committed
sem: tests+fixtures for more failing escape seq
Signed-off-by: Alexander Bezzubov <[email protected]>
1 parent db1786f commit 13d607f

File tree

4 files changed

+152
-11
lines changed

4 files changed

+152
-11
lines changed

driver/normalizer/strconv_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,27 @@ var testCasesUnquoteSingle = []struct {
2424
{`'\0something\0else'`, "\u0000something\u0000else", "'\\x00something\\x00else'"},
2525
{`'\u0000123\0s'`, "\u0000123\u0000s", "'\\x00123\\x00s'"},
2626
{`'\0\0'`, "\u0000\u0000", "'\\x00\\x00'"},
27+
{`'\01'`, "\u0001", "'\\x01'"},
2728
}
2829

2930
var testCasesUnquoteDouble = []struct {
3031
quoted string
3132
unquoted string
3233
}{
3334
{`"\0\0\0"`, "\x00\x00\x00"},
34-
{`"\.\."`, "\\.\\."},
35+
{`"\a"`, "a"},
36+
{`"\.\."`, ".."},
37+
{`"\1"`, "1"},
38+
{`"\01"`, "1"},
39+
{`"\u{1D306}"`, "𝌆"},
3540
}
3641

3742
func TestUnquoteDouble(t *testing.T) {
3843
for _, test := range testCasesUnquoteDouble {
3944
t.Run("", func(t *testing.T) {
4045
s, err := unquoteDouble(test.quoted)
4146
require.NoError(t, err)
42-
require.Equal(t, test.unquoted, s)
47+
assertEquals(t, test.unquoted, s)
4348
})
4449
}
4550
}
@@ -49,7 +54,7 @@ func TestUnquoteSingle(t *testing.T) {
4954
t.Run("", func(t *testing.T) {
5055
s, err := unquoteSingle(test.quoted)
5156
require.NoError(t, err)
52-
require.Equal(t, test.unquoted, s)
57+
assertEquals(t, test.unquoted, s)
5358
})
5459
}
5560
}

fixtures/string-literal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ var escPeriod = '\0PERIOD'+Math.random()+'\0';
1111
d = "\0\0\0\0\0\0\0\0"
1212

1313
c = "\.\1 or really \anything"
14+
15+
f = "\u{1D306}"

fixtures/string-literal.js.native

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
comments: [],
3-
end: 311,
3+
end: 328,
44
loc: {
55
end: {
66
column: 0,
7-
line: 14,
7+
line: 16,
88
},
99
start: {
1010
column: 0,
@@ -1293,13 +1293,81 @@
12931293
start: 280,
12941294
type: "ExpressionStatement",
12951295
},
1296+
{
1297+
end: 327,
1298+
expression: {
1299+
end: 327,
1300+
left: {
1301+
end: 313,
1302+
loc: {
1303+
end: {
1304+
column: 1,
1305+
line: 15,
1306+
},
1307+
identifierName: "f",
1308+
start: {
1309+
column: 0,
1310+
line: 15,
1311+
},
1312+
},
1313+
name: "f",
1314+
start: 312,
1315+
type: "Identifier",
1316+
},
1317+
loc: {
1318+
end: {
1319+
column: 15,
1320+
line: 15,
1321+
},
1322+
start: {
1323+
column: 0,
1324+
line: 15,
1325+
},
1326+
},
1327+
operator: "=",
1328+
right: {
1329+
end: 327,
1330+
extra: {
1331+
raw: "\"\\u{1D306}\"",
1332+
rawValue: "𝌆",
1333+
},
1334+
loc: {
1335+
end: {
1336+
column: 15,
1337+
line: 15,
1338+
},
1339+
start: {
1340+
column: 4,
1341+
line: 15,
1342+
},
1343+
},
1344+
start: 316,
1345+
type: "StringLiteral",
1346+
value: "𝌆",
1347+
},
1348+
start: 312,
1349+
type: "AssignmentExpression",
1350+
},
1351+
loc: {
1352+
end: {
1353+
column: 15,
1354+
line: 15,
1355+
},
1356+
start: {
1357+
column: 0,
1358+
line: 15,
1359+
},
1360+
},
1361+
start: 312,
1362+
type: "ExpressionStatement",
1363+
},
12961364
],
12971365
directives: [],
1298-
end: 311,
1366+
end: 328,
12991367
loc: {
13001368
end: {
13011369
column: 0,
1302-
line: 14,
1370+
line: 16,
13031371
},
13041372
start: {
13051373
column: 0,

fixtures/string-literal.js.uast

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
col: 1,
88
},
99
end: { '@type': "uast:Position",
10-
offset: 312,
11-
line: 14,
10+
offset: 329,
11+
line: 16,
1212
col: 1,
1313
},
1414
},
@@ -22,8 +22,8 @@
2222
col: 1,
2323
},
2424
end: { '@type': "uast:Position",
25-
offset: 312,
26-
line: 14,
25+
offset: 329,
26+
line: 16,
2727
col: 1,
2828
},
2929
},
@@ -1273,6 +1273,72 @@
12731273
},
12741274
},
12751275
},
1276+
{ '@type': "ExpressionStatement",
1277+
'@role': [Statement],
1278+
'@pos': { '@type': "uast:Positions",
1279+
start: { '@type': "uast:Position",
1280+
offset: 313,
1281+
line: 15,
1282+
col: 1,
1283+
},
1284+
end: { '@type': "uast:Position",
1285+
offset: 328,
1286+
line: 15,
1287+
col: 16,
1288+
},
1289+
},
1290+
expression: { '@type': "AssignmentExpression",
1291+
'@role': [Assignment, Binary, Expression, Operator],
1292+
'@pos': { '@type': "uast:Positions",
1293+
start: { '@type': "uast:Position",
1294+
offset: 313,
1295+
line: 15,
1296+
col: 1,
1297+
},
1298+
end: { '@type': "uast:Position",
1299+
offset: 328,
1300+
line: 15,
1301+
col: 16,
1302+
},
1303+
},
1304+
left: { '@type': "Identifier",
1305+
'@token': "f",
1306+
'@role': [Assignment, Binary, Expression, Identifier, Left],
1307+
'@pos': { '@type': "uast:Positions",
1308+
start: { '@type': "uast:Position",
1309+
offset: 313,
1310+
line: 15,
1311+
col: 1,
1312+
},
1313+
end: { '@type': "uast:Position",
1314+
offset: 314,
1315+
line: 15,
1316+
col: 2,
1317+
},
1318+
},
1319+
},
1320+
operator: { '@type': "uast:Operator",
1321+
'@token': "=",
1322+
'@role': [Assignment, Binary, Expression, Operator],
1323+
},
1324+
right: { '@type': "StringLiteral",
1325+
'@token': "\"\\u{1D306}\"",
1326+
'@role': [Assignment, Binary, Expression, Literal, Right, String],
1327+
'@pos': { '@type': "uast:Positions",
1328+
start: { '@type': "uast:Position",
1329+
offset: 317,
1330+
line: 15,
1331+
col: 5,
1332+
},
1333+
end: { '@type': "uast:Position",
1334+
offset: 328,
1335+
line: 15,
1336+
col: 16,
1337+
},
1338+
},
1339+
},
1340+
},
1341+
},
12761342
],
12771343
directives: [],
12781344
sourceType: "script",

0 commit comments

Comments
 (0)