Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Unified Diff: test/mjsunit/harmony/template-escapes.js

Issue 2665513002: [parser] Lift template literal invalid escape restriction (Closed)
Patch Set: reintroduce DCHECK_EQ Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/compiler/literals.js ('k') | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/template-escapes.js
diff --git a/test/mjsunit/harmony/template-escapes.js b/test/mjsunit/harmony/template-escapes.js
new file mode 100644
index 0000000000000000000000000000000000000000..fcaf8ac5bfcfa79e361852c144cca13139317959
--- /dev/null
+++ b/test/mjsunit/harmony/template-escapes.js
@@ -0,0 +1,785 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-template-escapes
+
+function check({cooked, raw, exprs}) {
+ return function(strs, ...args) {
+ assertArrayEquals(cooked, strs);
+ assertArrayEquals(raw, strs.raw);
+ assertArrayEquals(exprs, args);
+ };
+}
+
+// clang-format off
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\01'
+ ],
+ 'exprs': []
+})`\01`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\01',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\01${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\01'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\01`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\01',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\01${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\1'
+ ],
+ 'exprs': []
+})`\1`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\1',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\1${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\1'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\1`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\1',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\1${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\xg'
+ ],
+ 'exprs': []
+})`\xg`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\xg',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\xg${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\xg'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\xg`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\xg',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\xg${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\xAg'
+ ],
+ 'exprs': []
+})`\xAg`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\xAg',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\xAg${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\xAg'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\xAg`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\xAg',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\xAg${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u0'
+ ],
+ 'exprs': []
+})`\u0`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u0',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u0${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u0'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u0`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u0',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u0${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u0g'
+ ],
+ 'exprs': []
+})`\u0g`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u0g',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u0g${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u0g'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u0g`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u0g',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u0g${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u00g'
+ ],
+ 'exprs': []
+})`\u00g`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u00g',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u00g${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u00g'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u00g`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u00g',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u00g${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u000g'
+ ],
+ 'exprs': []
+})`\u000g`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u000g',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u000g${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u000g'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u000g`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u000g',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u000g${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{}'
+ ],
+ 'exprs': []
+})`\u{}`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{}',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{}${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{}'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{}`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{}',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{}${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{-0}'
+ ],
+ 'exprs': []
+})`\u{-0}`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{-0}',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{-0}${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{-0}'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{-0}`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{-0}',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{-0}${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{g}'
+ ],
+ 'exprs': []
+})`\u{g}`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{g}',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{g}${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{g}'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{g}`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{g}',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{g}${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{0'
+ ],
+ 'exprs': []
+})`\u{0`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{0',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{0${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{0'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{0`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{0',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{0${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{\\u{0}'
+ ],
+ 'exprs': []
+})`\u{\u{0}`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{\\u{0}',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{\u{0}${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{\\u{0}'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{\u{0}`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{\\u{0}',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{\u{0}${1}right`;
+
+check({
+ 'cooked': [
+ undefined
+ ],
+ 'raw': [
+ '\\u{110000}'
+ ],
+ 'exprs': []
+})`\u{110000}`;
+
+check({
+ 'cooked': [
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ '\\u{110000}',
+ 'right'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`\u{110000}${0}right`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined
+ ],
+ 'raw': [
+ 'left',
+ '\\u{110000}'
+ ],
+ 'exprs': [
+ 0
+ ]
+})`left${0}\u{110000}`;
+
+check({
+ 'cooked': [
+ 'left',
+ undefined,
+ 'right'
+ ],
+ 'raw': [
+ 'left',
+ '\\u{110000}',
+ 'right'
+ ],
+ 'exprs': [
+ 0,
+ 1
+ ]
+})`left${0}\u{110000}${1}right`;
« no previous file with comments | « test/mjsunit/compiler/literals.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698