diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/node_version.js | 28 | ||||
-rwxr-xr-x | test/run-tests.js | 20 |
2 files changed, 45 insertions, 3 deletions
diff --git a/test/compress/node_version.js b/test/compress/node_version.js index ad0bfa15..ef62fd70 100644 --- a/test/compress/node_version.js +++ b/test/compress/node_version.js @@ -1,4 +1,4 @@ -eval_let: { +eval_let_6: { input: { eval("let a;"); console.log(); @@ -10,3 +10,29 @@ eval_let: { expect_stdout: "" node_version: ">=6" } + +eval_let_4: { + input: { + eval("let a;"); + console.log(); + } + expect: { + eval("let a;"); + console.log(); + } + expect_stdout: SyntaxError("Block-scoped declarations (let, const, function, class) not yet supported outside strict mode") + node_version: "4" +} + +eval_let_0: { + input: { + eval("let a;"); + console.log(); + } + expect: { + eval("let a;"); + console.log(); + } + expect_stdout: SyntaxError("Unexpected identifier") + node_version: "<=0.12" +} diff --git a/test/run-tests.js b/test/run-tests.js index 8427d4a8..188532ea 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -294,8 +294,24 @@ function parse_test(file) { if (label.name == "expect_exact" || label.name == "node_version") { test[label.name] = read_string(stat); } else if (label.name == "expect_stdout") { - if (stat.TYPE == "SimpleStatement" && stat.body instanceof U.AST_Boolean) { - test[label.name] = stat.body.value; + if (stat.TYPE == "SimpleStatement") { + var body = stat.body; + if (body instanceof U.AST_Boolean) { + test[label.name] = body.value; + } else if (body instanceof U.AST_Call) { + var ctor = global[body.expression.name]; + assert.ok(ctor === Error || ctor.prototype instanceof Error, tmpl("Unsupported expect_stdout format [{line},{col}]", { + line: label.start.line, + col: label.start.col + })); + test[label.name] = ctor.apply(null, body.args.map(function(node) { + assert.ok(node instanceof U.AST_Constant, tmpl("Unsupported expect_stdout format [{line},{col}]", { + line: label.start.line, + col: label.start.col + })); + return node.value; + })); + } } else { test[label.name] = read_string(stat) + "\n"; } |