Conflicts:
	README.md
	acorn.js
	package.json
This commit is contained in:
Sebastian McKenzie
2014-12-27 20:02:15 +11:00
8 changed files with 325 additions and 89 deletions

View File

@@ -58,7 +58,6 @@
parse: (typeof require === "undefined" ? window.acorn : require("../acorn_loose")).parse_dammit,
loose: true,
filter: function (test) {
if (/`/.test(test.code)) return false; // FIXME remove this when the loose parse supports template strings
var opts = test.options || {};
if (opts.loose === false) return false;
return (opts.ecmaVersion || 5) <= 6;

View File

@@ -482,8 +482,6 @@ test('({x, ...y, a, ...b, c})', {
testFail("function foo(promise) { await promise; }", "Unexpected token (1:30)", {ecmaVersion: 7});
testFail("async function* foo(promise) { await promise; }", "Unexpected token (1:14)", {ecmaVersion: 7});
test('async function foo(promise) { await promise; }', {
type: "Program",
body: [{

View File

@@ -976,6 +976,131 @@ test("new raw`42`", {
locations: true
});
test("`outer${{x: {y: 10}}}bar${`nested${function(){return 1;}}endnest`}end`",{
type: "Program",
body: [
{
type: "ExpressionStatement",
expression: {
type: "TemplateLiteral",
expressions: [
{
type: "ObjectExpression",
properties: [
{
type: "Property",
method: false,
shorthand: false,
computed: false,
key: {
type: "Identifier",
name: "x"
},
value: {
type: "ObjectExpression",
properties: [
{
type: "Property",
method: false,
shorthand: false,
computed: false,
key: {
type: "Identifier",
name: "y"
},
value: {
type: "Literal",
value: 10,
raw: "10"
},
kind: "init"
}
]
},
kind: "init"
}
]
},
{
type: "TemplateLiteral",
expressions: [
{
type: "FunctionExpression",
id: null,
params: [],
defaults: [],
rest: null,
generator: false,
body: {
type: "BlockStatement",
body: [
{
type: "ReturnStatement",
argument: {
type: "Literal",
value: 1,
raw: "1"
}
}
]
},
expression: false
}
],
quasis: [
{
type: "TemplateElement",
value: {
cooked: "nested",
raw: "nested"
},
tail: false
},
{
type: "TemplateElement",
value: {
cooked: "endnest",
raw: "endnest"
},
tail: true
}
]
}
],
quasis: [
{
type: "TemplateElement",
value: {
cooked: "outer",
raw: "outer"
},
tail: false
},
{
type: "TemplateElement",
value: {
cooked: "bar",
raw: "bar"
},
tail: false
},
{
type: "TemplateElement",
value: {
cooked: "end",
raw: "end"
},
tail: true
}
]
}
}
]
}, {
ecmaVersion: 6
});
// ES6: Switch Case Declaration
test("switch (answer) { case 42: let t = 42; break; }", {
@@ -13972,7 +14097,7 @@ testFail("class A extends yield B { }", "Unexpected token (1:22)", {ecmaVersion:
testFail("class default", "Unexpected token (1:6)", {ecmaVersion: 6});
testFail("`test", "Unterminated string constant (1:1)", {ecmaVersion: 6});
testFail("`test", "Unterminated template (1:0)", {ecmaVersion: 6});
testFail("switch `test`", "Unexpected token (1:7)", {ecmaVersion: 6});
@@ -14026,6 +14151,8 @@ testFail("({ t(eval) { \"use strict\"; } });", "Defining 'eval' in strict mode (
testFail("\"use strict\"; `${test}\\02`;", "Octal literal in strict mode (1:22)", {ecmaVersion: 6});
testFail("if (1) import \"acorn\";", "'import' and 'export' may only appear at the top level (1:7)", {ecmaVersion: 6});
test("[...a, ] = b", {
type: "Program",
loc: {

View File

@@ -28834,3 +28834,14 @@ test('var x = (1 + 2)', {}, {
});
test("function f(f) { 'use strict'; }", {});
// https://github.com/marijnh/acorn/issues/180
test("#!/usr/bin/node\n;", {}, {
allowHashBang: true,
onComment: [{
type: "Line",
value: "/usr/bin/node",
start: 0,
end: 15
}]
});