Skip to content

Commit 905375d

Browse files
Merge pull request #2807 from Microsoft/templateBackslashTests
Backslash escape tests for template strings
2 parents 8d4d7df + c7db1c3 commit 905375d

8 files changed

+103
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [templateStringWithBackslashEscapes01.ts]
2+
3+
4+
var a = `hello\world`;
5+
var b = `hello\\world`;
6+
var c = `hello\\\world`;
7+
var d = `hello\\\\world`;
8+
9+
//// [templateStringWithBackslashEscapes01.js]
10+
var a = "helloworld";
11+
var b = "hello\\world";
12+
var c = "hello\\world";
13+
var d = "hello\\\\world";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/conformance/es6/templates/templateStringWithBackslashEscapes01.ts ===
2+
3+
4+
var a = `hello\world`;
5+
>a : Symbol(a, Decl(templateStringWithBackslashEscapes01.ts, 2, 3))
6+
7+
var b = `hello\\world`;
8+
>b : Symbol(b, Decl(templateStringWithBackslashEscapes01.ts, 3, 3))
9+
10+
var c = `hello\\\world`;
11+
>c : Symbol(c, Decl(templateStringWithBackslashEscapes01.ts, 4, 3))
12+
13+
var d = `hello\\\\world`;
14+
>d : Symbol(d, Decl(templateStringWithBackslashEscapes01.ts, 5, 3))
15+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/conformance/es6/templates/templateStringWithBackslashEscapes01.ts ===
2+
3+
4+
var a = `hello\world`;
5+
>a : string
6+
>`hello\world` : string
7+
8+
var b = `hello\\world`;
9+
>b : string
10+
>`hello\\world` : string
11+
12+
var c = `hello\\\world`;
13+
>c : string
14+
>`hello\\\world` : string
15+
16+
var d = `hello\\\\world`;
17+
>d : string
18+
>`hello\\\\world` : string
19+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [templateStringWithBackslashEscapes01_ES6.ts]
2+
3+
var a = `hello\world`;
4+
var b = `hello\\world`;
5+
var c = `hello\\\world`;
6+
var d = `hello\\\\world`;
7+
8+
//// [templateStringWithBackslashEscapes01_ES6.js]
9+
var a = `hello\world`;
10+
var b = `hello\\world`;
11+
var c = `hello\\\world`;
12+
var d = `hello\\\\world`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/es6/templates/templateStringWithBackslashEscapes01_ES6.ts ===
2+
3+
var a = `hello\world`;
4+
>a : Symbol(a, Decl(templateStringWithBackslashEscapes01_ES6.ts, 1, 3))
5+
6+
var b = `hello\\world`;
7+
>b : Symbol(b, Decl(templateStringWithBackslashEscapes01_ES6.ts, 2, 3))
8+
9+
var c = `hello\\\world`;
10+
>c : Symbol(c, Decl(templateStringWithBackslashEscapes01_ES6.ts, 3, 3))
11+
12+
var d = `hello\\\\world`;
13+
>d : Symbol(d, Decl(templateStringWithBackslashEscapes01_ES6.ts, 4, 3))
14+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/conformance/es6/templates/templateStringWithBackslashEscapes01_ES6.ts ===
2+
3+
var a = `hello\world`;
4+
>a : string
5+
>`hello\world` : string
6+
7+
var b = `hello\\world`;
8+
>b : string
9+
>`hello\\world` : string
10+
11+
var c = `hello\\\world`;
12+
>c : string
13+
>`hello\\\world` : string
14+
15+
var d = `hello\\\\world`;
16+
>d : string
17+
>`hello\\\\world` : string
18+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+

2+
3+
var a = `hello\world`;
4+
var b = `hello\\world`;
5+
var c = `hello\\\world`;
6+
var d = `hello\\\\world`;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @target: es6
2+
3+
var a = `hello\world`;
4+
var b = `hello\\world`;
5+
var c = `hello\\\world`;
6+
var d = `hello\\\\world`;

0 commit comments

Comments
 (0)