aboutsummaryrefslogtreecommitdiff
path: root/test/ufuzz
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-01 02:36:45 +0000
committerGitHub <noreply@github.com>2021-02-01 10:36:45 +0800
commitd4685640a00a0c998041c96ec197e613bd67b7b3 (patch)
tree53ed8185a109028e4270993fc1d6962fcc22495b /test/ufuzz
parentac7b5c07d778d3b70bf39c4c0014e9411d780268 (diff)
downloadtracifyjs-d4685640a00a0c998041c96ec197e613bd67b7b3.tar.gz
tracifyjs-d4685640a00a0c998041c96ec197e613bd67b7b3.zip
support template literals (#4601)
Diffstat (limited to 'test/ufuzz')
-rw-r--r--test/ufuzz/index.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index bee4c399..86badf3a 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -146,6 +146,7 @@ var SUPPORT = function(matrix) {
rest_object: "var {...a} = {};",
spread: "[...[]];",
spread_object: "({...0});",
+ template: "``",
trailing_comma: "function f(a,) {}",
});
@@ -1038,6 +1039,7 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
case p++:
return rng(2) + " === 1 ? a : b";
case p++:
+ if (SUPPORT.template && rng(20) == 0) return createTemplateLiteral(recurmax, stmtDepth, canThrow);
case p++:
return createValue();
case p++:
@@ -1298,6 +1300,28 @@ function createArrayLiteral(recurmax, stmtDepth, canThrow) {
return "[" + arr.join(", ") + "]";
}
+function createTemplateLiteral(recurmax, stmtDepth, canThrow) {
+ recurmax--;
+ var s = [];
+ addText();
+ for (var i = rng(6); --i >= 0;) {
+ s.push("${", createExpression(recurmax, COMMA_OK, stmtDepth, canThrow), "}");
+ addText();
+ }
+ return (rng(10) ? "`" : "String.raw`") + s.join(rng(5) ? "" : "\n") + "`";
+
+ function addText() {
+ while (rng(5) == 0) s.push([
+ " ",
+ "$",
+ "}",
+ "\\`",
+ "\\\\",
+ "tmpl",
+ ][rng(6)]);
+ }
+}
+
var SAFE_KEYS = [
"length",
"foo",