diff --git a/test/fixtures/lightscript/arrow-expressions/skinny-curly/expected.json b/test/fixtures/lightscript/arrow-expressions/skinny-curly/expected.json index 0505dbb550..7adf40f53d 100644 --- a/test/fixtures/lightscript/arrow-expressions/skinny-curly/expected.json +++ b/test/fixtures/lightscript/arrow-expressions/skinny-curly/expected.json @@ -79,40 +79,95 @@ "body": [ { "type": "ExpressionStatement", - "start": 10, - "end": 11, + "start": 6, + "end": 13, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 6 }, "end": { - "line": 2, - "column": 3 + "line": 3, + "column": 1 } }, "expression": { - "type": "Identifier", - "start": 10, - "end": 11, + "type": "ObjectExpression", + "start": 6, + "end": 13, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 6 }, "end": { - "line": 2, - "column": 3 - }, - "identifierName": "x" + "line": 3, + "column": 1 + } }, - "name": "x" + "properties": [ + { + "type": "ObjectProperty", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "value": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "shorthand": true + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/commaless/arrow-expr-params/expected.json b/test/fixtures/lightscript/commaless/arrow-expr-params/expected.json index ca10c8f91f..0ec97cc280 100644 --- a/test/fixtures/lightscript/commaless/arrow-expr-params/expected.json +++ b/test/fixtures/lightscript/commaless/arrow-expr-params/expected.json @@ -111,10 +111,42 @@ "column": 7 } }, - "body": [], + "body": [ + { + "type": "ExpressionStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "properties": [] + } + } + ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/commaless/arrow-expr-params/options.json b/test/fixtures/lightscript/commaless/arrow-expr-params/options.json index 8e44176f95..b223b375f8 100644 --- a/test/fixtures/lightscript/commaless/arrow-expr-params/options.json +++ b/test/fixtures/lightscript/commaless/arrow-expr-params/options.json @@ -1,7 +1,7 @@ { "alternatives": { "objectBlockAmbiguity": { - "excludePlugins": ["objectBlockAmbiguity_preferObject"], + "excludePlugins": ["whiteblockOnly", "whiteblockPreferred"], "expected": "expected.objectBlockAmbiguity.json" } } diff --git a/test/fixtures/lightscript/for-in/now/expected.whiteblock.json b/test/fixtures/lightscript/for-in/now/expected.braceblock.json similarity index 66% rename from test/fixtures/lightscript/for-in/now/expected.whiteblock.json rename to test/fixtures/lightscript/for-in/now/expected.braceblock.json index aadc64121b..60e6db5e1e 100644 --- a/test/fixtures/lightscript/for-in/now/expected.whiteblock.json +++ b/test/fixtures/lightscript/for-in/now/expected.braceblock.json @@ -79,54 +79,22 @@ }, "body": { "type": "BlockStatement", - "start": 16, + "start": 18, "end": 20, "loc": { "start": { "line": 1, - "column": 16 + "column": 18 }, "end": { "line": 1, "column": 20 } }, - "body": [ - { - "type": "ExpressionStatement", - "start": 18, - "end": 20, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 20 - } - }, - "expression": { - "type": "ObjectExpression", - "start": 18, - "end": 20, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 20 - } - }, - "properties": [] - } - } - ], + "body": [], "directives": [], "extra": { - "curly": false + "curly": true } } } diff --git a/test/fixtures/lightscript/for-in/now/expected.json b/test/fixtures/lightscript/for-in/now/expected.json index 60e6db5e1e..aadc64121b 100644 --- a/test/fixtures/lightscript/for-in/now/expected.json +++ b/test/fixtures/lightscript/for-in/now/expected.json @@ -79,22 +79,54 @@ }, "body": { "type": "BlockStatement", - "start": 18, + "start": 16, "end": 20, "loc": { "start": { "line": 1, - "column": 18 + "column": 16 }, "end": { "line": 1, "column": 20 } }, - "body": [], + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "properties": [] + } + } + ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/for-in/now/options.json b/test/fixtures/lightscript/for-in/now/options.json index 789ef9baa7..b653bf986f 100644 --- a/test/fixtures/lightscript/for-in/now/options.json +++ b/test/fixtures/lightscript/for-in/now/options.json @@ -1,8 +1,9 @@ { "alternatives": { - "whiteblock": { + "braceblock": { "allPlugins": true, - "expected": "expected.whiteblock.json" + "excludePlugins": ["whiteblockOnly", "whiteblockPreferred"], + "expected": "expected.braceblock.json" } } } diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.whiteblock.json b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.braceblock.json similarity index 64% rename from test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.whiteblock.json rename to test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.braceblock.json index 12082daac4..84fe23bc04 100644 --- a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.whiteblock.json +++ b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.braceblock.json @@ -78,42 +78,10 @@ "column": 10 } }, - "body": [ - { - "type": "ExpressionStatement", - "start": 8, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "expression": { - "type": "ObjectExpression", - "start": 8, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "properties": [] - } - } - ], + "body": [], "directives": [], "extra": { - "curly": false + "curly": true } } } diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.json b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.json index 84fe23bc04..12082daac4 100644 --- a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.json +++ b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/expected.json @@ -78,10 +78,42 @@ "column": 10 } }, - "body": [], + "body": [ + { + "type": "ExpressionStatement", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "properties": [] + } + } + ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/options.json b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/options.json index aaf6bdcf7f..af413d2590 100644 --- a/test/fixtures/lightscript/named-arrow-functions/skinny-curly/options.json +++ b/test/fixtures/lightscript/named-arrow-functions/skinny-curly/options.json @@ -1,9 +1,9 @@ { "alternatives": { - "whiteblock": { + "braceblock": { "allPlugins": true, - "excludePlugins": ["whiteblockPreferred"], - "expected": "expected.whiteblock.json" + "excludePlugins": ["whiteblockPreferred", "whiteblockOnly"], + "expected": "expected.braceblock.json" } } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/basic/expected.braceblock.json b/test/fixtures/lightscript/object-block-ambiguity/basic/expected.braceblock.json new file mode 100644 index 0000000000..69b001f468 --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/basic/expected.braceblock.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "NamedArrowDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "expression": false, + "async": false, + "params": [], + "skinny": false, + "body": { + "type": "BlockStatement", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [], + "extra": { + "curly": true + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/basic/expected.json b/test/fixtures/lightscript/object-block-ambiguity/basic/expected.json index 69b001f468..59108260c1 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/basic/expected.json +++ b/test/fixtures/lightscript/object-block-ambiguity/basic/expected.json @@ -81,40 +81,95 @@ "body": [ { "type": "ExpressionStatement", - "start": 11, - "end": 12, + "start": 7, + "end": 14, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 7 }, "end": { - "line": 2, - "column": 3 + "line": 3, + "column": 1 } }, "expression": { - "type": "Identifier", - "start": 11, - "end": 12, + "type": "ObjectExpression", + "start": 7, + "end": 14, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 7 }, "end": { - "line": 2, - "column": 3 - }, - "identifierName": "x" + "line": 3, + "column": 1 + } }, - "name": "x" + "properties": [ + { + "type": "ObjectProperty", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "value": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "shorthand": true + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/basic/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/basic/expected.whiteblockOnly.json similarity index 100% rename from test/fixtures/lightscript/object-block-ambiguity/basic/expected.whiteblock.json rename to test/fixtures/lightscript/object-block-ambiguity/basic/expected.whiteblockOnly.json diff --git a/test/fixtures/lightscript/object-block-ambiguity/error-obj/options.json b/test/fixtures/lightscript/object-block-ambiguity/error-obj/options.json index 0b7c1c9523..775b361f69 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/error-obj/options.json +++ b/test/fixtures/lightscript/object-block-ambiguity/error-obj/options.json @@ -1,9 +1,12 @@ { "alternatives": { - "whiteblock": { + "all": { "throws": "Expected an Indent or Statement (7:6)" }, - "all": { + "whiteblockOnly": { + "throws": "Expected an Indent or Statement (7:6)" + }, + "braceblock": { "throws": "Leading decorators must be attached to a class declaration (7:2)" } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/if/expected.braceblock.json b/test/fixtures/lightscript/object-block-ambiguity/if/expected.braceblock.json new file mode 100644 index 0000000000..5806448ace --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/if/expected.braceblock.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "test": { + "type": "Identifier", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "consequent": { + "type": "BlockStatement", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "y" + }, + "name": "y" + } + } + ], + "directives": [], + "extra": { + "curly": true + } + }, + "alternate": { + "type": "BlockStatement", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "z" + }, + "name": "z" + } + } + ], + "directives": [], + "extra": { + "curly": true + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/if/expected.json b/test/fixtures/lightscript/object-block-ambiguity/if/expected.json index 5806448ace..0bac2c4603 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/if/expected.json +++ b/test/fixtures/lightscript/object-block-ambiguity/if/expected.json @@ -61,12 +61,12 @@ }, "consequent": { "type": "BlockStatement", - "start": 6, + "start": 4, "end": 11, "loc": { "start": { "line": 1, - "column": 6 + "column": 4 }, "end": { "line": 1, @@ -76,50 +76,105 @@ "body": [ { "type": "ExpressionStatement", - "start": 8, - "end": 9, + "start": 6, + "end": 11, "loc": { "start": { "line": 1, - "column": 8 + "column": 6 }, "end": { "line": 1, - "column": 9 + "column": 11 } }, "expression": { - "type": "Identifier", - "start": 8, - "end": 9, + "type": "ObjectExpression", + "start": 6, + "end": 11, "loc": { "start": { "line": 1, - "column": 8 + "column": 6 }, "end": { "line": 1, - "column": 9 - }, - "identifierName": "y" + "column": 11 + } }, - "name": "y" + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "y" + }, + "name": "y" + }, + "value": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "y" + }, + "name": "y" + }, + "extra": { + "shorthand": true + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } }, "alternate": { "type": "BlockStatement", - "start": 18, + "start": 16, "end": 25, "loc": { "start": { "line": 1, - "column": 18 + "column": 16 }, "end": { "line": 3, @@ -129,40 +184,95 @@ "body": [ { "type": "ExpressionStatement", - "start": 22, - "end": 23, + "start": 18, + "end": 25, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 18 }, "end": { - "line": 2, - "column": 3 + "line": 3, + "column": 1 } }, "expression": { - "type": "Identifier", - "start": 22, - "end": 23, + "type": "ObjectExpression", + "start": 18, + "end": 25, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 18 }, "end": { - "line": 2, - "column": 3 - }, - "identifierName": "z" + "line": 3, + "column": 1 + } }, - "name": "z" + "properties": [ + { + "type": "ObjectProperty", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "z" + }, + "name": "z" + }, + "value": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "z" + }, + "name": "z" + }, + "extra": { + "shorthand": true + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/if/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/if/expected.whiteblockOnly.json similarity index 100% rename from test/fixtures/lightscript/object-block-ambiguity/if/expected.whiteblock.json rename to test/fixtures/lightscript/object-block-ambiguity/if/expected.whiteblockOnly.json diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/actual.js b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/actual.js index 497e7c4086..26ad29aeec 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/actual.js +++ b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/actual.js @@ -1,3 +1,3 @@ if true: { - for elem e in arr: e + ...for elem e in arr: e } diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.json b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.json index f2b3febedc..46e3fab42f 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.json +++ b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 35, + "end": 38, "loc": { "start": { "line": 1, @@ -15,7 +15,7 @@ "program": { "type": "Program", "start": 0, - "end": 35, + "end": 38, "loc": { "start": { "line": 1, @@ -31,7 +31,7 @@ { "type": "IfStatement", "start": 0, - "end": 35, + "end": 38, "loc": { "start": { "line": 1, @@ -60,12 +60,12 @@ }, "consequent": { "type": "BlockStatement", - "start": 9, - "end": 35, + "start": 7, + "end": 38, "loc": { "start": { "line": 1, - "column": 9 + "column": 7 }, "end": { "line": 3, @@ -74,90 +74,137 @@ }, "body": [ { - "type": "ForInArrayStatement", - "start": 13, - "end": 33, + "type": "ExpressionStatement", + "start": 9, + "end": 38, "loc": { "start": { - "line": 2, - "column": 2 + "line": 1, + "column": 9 }, "end": { - "line": 2, - "column": 22 + "line": 3, + "column": 1 } }, - "elem": { - "type": "Identifier", - "start": 22, - "end": 23, - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 12 - }, - "identifierName": "e" - }, - "name": "e" - }, - "body": { - "type": "ExpressionStatement", - "start": 32, - "end": 33, + "expression": { + "type": "ObjectComprehension", + "start": 9, + "end": 38, "loc": { "start": { - "line": 2, - "column": 21 + "line": 1, + "column": 9 }, "end": { - "line": 2, - "column": 22 + "line": 3, + "column": 1 } }, - "expression": { - "type": "Identifier", - "start": 32, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 21 + "properties": [ + { + "type": "LoopComprehension", + "start": 13, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 25 + } }, - "end": { - "line": 2, - "column": 22 - }, - "identifierName": "e" - }, - "name": "e" - } - }, - "array": { - "type": "Identifier", - "start": 27, - "end": 30, - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 19 - }, - "identifierName": "arr" - }, - "name": "arr" + "loop": { + "type": "ForInArrayStatement", + "start": 13, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "elem": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "e" + }, + "name": "e" + }, + "body": { + "type": "ExpressionStatement", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "expression": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "e" + }, + "name": "e" + } + }, + "array": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "arr" + }, + "name": "arr" + } + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } }, "alternate": null diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json deleted file mode 100644 index 814c1eb48e..0000000000 --- a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json +++ /dev/null @@ -1,199 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "sourceType": "script", - "body": [ - { - "type": "IfStatement", - "start": 0, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "test": { - "type": "BooleanLiteral", - "start": 3, - "end": 7, - "loc": { - "start": { - "line": 1, - "column": 3 - }, - "end": { - "line": 1, - "column": 7 - } - }, - "value": true - }, - "consequent": { - "type": "BlockStatement", - "start": 7, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "start": 9, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "expression": { - "type": "ObjectComprehension", - "start": 9, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "properties": [], - "loop": { - "type": "ForInArrayStatement", - "start": 13, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 22 - } - }, - "elem": { - "type": "Identifier", - "start": 22, - "end": 23, - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 12 - }, - "identifierName": "e" - }, - "name": "e" - }, - "body": { - "type": "ExpressionStatement", - "start": 32, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - } - }, - "expression": { - "type": "Identifier", - "start": 32, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - }, - "identifierName": "e" - }, - "name": "e" - } - }, - "array": { - "type": "Identifier", - "start": 27, - "end": 30, - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 19 - }, - "identifierName": "arr" - }, - "name": "arr" - } - } - } - } - ], - "directives": [], - "extra": { - "curly": false - } - }, - "alternate": null - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblockOnly.json b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblockOnly.json new file mode 100644 index 0000000000..46e3fab42f --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblockOnly.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 3, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "start": 7, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "expression": { + "type": "ObjectComprehension", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "LoopComprehension", + "start": 13, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "loop": { + "type": "ForInArrayStatement", + "start": 13, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "elem": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "e" + }, + "name": "e" + }, + "body": { + "type": "ExpressionStatement", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "expression": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "e" + }, + "name": "e" + } + }, + "array": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "arr" + }, + "name": "arr" + } + } + } + ] + } + } + ], + "directives": [], + "extra": { + "curly": false + } + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/options.json b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/options.json new file mode 100644 index 0000000000..7c6a48606a --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/options.json @@ -0,0 +1,7 @@ +{ + "alternatives": { + "braceblock": { + "throws": "Unexpected token (2:2)" + } + } +} diff --git a/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.braceblock.json b/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.braceblock.json new file mode 100644 index 0000000000..d97d38bee6 --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.braceblock.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "body": [ + { + "type": "NamedArrowDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "expression": false, + "async": false, + "params": [], + "skinny": false, + "body": { + "type": "BlockStatement", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [], + "extra": { + "curly": true + } + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "ExpressionStatement", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "y" + }, + "name": "y" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.json b/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.json index d97d38bee6..efc2ffd412 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.json +++ b/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.json @@ -81,40 +81,95 @@ "body": [ { "type": "ExpressionStatement", - "start": 9, - "end": 10, + "start": 7, + "end": 12, "loc": { "start": { "line": 1, - "column": 9 + "column": 7 }, "end": { "line": 1, - "column": 10 + "column": 12 } }, "expression": { - "type": "Identifier", - "start": 9, - "end": 10, + "type": "ObjectExpression", + "start": 7, + "end": 12, "loc": { "start": { "line": 1, - "column": 9 + "column": 7 }, "end": { "line": 1, - "column": 10 - }, - "identifierName": "x" + "column": 12 + } }, - "name": "x" + "properties": [ + { + "type": "ObjectProperty", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "value": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "shorthand": true + } + } + ] } } ], "directives": [], "extra": { - "curly": true + "curly": false } } }, diff --git a/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.whiteblockOnly.json similarity index 100% rename from test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.whiteblock.json rename to test/fixtures/lightscript/object-block-ambiguity/oneline-semi/expected.whiteblockOnly.json diff --git a/test/fixtures/lightscript/object-block-ambiguity/options.json b/test/fixtures/lightscript/object-block-ambiguity/options.json index 5793535351..a091adfa61 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/options.json +++ b/test/fixtures/lightscript/object-block-ambiguity/options.json @@ -1,9 +1,17 @@ { "alternatives": { - "whiteblock": { + "all": { + "includePlugins": ["splatComprehension"] + }, + "whiteblockOnly": { "allPlugins": true, - "excludePlugins": ["splatComprehension", "whiteblockPreferred"], - "expected": "expected.whiteblock.json" + "excludePlugins": ["whiteblockPreferred"], + "expected": "expected.whiteblockOnly.json" + }, + "braceblock": { + "allPlugins": true, + "excludePlugins": ["whiteblockPreferred", "whiteblockOnly"], + "expected": "expected.braceblock.json" } } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.json similarity index 100% rename from test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.whiteblock.json rename to test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.json diff --git a/test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.whiteblockOnly.json b/test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.whiteblockOnly.json new file mode 100644 index 0000000000..115f7801e7 --- /dev/null +++ b/test/fixtures/lightscript/object-block-ambiguity/tilde-call/expected.whiteblockOnly.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "test": { + "type": "Identifier", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "consequent": { + "type": "BlockStatement", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "CallExpression", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "y" + }, + "name": "y" + }, + "arguments": [ + { + "type": "ObjectExpression", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "properties": [] + } + ], + "tilde": true + } + } + ], + "directives": [], + "extra": { + "curly": false + } + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/object-block-ambiguity/tilde-call/options.json b/test/fixtures/lightscript/object-block-ambiguity/tilde-call/options.json index 22c1a2e3aa..274e29cbb2 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/tilde-call/options.json +++ b/test/fixtures/lightscript/object-block-ambiguity/tilde-call/options.json @@ -1,6 +1,6 @@ { "alternatives": { - "all": { + "braceblock": { "throws": "Unexpected token (1:8)" } }