From b4e92f4d9299437a89a81930faf08b897d62d177 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 7 Oct 2015 14:23:34 -0700 Subject: [PATCH] Breaking: Switch to Acorn (fixes #200) --- .eslintrc | 18 +- .gitignore | 2 + .travis.yml | 1 + README.md | 75 +- espree.js | 5811 ++--------------- lib/ast-node-factory.js | 964 --- lib/features.js | 5 +- lib/messages.js | 99 - lib/string-map.js | 55 - lib/syntax.js | 189 - lib/token-translator.js | 260 + lib/xhtml-entities.js | 293 - package.json | 9 +- .../block-trailing-comment.result.js | 186 +- .../comment-within-condition.result.js | 138 +- .../export-default-anonymous-class.result.js | 416 +- .../surrounding-call-comments.result.js | 268 +- .../surrounding-debugger-comments.result.js | 188 +- .../surrounding-return-comments.result.js | 190 +- .../surrounding-throw-comments.result.js | 230 +- .../surrounding-while-loop-comments.result.js | 372 +- ...-fallthrough-comment-in-function.result.js | 552 +- .../switch-fallthrough-comment.result.js | 398 +- ...h-no-default-comment-in-function.result.js | 516 +- ...ault-comment-in-nested-functions.result.js | 1266 ++-- .../switch-no-default-comment.result.js | 250 +- .../computed-generator.result.js | 4 +- .../error-generator.result.js | 4 +- .../error-no-class.result.js | 4 +- .../error-static-no-generators.result.js | 4 +- .../param-defaults-array.result.js | 3 +- .../param-defaults-object-nested.result.js | 4 +- .../param-defaults-object.result.js | 3 +- .../invalid-rest.result.js | 8 +- ...omplex-destructured-spread-first.result.js | 496 -- .../complex-destructured.result.js | 4 +- .../destructured-array-literal.result.js | 4 +- ...onfig.js => destructuring-param.config.js} | 0 .../destructuring-param.result.js | 511 ++ ...aram.src.js => destructuring-param.src.js} | 0 ...mplex-destructured-spread-first.config.js} | 0 ...omplex-destructured-spread-first.result.js | 6 + ...-complex-destructured-spread-first.src.js} | 0 .../error-destructuring-param.result.js | 6 - .../multi-destructured.result.js | 4 +- .../not-final-array-empty.result.js | 4 +- .../not-final-array.result.js | 313 +- .../single-destructured.result.js | 4 +- .../var-complex-destructured.result.js | 4 +- .../var-destructured-array-literal.result.js | 4 +- .../var-multi-destructured.result.js | 4 +- .../var-single-destructured.result.js | 4 +- .../for-of-declaring-inline.config.js | 3 - .../for-of-declaring-inline.result.js | 420 -- .../for-of-declaring-inline.src.js | 4 - .../forOf-operator/for-of-declaring.config.js | 3 - .../forOf-operator/for-of-declaring.result.js | 474 -- .../forOf-operator/for-of-declaring.src.js | 4 - .../export-const-object.result.js | 20 +- .../export-let-object.result.js | 20 +- .../error-no-shorthand.result.js | 4 +- .../generator-object-literal-method.result.js | 6 +- .../invalid-arrow-rest-params.result.js | 8 +- .../template-strings-in-jsx-multi.result.js | 14 +- .../template-strings-in-jsx.result.js | 14 +- .../as-param-with-params.result.js | 284 +- .../arrowFunctions/as-param.result.js | 230 +- .../arrowFunctions/basic.result.js | 150 +- .../block-body-not-object.result.js | 292 +- .../arrowFunctions/block-body.result.js | 240 +- .../arrowFunctions/error-dup-params.result.js | 6 +- .../error-missing-paren.result.js | 6 +- .../arrowFunctions/error-not-arrow.result.js | 2 +- .../error-numeric-param-multi.result.js | 6 +- .../error-numeric-param-multi.src.js | 2 +- .../error-numeric-param.result.js | 6 +- .../arrowFunctions/error-numeric-param.src.js | 2 +- .../error-reverse-arrow.result.js | 6 +- .../error-strict-default-param-eval.result.js | 2 +- .../error-strict-dup-params.result.js | 6 +- .../error-strict-eval-return.result.js | 6 +- .../error-strict-eval.result.js | 6 +- .../error-strict-octal.result.js | 2 +- .../error-strict-param-arguments.result.js | 6 +- .../error-strict-param-eval.result.js | 6 +- .../error-strict-param-names.result.js | 6 +- ...-strict-param-no-paren-arguments.result.js | 6 +- ...error-strict-param-no-paren-eval.result.js | 6 +- .../arrowFunctions/error-two-lines.result.js | 8 +- .../error-wrapped-param.result.js | 6 +- .../arrowFunctions/expression.result.js | 170 +- .../arrowFunctions/iife.result.js | 292 +- .../arrowFunctions/multiple-params.result.js | 204 +- .../arrowFunctions/no-auto-return.result.js | 292 +- .../not-strict-arguments.result.js | 152 +- .../not-strict-eval-params.result.js | 204 +- .../arrowFunctions/not-strict-eval.result.js | 152 +- .../arrowFunctions/not-strict-octal.result.js | 172 +- .../return-arrow-function.result.js | 216 +- .../arrowFunctions/return-sequence.result.js | 422 +- .../single-param-parens.result.js | 172 +- .../single-param-return-identifier.result.js | 170 +- .../arrowFunctions/single-param.result.js | 152 +- .../binaryLiterals/invalid.result.js | 2 +- .../binaryLiterals/lowercase.result.js | 88 +- .../binaryLiterals/uppercase.result.js | 88 +- .../blockBindings/const.result.js | 158 +- .../blockBindings/let-in-switchcase.result.js | 384 +- .../ecma-features/blockBindings/let.result.js | 158 +- .../class-accessor-properties.result.js | 480 +- .../class-computed-static-method.result.js | 338 +- .../classes/class-expression.result.js | 154 +- .../class-method-named-prototype.result.js | 298 +- .../class-method-named-static.result.js | 308 +- .../classes/class-one-method-super.result.js | 424 +- .../classes/class-one-method.result.js | 298 +- ...ss-static-method-named-prototype.result.js | 330 +- ...class-static-method-named-static.result.js | 318 +- .../classes/class-static-method.result.js | 318 +- ...-methods-and-accessor-properties.result.js | 636 +- ...lass-two-computed-static-methods.result.js | 498 +- ...two-methods-computed-constructor.result.js | 452 +- .../classes/class-two-methods-semi.result.js | 438 +- .../class-two-methods-three-semi.result.js | 458 +- .../class-two-methods-two-semi.result.js | 448 +- .../classes/class-two-methods.result.js | 428 +- ...static-methods-named-constructor.result.js | 448 +- .../classes/class-with-constructor.result.js | 298 +- .../derived-class-assign-to-var.result.js | 262 +- .../derived-class-expression.result.js | 188 +- .../classes/empty-class-double-semi.result.js | 138 +- .../classes/empty-class-semi.result.js | 148 +- .../classes/empty-class.result.js | 138 +- .../empty-literal-derived-class.result.js | 172 +- .../invalid-class-declaration.result.js | 2 +- ...invalid-class-setter-declaration.result.js | 6 +- .../classes/named-class-expression.result.js | 176 +- .../named-derived-class-expression.result.js | 210 +- .../defaultParams/declaration.result.js | 226 +- .../defaultParams/expression.result.js | 292 +- .../defaultParams/method.result.js | 410 +- .../defaultParams/not-all-params.result.js | 376 +- .../destructuring/array-member.result.js | 260 +- .../destructuring/array-to-array.result.js | 304 +- .../array-var-undefined.result.js | 218 +- .../defaults-array-all.result.js | 447 +- ...ults-array-longform-nested-multi.result.js | 657 +- .../defaults-array-multi.result.js | 333 +- .../defaults-array-nested-all.result.js | 408 +- .../defaults-array-nested-multi.result.js | 347 +- .../destructuring/defaults-array.result.js | 247 +- .../defaults-object-all.result.js | 587 +- .../defaults-object-longform-all.result.js | 655 +- .../defaults-object-longform-multi.result.js | 521 +- .../defaults-object-longform.result.js | 337 +- .../defaults-object-mixed-multi.result.js | 477 +- .../defaults-object-multi.result.js | 459 +- .../defaults-object-nested-all.result.js | 570 +- .../defaults-object-nested-multi.result.js | 505 +- .../destructuring/defaults-object.result.js | 307 +- .../destructured-array-catch.result.js | 770 +-- .../destructured-object-catch.result.js | 814 +-- .../destructuring/named-param.result.js | 284 +- .../destructuring/nested-array.result.js | 508 +- .../destructuring/nested-object.result.js | 822 +-- .../destructuring/object-var-named.result.js | 286 +- .../object-var-undefined.result.js | 262 +- .../param-defaults-array.result.js | 277 +- .../param-defaults-object-nested.result.js | 630 +- .../param-defaults-object.result.js | 325 +- .../params-array-wrapped.result.js | 304 +- .../destructuring/params-array.result.js | 266 +- .../params-multi-object.result.js | 310 +- .../params-nested-array.result.js | 336 +- .../params-nested-object.result.js | 512 +- .../params-object-wrapped.result.js | 388 +- .../destructuring/params-object.result.js | 350 +- .../destructuring/sparse-array.result.js | 238 +- .../property-spread.result.js | 704 +- .../single-spread.result.js | 636 +- .../two-spread.result.js | 608 +- ...for-of-with-function-initializer.result.js | 590 +- .../for-of-with-var-and-braces.result.js | 366 +- .../for-of-with-var-and-no-braces.result.js | 316 +- ...-for-of-with-const-and-no-braces.result.js | 2 +- ...id-for-of-with-let-and-no-braces.result.js | 2 +- .../generators/anonymous-generator.result.js | 300 +- .../generators/double-yield.result.js | 344 +- .../empty-generator-declaration.result.js | 172 +- .../generator-declaration.result.js | 294 +- .../generators/yield-delegation.result.js | 310 +- .../yield-without-value-in-call.result.js | 346 +- .../yield-without-value-no-semi.result.js | 262 +- .../generators/yield-without-value.result.js | 272 +- .../globalReturn/return-identifier.result.js | 96 +- .../globalReturn/return-no-arg.result.js | 60 +- .../globalReturn/return-true.result.js | 98 +- .../jsx/embedded-comment.result.js | 296 +- .../jsx/embedded-conditional.result.js | 600 +- .../embedded-invalid-js-identifier.result.js | 378 +- .../ecma-features/jsx/embedded-tags.result.js | 622 +- .../jsx/empty-placeholder.result.js | 296 +- .../jsx/escape-patterns.result.js | 798 +-- ...invalid-attribute-missing-equals.result.js | 2 +- .../jsx/invalid-attribute.result.js | 2 +- .../jsx/invalid-broken-tag.result.js | 6 +- .../invalid-computed-end-tag-name.result.js | 2 +- ...lid-computed-string-end-tag-name.result.js | 2 +- .../jsx/invalid-embedded-expression.result.js | 2 +- .../invalid-leading-dot-tag-name.result.js | 2 +- ...ching-placeholder-in-closing-tag.result.js | 2 +- .../invalid-mismatched-closing-tag.result.js | 6 +- .../invalid-mismatched-closing-tags.result.js | 6 +- .../invalid-mismatched-dot-tag-name.result.js | 6 +- ...invalid-mismatched-namespace-tag.result.js | 6 +- ...losing-tag-attribute-placeholder.result.js | 6 +- .../jsx/invalid-missing-closing-tag.result.js | 6 +- .../invalid-missing-namespace-name.result.js | 2 +- .../invalid-missing-namespace-value.result.js | 6 +- .../invalid-missing-spread-operator.result.js | 2 +- ...nvalid-namespace-name-with-docts.result.js | 2 +- ...nvalid-namespace-value-with-dots.result.js | 559 +- ...id-no-common-parent-with-comment.result.js | 2 +- .../jsx/invalid-no-common-parent.result.js | 2 +- .../jsx/invalid-no-tag-name.result.js | 2 +- ...valid-placeholder-in-closing-tag.result.js | 2 +- .../invalid-trailing-dot-tag-name.result.js | 2 +- .../jsx/invalid-unexpected-comma.result.js | 2 +- .../jsx/japanese-characters.result.js | 240 +- .../jsx/less-than-operator.result.js | 260 +- .../jsx/multiple-blank-spaces.result.js | 264 +- ...ced-attribute-and-value-inserted.result.js | 800 +-- .../namespaced-name-and-attribute.result.js | 374 +- .../jsx/newslines-and-entities.result.js | 2 +- .../self-closing-tag-with-newline.result.js | 2 +- .../jsx/self-closing-tag.result.js | 180 +- ...-attribute-and-regular-attribute.result.js | 352 +- .../jsx/spread-operator-attributes.result.js | 274 +- .../jsx/tag-names-with-dots.result.js | 358 +- .../jsx/tag-names-with-multi-dots.result.js | 474 +- .../ecma-features/jsx/test-content.result.js | 264 +- ...ailing-spread-operator-attribute.result.js | 490 +- .../jsx/unknown-escape-pattern.result.js | 278 +- .../modules/error-delete.result.js | 6 +- .../modules/error-function.result.js | 8 +- .../modules/error-strict.result.js | 2 +- .../modules/export-default-array.result.js | 116 +- .../export-default-expression.result.js | 192 +- .../modules/export-default-function.result.js | 170 +- .../export-default-named-function.result.js | 192 +- .../modules/export-default-number.result.js | 108 +- .../modules/export-default-object.result.js | 228 +- .../modules/export-default-value.result.js | 106 +- .../modules/export-from-batch.result.js | 118 +- .../modules/export-from-default.result.js | 188 +- .../export-from-named-as-default.result.js | 216 +- .../export-from-named-as-specifier.result.js | 216 +- .../export-from-named-as-specifiers.result.js | 282 +- .../modules/export-from-specifier.result.js | 188 +- .../modules/export-from-specifiers.result.js | 254 +- .../modules/export-function.result.js | 184 +- .../modules/export-named-as-default.result.js | 186 +- .../export-named-as-specifier.result.js | 186 +- .../export-named-as-specifiers.result.js | 252 +- .../modules/export-named-empty.result.js | 84 +- .../modules/export-named-specifier.result.js | 158 +- .../export-named-specifiers-comma.result.js | 234 +- .../modules/export-named-specifiers.result.js | 224 +- .../export-var-anonymous-function.result.js | 270 +- .../modules/export-var-number.result.js | 200 +- .../modules/export-var.result.js | 170 +- ...ort-default-and-named-specifiers.result.js | 242 +- ...default-and-namespace-specifiers.result.js | 230 +- .../modules/import-default-as.result.js | 216 +- .../modules/import-default.result.js | 156 +- .../modules/import-jquery.result.js | 146 +- .../modules/import-module.result.js | 98 +- .../import-named-as-specifier.result.js | 216 +- .../import-named-as-specifiers.result.js | 282 +- .../modules/import-named-empty.result.js | 128 +- .../modules/import-named-specifier.result.js | 188 +- .../import-named-specifiers-comma.result.js | 264 +- .../modules/import-named-specifiers.result.js | 254 +- .../import-namespace-specifier.result.js | 176 +- .../modules/import-null-as-nil.result.js | 206 +- .../modules/invalid-await.result.js | 2 +- .../modules/invalid-class.result.js | 2 +- ...export-batch-missing-from-clause.result.js | 8 +- .../invalid-export-batch-token.result.js | 6 +- .../invalid-export-default-equal.result.js | 2 +- .../invalid-export-default-token.result.js | 6 +- .../modules/invalid-export-default.result.js | 6 +- .../invalid-export-named-default.result.js | 6 +- ...invalid-export-named-extra-comma.result.js | 2 +- ...nvalid-export-named-middle-comma.result.js | 2 +- ...efault-after-named-after-default.result.js | 2 +- ...valid-import-default-after-named.result.js | 2 +- ...default-missing-module-specifier.result.js | 8 +- ...-import-default-module-specifier.result.js | 2 +- .../modules/invalid-import-default.result.js | 6 +- ...-import-missing-module-specifier.result.js | 8 +- .../invalid-import-module-specifier.result.js | 2 +- ...invalid-import-named-after-named.result.js | 2 +- ...lid-import-named-after-namespace.result.js | 2 +- ...lid-import-named-as-missing-from.result.js | 8 +- ...invalid-import-named-extra-comma.result.js | 2 +- ...nvalid-import-named-middle-comma.result.js | 2 +- ...lid-import-namespace-after-named.result.js | 2 +- ...alid-import-namespace-missing-as.result.js | 6 +- .../newTarget/invalid-new-target.result.js | 6 +- .../invalid-unknown-property.result.js | 2 +- .../newTarget/simple-new-target.result.js | 348 +- .../computed-addition-property.result.js | 362 +- .../computed-and-identifier.result.js | 342 +- .../computed-getter-and-setter.result.js | 502 +- .../computed-string-property.result.js | 300 +- .../computed-variable-property.result.js | 298 +- ...valid-computed-variable-property.result.js | 2 +- ...alone-computed-variable-property.result.js | 2 +- ...ndalone-expression-with-addition.result.js | 312 +- ...tandalone-expression-with-method.result.js | 316 +- .../standalone-expression.result.js | 248 +- .../proto-property.result.js | 6 +- .../proto-string-property.result.js | 6 +- .../strict-duplicate-properties.result.js | 434 +- ...rict-duplicate-string-properties.result.js | 438 +- .../invalid-method-no-braces.result.js | 2 +- .../method-property.result.js | 416 +- .../simple-method-named-get.result.js | 336 +- .../simple-method-named-set.result.js | 336 +- .../simple-method-with-argument.result.js | 358 +- .../simple-method-with-string-name.result.js | 338 +- .../simple-method.result.js | 336 +- .../string-name-method-property.result.js | 418 +- .../shorthand-properties.result.js | 602 +- .../octalLiterals/invalid.result.js | 2 +- .../octalLiterals/lowercase.result.js | 88 +- .../octalLiterals/strict-uppercase.result.js | 146 +- .../octalLiterals/uppercase.result.js | 88 +- .../regex-u-extended-escape.result.js | 172 +- .../regex-u-invalid-extended-escape.result.js | 6 +- .../regexUFlag/regex-u-simple.result.js | 172 +- .../regexYFlag/regexp-y-simple.result.js | 172 +- .../restParams/basic-rest.result.js | 252 +- .../restParams/error-no-default.result.js | 2 +- .../restParams/error-not-last.result.js | 2 +- .../func-expression-multi.result.js | 320 +- .../restParams/func-expression.result.js | 288 +- .../restParams/invalid-rest-param.result.js | 2 +- .../restParams/single-rest.result.js | 220 +- .../spread/error-invalid-if.result.js | 6 +- .../spread/error-invalid-sequence.result.js | 6 +- .../spread/multi-function-call.result.js | 228 +- .../spread/not-final-param.result.js | 228 +- .../spread/simple-function-call.result.js | 196 +- .../invalid-super-global-call.result.js | 6 - .../invalid-super-global-call.src.js | 1 - ...-function-call-in-object-literal.result.js | 533 -- ...per-function-call-in-object-literal.src.js | 6 - .../super-function-call.result.js | 346 - .../super-function-call.src.js | 3 - ...-property-call-in-object-literal.result.js | 605 -- ...per-property-call-in-object-literal.src.js | 6 - .../super-property-call.result.js | 418 -- .../super-property-call.src.js | 3 - .../templateStrings/deeply-nested.result.js | 464 +- .../escape-characters.result.js | 200 +- .../templateStrings/expressions.result.js | 586 +- .../multi-line-template-string.result.js | 128 +- .../templateStrings/octal-literal.result.js | 6 +- .../simple-template-string.result.js | 128 +- .../single-dollar-sign.result.js | 200 +- .../tagged-no-placeholders.result.js | 178 +- .../tagged-template-string.result.js | 636 +- .../basic-string-literal.result.js | 88 +- .../complex-string-literal.result.js | 88 +- .../invalid-empty-escape.result.js | 2 +- .../invalid-too-large-escape.result.js | 6 +- tests/lib/attach-comments.js | 6 +- tests/lib/ecma-features.js | 45 +- tests/lib/tokenize.js | 50 +- tools/update-tests.js | 38 +- 382 files changed, 36246 insertions(+), 45375 deletions(-) delete mode 100644 lib/ast-node-factory.js delete mode 100644 lib/messages.js delete mode 100644 lib/string-map.js delete mode 100644 lib/syntax.js create mode 100644 lib/token-translator.js delete mode 100644 lib/xhtml-entities.js delete mode 100644 tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.result.js rename tests/fixtures/ecma-features-mix/destructuring-and-spread/{complex-destructured-spread-first.config.js => destructuring-param.config.js} (100%) create mode 100644 tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.result.js rename tests/fixtures/ecma-features-mix/destructuring-and-spread/{error-destructuring-param.src.js => destructuring-param.src.js} (100%) rename tests/fixtures/ecma-features-mix/destructuring-and-spread/{error-destructuring-param.config.js => error-complex-destructured-spread-first.config.js} (100%) create mode 100644 tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.result.js rename tests/fixtures/ecma-features-mix/destructuring-and-spread/{complex-destructured-spread-first.src.js => error-complex-destructured-spread-first.src.js} (100%) delete mode 100644 tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.result.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.config.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.result.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.src.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.config.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.result.js delete mode 100644 tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.src.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.result.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.src.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.result.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.src.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-function-call.result.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-function-call.src.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.result.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.src.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-property-call.result.js delete mode 100644 tests/fixtures/ecma-features/superInFunctions/super-property-call.src.js diff --git a/.eslintrc b/.eslintrc index e500b04e..57a7ad7f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,20 +1,4 @@ env: node: true -rules: - brace-style: [2, "1tbs"] - comma-style: [2, "last"] - default-case: 2 - func-style: [2, "declaration"] - guard-for-in: 2 - no-floating-decimal: 2 - no-nested-ternary: 2 - no-undefined: 2 - no-console: 2 - quotes: [2, "double"] - radix: 2 - space-after-keywords: [2, "always"] - space-before-blocks: 2 - spaced-line-comment: [2, "always", { exceptions: ["-"]}] - valid-jsdoc: [2, { prefer: { "return": "returns"}}] - wrap-iife: 2 +extends: eslint diff --git a/.gitignore b/.gitignore index 3f598f40..4b4cc07f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build coverage node_modules npm-debug.log +_test.js + diff --git a/.travis.yml b/.travis.yml index b8a102b3..c943be51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ sudo: false node_js: - "0.10" - "0.12" + - 4 after_success: - npm run coveralls diff --git a/README.md b/README.md index f8a5eec1..15d73f73 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,6 @@ # Espree -Espree is an actively-maintained fork Esprima, a high performance, -standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) -parser written in ECMAScript (also popularly known as -[JavaScript](http://en.wikipedia.org/wiki/JavaScript)). - -## Features - -- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm)) -- Implements [ESTree](https://github.com/estree/estree) (both ES5 and ES6 specs) as the AST format. -- Optional tracking of syntax node location (index-based and line-column) -- Heavily tested and battle-hardened by inclusion in [ESLint](http://eslint.org) +Espree started out as a fork of [Esprima](http://esprima.org) v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree is now built on top of [Acorn](https://github.com/ternjs/acorn), which has a modular architecture that allows extension of core functionality. The goal of Espree is to produce output that is similar to Esprima with a similar API so that it can be used in place of Esprima. ## Usage @@ -113,14 +103,11 @@ var ast = espree.parse(code, { // enable parsing spread operator spread: true, - // enable super in functions - superInFunctions: true, - // enable parsing classes classes: true, // enable parsing of new.target - newTarget: false, + newTarget: true, // enable parsing of modules modules: true, @@ -137,30 +124,12 @@ var ast = espree.parse(code, { }); ``` -## Plans - -Espree starts as a fork of Esprima v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree's first version is therefore v1.2.2 and is 100% compatible with Esprima v1.2.2 as a drop-in replacement. The version number will be incremented based on [semantic versioning](http://semver.org/) as features and bug fixes are added. - -The immediate plans are: - -1. Move away from giant files and move towards small, modular files that are easier to manage. -1. Move towards CommonJS for all files and use browserify to create browser bundles. -1. Support ECMAScript version filtering, allowing users to specify which version the parser should work in (similar to Acorn's `ecmaVersion` property). -1. Add tests to track comment attachment. -1. Add well-thought-out features that are useful for tools developers. -1. Add full support for ECMAScript 6. -1. Add optional parsing of JSX. - ## Esprima Compatibility Going Forward -The primary goal is to produce the exact same AST structure as Esprima and Acorn, and that takes precedence over anything else. (The AST structure being the ESTree API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same. +The primary goal is to produce the exact same AST structure and tokens as Esprima, and that takes precedence over anything else. (The AST structure being the [ESTree](https://github.com/estree/estree) API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same. Espree may also deviate from Esprima in the interface it exposes. -## Frequent and Incremental Releases - -Espree will not do giant releases. Releases will happen periodically as changes are made and incremental releases will be made towards larger goals. For instance, we will not have one big release for ECMAScript 6 support. Instead, we will implement ECMAScript 6, piece-by-piece, hiding those pieces behind an `ecmaFeatures` property that allows you to opt-in to use those features. - ## Contributing Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/espree/issues). @@ -173,48 +142,50 @@ Espree is licensed under a permissive BSD 2-clause license. * `npm run lint` - run all linting * `npm run browserify` - creates a version of Espree that is usable in a browser +## Differences from Espree 1.x + +* The `tokenize()` method does not use `ecmaFeatures`. Any string will be tokenized completely based on ECMAScript 6 semantics. +* Trailing whitespace no longer is counted as part of a node. +* `let` and `const` declarations are no longer parsed by default. You must opt-in using `ecmaFeatures.blockBindings`. + + ## Known Incompatibilities In an effort to help those wanting to transition from other parsers to Espree, the following is a list of noteworthy incompatibilities with other parsers. These are known differences that we do not intend to change. ### Esprima 1.2.2 -* None. - -### Esprima/Harmony Branch +* Esprima counts trailing whitespace as part of each AST node while Espree does not. In Espree, the end of a node is where the last token occurs. +* Espree does not parse `let` and `const` declarations by default. -* Esprima/Harmony uses a different comment attachment algorithm that results in some comments being added in different places than Espree. The algorithm Espree uses is the same one used in Esprima 1.2.2. -* Espree uses ESTree format for the AST nodes whereas Esprima/Harmony uses a nonstandard format. +### Esprima 2.x -### Esprima-FB - -* All Esprima/Harmony incompatibilities. +* Esprima 2.x uses a different comment attachment algorithm that results in some comments being added in different places than Espree. The algorithm Espree uses is the same one used in Esprima 1.2.2. ## Frequently Asked Questions -### Why are you forking Esprima? +### Why another parser -[ESLint](http://eslint.org) has been relying on Esprima as its parser from the beginning. While that was fine when the JavaScript language was evolving slowly, the pace of development has increased dramatically and Esprima has fallen behind. ESLint, like many other tools reliant on Esprima, has been stuck in using new JavaScript language features until Esprima updates, and that has caused our users frustration. +[ESLint](http://eslint.org) had been relying on Esprima as its parser from the beginning. While that was fine when the JavaScript language was evolving slowly, the pace of development increased dramatically and Esprima had fallen behind. ESLint, like many other tools reliant on Esprima, has been stuck in using new JavaScript language features until Esprima updates, and that caused our users frustration. We decided the only way for us to move forward was to create our own parser, bringing us inline with JSHint and JSLint, and allowing us to keep implementing new features as we need them. We chose to fork Esprima instead of starting from scratch in order to move as quickly as possible with a compatible API. -### Have you tried working with Esprima? +With Espree 2.0.0, we are no longer a fork of Esprima but rather a translation layer between Acorn and Esprima syntax. This allows us to put work back into a community-supported parser (Acorn) that is continuing to grow and evolve while maintaining an Esprima-compatible parser for those utilities still built on Esprima. -Yes. Since the start of ESLint, we've regularly filed bugs and feature requests with Esprima. Unfortunately, we've been unable to make much progress towards getting our needs addressed. - -We are actively working with Esprima as part of its adoption by the jQuery Foundation. We are hoping to reconcile Espree with Esprima at some point in the future, but there are some different philosophies around how the projects work that need to be worked through. We're committed to a goal of merging Espree back into Esprima, or at the very least, to have Espree track Esprima as an upstream target so there's no duplication of effort. In the meantime, we will continue to update and maintain Espree. - -### Why don't you just use Facebook's Esprima fork? +### Have you tried working with Esprima? -`esprima-fb` is Facebook's Esprima fork that features JSX and Flow type annotations. We tried working with `esprima-fb` in our evaluation of how to support ECMAScript 6 and JSX in ESLint. Unfortunately, we were hampered by bugs that were part of Esprima (not necessarily Facebook's code). Since `esprima-fb` tracks the Esprima Harmony branch, that means we still were unable to get fixes or features we needed in a timely manner. +Yes. Since the start of ESLint, we've regularly filed bugs and feature requests with Esprima and will continue to do so. However, there are some different philosophies around how the projects work that need to be worked through. The initial goal was to have Espree track Esprima and eventually merge the two back together, but we ultimately decided that building on top of Acorn was a better choice due to Acorn's plugin support. ### Why don't you just use Acorn? Acorn is a great JavaScript parser that produces an AST that is compatible with Esprima. Unfortunately, ESLint relies on more than just the AST to do its job. It relies on Esprima's tokens and comment attachment features to get a complete picture of the source code. We investigated switching to Acorn, but the inconsistencies between Esprima and Acorn created too much work for a project like ESLint. -We expect there are other tools like ESLint that rely on more than just the AST produced by Esprima, and so a drop-in replacement will help those projects as well as ESLint. +We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better. ### What ECMAScript 6 features do you support? All of them. +### How do you determine which experimental features to support? + +In general, we do not support experimental JavaScript features. We may make exceptions from time to time depending on the maturity of the features. diff --git a/espree.js b/espree.js index a83286c3..5a8de7e9 100644 --- a/espree.js +++ b/espree.js @@ -1,5272 +1,472 @@ -/* -Copyright (C) 2015 Fred K. Schott -Copyright (C) 2013 Ariya Hidayat -Copyright (C) 2013 Thaddee Tyl -Copyright (C) 2013 Mathias Bynens -Copyright (C) 2012 Ariya Hidayat -Copyright (C) 2012 Mathias Bynens -Copyright (C) 2012 Joost-Wim Boekesteijn -Copyright (C) 2012 Kris Kowal -Copyright (C) 2012 Yusuke Suzuki -Copyright (C) 2012 Arpad Borsos -Copyright (C) 2011 Ariya Hidayat - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +/** + * @fileoverview Main Espree file that converts Acorn into Esprima output. + * Copyright 2015 Nicholas C. Zakas. All rights reserved. + * + * This file contains code from the following MIT-licensed projects: + * 1. Acorn + * 2. Babylon + * 3. Babel-ESLint + * + * This file also contains code from Esprima, which is BSD licensed. + * + * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS) + * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS) + * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*eslint no-undefined:0, no-use-before-define: 0*/ "use strict"; -var syntax = require("./lib/syntax"), - tokenInfo = require("./lib/token-info"), - astNodeTypes = require("./lib/ast-node-types"), - astNodeFactory = require("./lib/ast-node-factory"), +var astNodeTypes = require("./lib/ast-node-types"), + commentAttachment = require("./lib/comment-attachment"), defaultFeatures = require("./lib/features"), - Messages = require("./lib/messages"), - XHTMLEntities = require("./lib/xhtml-entities"), - StringMap = require("./lib/string-map"), - commentAttachment = require("./lib/comment-attachment"); - -var Token = tokenInfo.Token, - TokenName = tokenInfo.TokenName, - FnExprTokens = tokenInfo.FnExprTokens, - Regex = syntax.Regex, - PropertyKind, - source, - strict, - index, - lineNumber, - lineStart, - length, - lookahead, - state, - extra; - -PropertyKind = { - Data: 1, - Get: 2, - Set: 4 -}; - - -// Ensure the condition is true, otherwise throw an error. -// This is only to have a better contract semantic, i.e. another safety net -// to catch a logic error. The condition shall be fulfilled in normal case. -// Do NOT use this to enforce a certain condition on any user input. - -function assert(condition, message) { - /* istanbul ignore if */ - if (!condition) { - throw new Error("ASSERT: " + message); - } -} - -// 7.4 Comments - -function addComment(type, value, start, end, loc) { - var comment; - - assert(typeof start === "number", "Comment must have valid position"); - - // Because the way the actual token is scanned, often the comments - // (if any) are skipped twice during the lexical analysis. - // Thus, we need to skip adding a comment if the comment array already - // handled it. - if (state.lastCommentStart >= start) { - return; - } - state.lastCommentStart = start; - - comment = { - type: type, - value: value - }; - if (extra.range) { - comment.range = [start, end]; - } - if (extra.loc) { - comment.loc = loc; - } - extra.comments.push(comment); - - if (extra.attachComment) { - commentAttachment.addComment(comment); - } -} - -function skipSingleLineComment(offset) { - var start, loc, ch, comment; - - start = index - offset; - loc = { - start: { - line: lineNumber, - column: index - lineStart - offset - } - }; - - while (index < length) { - ch = source.charCodeAt(index); - ++index; - if (syntax.isLineTerminator(ch)) { - if (extra.comments) { - comment = source.slice(start + offset, index - 1); - loc.end = { - line: lineNumber, - column: index - lineStart - 1 - }; - addComment("Line", comment, start, index - 1, loc); - } - if (ch === 13 && source.charCodeAt(index) === 10) { - ++index; - } - ++lineNumber; - lineStart = index; - return; - } - } - - if (extra.comments) { - comment = source.slice(start + offset, index); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment("Line", comment, start, index, loc); - } -} - -function skipMultiLineComment() { - var start, loc, ch, comment; - - if (extra.comments) { - start = index - 2; - loc = { - start: { - line: lineNumber, - column: index - lineStart - 2 - } - }; - } - - while (index < length) { - ch = source.charCodeAt(index); - if (syntax.isLineTerminator(ch)) { - if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) { - ++index; - } - ++lineNumber; - ++index; - lineStart = index; - if (index >= length) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } else if (ch === 0x2A) { - // Block comment ends with "*/". - if (source.charCodeAt(index + 1) === 0x2F) { - ++index; - ++index; - if (extra.comments) { - comment = source.slice(start + 2, index - 2); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment("Block", comment, start, index, loc); - } - return; - } - ++index; - } else { - ++index; - } - } - - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); -} - -function skipComment() { - var ch, start; - - start = (index === 0); - while (index < length) { - ch = source.charCodeAt(index); - - if (syntax.isWhiteSpace(ch)) { - ++index; - } else if (syntax.isLineTerminator(ch)) { - ++index; - if (ch === 0x0D && source.charCodeAt(index) === 0x0A) { - ++index; - } - ++lineNumber; - lineStart = index; - start = true; - } else if (ch === 0x2F) { // U+002F is "/" - ch = source.charCodeAt(index + 1); - if (ch === 0x2F) { - ++index; - ++index; - skipSingleLineComment(2); - start = true; - } else if (ch === 0x2A) { // U+002A is "*" - ++index; - ++index; - skipMultiLineComment(); - } else { - break; - } - } else if (start && ch === 0x2D) { // U+002D is "-" - // U+003E is ">" - if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) { - // "-->" is a single-line comment - index += 3; - skipSingleLineComment(3); - } else { - break; - } - } else if (ch === 0x3C) { // U+003C is "<" - if (source.slice(index + 1, index + 4) === "!--") { - ++index; // `<` - ++index; // `!` - ++index; // `-` - ++index; // `-` - skipSingleLineComment(4); - } else { - break; - } - } else { - break; - } - } -} - -function scanHexEscape(prefix) { - var i, len, ch, code = 0; - - len = (prefix === "u") ? 4 : 2; - for (i = 0; i < len; ++i) { - if (index < length && syntax.isHexDigit(source[index])) { - ch = source[index++]; - code = code * 16 + "0123456789abcdef".indexOf(ch.toLowerCase()); - } else { - return ""; - } - } - return String.fromCharCode(code); -} - -/** - * Scans an extended unicode code point escape sequence from source. Throws an - * error if the sequence is empty or if the code point value is too large. - * @returns {string} The string created by the Unicode escape sequence. - * @private - */ -function scanUnicodeCodePointEscape() { - var ch, code, cu1, cu2; - - ch = source[index]; - code = 0; - - // At least one hex digit is required. - if (ch === "}") { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - while (index < length) { - ch = source[index++]; - if (!syntax.isHexDigit(ch)) { - break; - } - code = code * 16 + "0123456789abcdef".indexOf(ch.toLowerCase()); - } - - if (code > 0x10FFFF || ch !== "}") { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - // UTF-16 Encoding - if (code <= 0xFFFF) { - return String.fromCharCode(code); - } - cu1 = ((code - 0x10000) >> 10) + 0xD800; - cu2 = ((code - 0x10000) & 1023) + 0xDC00; - return String.fromCharCode(cu1, cu2); -} - -function getEscapedIdentifier() { - var ch, id; - - ch = source.charCodeAt(index++); - id = String.fromCharCode(ch); - - // "\u" (U+005C, U+0075) denotes an escaped character. - if (ch === 0x5C) { - if (source.charCodeAt(index) !== 0x75) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - ++index; - ch = scanHexEscape("u"); - if (!ch || ch === "\\" || !syntax.isIdentifierStart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - id = ch; - } - - while (index < length) { - ch = source.charCodeAt(index); - if (!syntax.isIdentifierPart(ch)) { - break; - } - ++index; - id += String.fromCharCode(ch); - - // "\u" (U+005C, U+0075) denotes an escaped character. - if (ch === 0x5C) { - id = id.substr(0, id.length - 1); - if (source.charCodeAt(index) !== 0x75) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - ++index; - ch = scanHexEscape("u"); - if (!ch || ch === "\\" || !syntax.isIdentifierPart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - id += ch; - } - } - - return id; -} - -function getIdentifier() { - var start, ch; - - start = index++; - while (index < length) { - ch = source.charCodeAt(index); - if (ch === 0x5C) { - // Blackslash (U+005C) marks Unicode escape sequence. - index = start; - return getEscapedIdentifier(); - } - if (syntax.isIdentifierPart(ch)) { - ++index; - } else { - break; - } - } - - return source.slice(start, index); -} - -function scanIdentifier() { - var start, id, type; - - start = index; - - // Backslash (U+005C) starts an escaped character. - id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier(); - - // There is no keyword or literal with only one character. - // Thus, it must be an identifier. - if (id.length === 1) { - type = Token.Identifier; - } else if (syntax.isKeyword(id, strict, extra.ecmaFeatures)) { - type = Token.Keyword; - } else if (id === "null") { - type = Token.NullLiteral; - } else if (id === "true" || id === "false") { - type = Token.BooleanLiteral; - } else { - type = Token.Identifier; - } - - return { - type: type, - value: id, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - - -// 7.7 Punctuators - -function scanPunctuator() { - var start = index, - code = source.charCodeAt(index), - code2, - ch1 = source[index], - ch2, - ch3, - ch4; - - switch (code) { - // Check for most common single-character punctuators. - case 40: // ( open bracket - case 41: // ) close bracket - case 59: // ; semicolon - case 44: // , comma - case 91: // [ - case 93: // ] - case 58: // : - case 63: // ? - case 126: // ~ - ++index; - - if (extra.tokenize && code === 40) { - extra.openParenToken = extra.tokens.length; - } - - return { - type: Token.Punctuator, - value: String.fromCharCode(code), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - - case 123: // { open curly brace - case 125: // } close curly brace - ++index; - - if (extra.tokenize && code === 123) { - extra.openCurlyToken = extra.tokens.length; - } - - // lookahead2 function can cause tokens to be scanned twice and in doing so - // would wreck the curly stack by pushing the same token onto the stack twice. - // curlyLastIndex ensures each token is pushed or popped exactly once - if (index > state.curlyLastIndex) { - state.curlyLastIndex = index; - if (code === 123) { - state.curlyStack.push("{"); - } else { - state.curlyStack.pop(); - } - } - - return { - type: Token.Punctuator, - value: String.fromCharCode(code), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - - default: - code2 = source.charCodeAt(index + 1); - - // "=" (char #61) marks an assignment or comparison operator. - if (code2 === 61) { - switch (code) { - case 37: // % - case 38: // & - case 42: // *: - case 43: // + - case 45: // - - case 47: // / - case 60: // < - case 62: // > - case 94: // ^ - case 124: // | - index += 2; - return { - type: Token.Punctuator, - value: String.fromCharCode(code) + String.fromCharCode(code2), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - - case 33: // ! - case 61: // = - index += 2; - - // !== and === - if (source.charCodeAt(index) === 61) { - ++index; - } - return { - type: Token.Punctuator, - value: source.slice(start, index), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - default: - break; - } - } - break; - } - - // Peek more characters. - - ch2 = source[index + 1]; - ch3 = source[index + 2]; - ch4 = source[index + 3]; - - // 4-character punctuator: >>>= - - if (ch1 === ">" && ch2 === ">" && ch3 === ">") { - if (ch4 === "=") { - index += 4; - return { - type: Token.Punctuator, - value: ">>>=", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - } - - // 3-character punctuators: === !== >>> <<= >>= - - if (ch1 === ">" && ch2 === ">" && ch3 === ">") { - index += 3; - return { - type: Token.Punctuator, - value: ">>>", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === "<" && ch2 === "<" && ch3 === "=") { - index += 3; - return { - type: Token.Punctuator, - value: "<<=", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === ">" && ch2 === ">" && ch3 === "=") { - index += 3; - return { - type: Token.Punctuator, - value: ">>=", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - // The ... operator (spread, restParams, JSX, etc.) - if (extra.ecmaFeatures.spread || - extra.ecmaFeatures.restParams || - extra.ecmaFeatures.experimentalObjectRestSpread || - (extra.ecmaFeatures.jsx && state.inJSXSpreadAttribute) - ) { - if (ch1 === "." && ch2 === "." && ch3 === ".") { - index += 3; - return { - type: Token.Punctuator, - value: "...", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - } - - // Other 2-character punctuators: ++ -- << >> && || - if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) { - index += 2; - return { - type: Token.Punctuator, - value: ch1 + ch2, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - // the => for arrow functions - if (extra.ecmaFeatures.arrowFunctions) { - if (ch1 === "=" && ch2 === ">") { - index += 2; - return { - type: Token.Punctuator, - value: "=>", - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - } - - if ("<>=!+-*%&|^/".indexOf(ch1) >= 0) { - ++index; - return { - type: Token.Punctuator, - value: ch1, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === ".") { - ++index; - return { - type: Token.Punctuator, - value: ch1, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); -} - -// 7.8.3 Numeric Literals - -function scanHexLiteral(start) { - var number = ""; - - while (index < length) { - if (!syntax.isHexDigit(source[index])) { - break; - } - number += source[index++]; - } - - if (number.length === 0) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - if (syntax.isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - return { - type: Token.NumericLiteral, - value: parseInt("0x" + number, 16), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function scanBinaryLiteral(start) { - var ch, number = ""; - - while (index < length) { - ch = source[index]; - if (ch !== "0" && ch !== "1") { - break; - } - number += source[index++]; - } - - if (number.length === 0) { - // only 0b or 0B - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - - if (index < length) { - ch = source.charCodeAt(index); - /* istanbul ignore else */ - if (syntax.isIdentifierStart(ch) || syntax.isDecimalDigit(ch)) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } - - return { - type: Token.NumericLiteral, - value: parseInt(number, 2), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function scanOctalLiteral(prefix, start) { - var number, octal; - - if (syntax.isOctalDigit(prefix)) { - octal = true; - number = "0" + source[index++]; - } else { - octal = false; - ++index; - number = ""; - } - - while (index < length) { - if (!syntax.isOctalDigit(source[index])) { - break; - } - number += source[index++]; - } - - if (!octal && number.length === 0) { - // only 0o or 0O - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - if (syntax.isIdentifierStart(source.charCodeAt(index)) || syntax.isDecimalDigit(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - return { - type: Token.NumericLiteral, - value: parseInt(number, 8), - octal: octal, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function scanNumericLiteral() { - var number, start, ch; - - ch = source[index]; - assert(syntax.isDecimalDigit(ch.charCodeAt(0)) || (ch === "."), - "Numeric literal must start with a decimal digit or a decimal point"); - - start = index; - number = ""; - if (ch !== ".") { - number = source[index++]; - ch = source[index]; - - // Hex number starts with "0x". - // Octal number starts with "0". - if (number === "0") { - if (ch === "x" || ch === "X") { - ++index; - return scanHexLiteral(start); - } - - // Binary number in ES6 starts with '0b' - if (extra.ecmaFeatures.binaryLiterals) { - if (ch === "b" || ch === "B") { - ++index; - return scanBinaryLiteral(start); - } - } - - if ((extra.ecmaFeatures.octalLiterals && (ch === "o" || ch === "O")) || syntax.isOctalDigit(ch)) { - return scanOctalLiteral(ch, start); - } - - // decimal number starts with "0" such as "09" is illegal. - if (ch && syntax.isDecimalDigit(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } - - while (syntax.isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; - } - - if (ch === ".") { - number += source[index++]; - while (syntax.isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; - } - - if (ch === "e" || ch === "E") { - number += source[index++]; - - ch = source[index]; - if (ch === "+" || ch === "-") { - number += source[index++]; - } - if (syntax.isDecimalDigit(source.charCodeAt(index))) { - while (syntax.isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - } else { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } - - if (syntax.isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - return { - type: Token.NumericLiteral, - value: parseFloat(number), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -/** - * Scan a string escape sequence and return its special character. - * @param {string} ch The starting character of the given sequence. - * @returns {Object} An object containing the character and a flag - * if the escape sequence was an octal. - * @private - */ -function scanEscapeSequence(ch) { - var code, - unescaped, - restore, - escapedCh, - octal = false; - - // An escape sequence cannot be empty - if (!ch) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - if (syntax.isLineTerminator(ch.charCodeAt(0))) { - ++lineNumber; - if (ch === "\r" && source[index] === "\n") { - ++index; - } - lineStart = index; - escapedCh = ""; - } else if (ch === "u" && source[index] === "{") { - // Handle ES6 extended unicode code point escape sequences. - if (extra.ecmaFeatures.unicodeCodePointEscapes) { - ++index; - escapedCh = scanUnicodeCodePointEscape(); - } else { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } else if (ch === "u" || ch === "x") { - // Handle other unicode and hex codes normally - restore = index; - unescaped = scanHexEscape(ch); - if (unescaped) { - escapedCh = unescaped; - } else { - index = restore; - escapedCh = ch; - } - } else if (ch === "n") { - escapedCh = "\n"; - } else if (ch === "r") { - escapedCh = "\r"; - } else if (ch === "t") { - escapedCh = "\t"; - } else if (ch === "b") { - escapedCh = "\b"; - } else if (ch === "f") { - escapedCh = "\f"; - } else if (ch === "v") { - escapedCh = "\v"; - } else if (syntax.isOctalDigit(ch)) { - code = "01234567".indexOf(ch); - - // \0 is not octal escape sequence - if (code !== 0) { - octal = true; - } - - if (index < length && syntax.isOctalDigit(source[index])) { - octal = true; - code = code * 8 + "01234567".indexOf(source[index++]); + astNodeTypes = require("./lib/ast-node-types"), + TokenTranslator = require("./lib/token-translator"), + syntax = require("./lib/syntax"), + acornJSX = require("acorn-jsx/inject"), + acorn = acornJSX(require("acorn")); - // 3 digits are only allowed when string starts with 0, 1, 2, 3 - if ("0123".indexOf(ch) >= 0 && - index < length && - syntax.isOctalDigit(source[index])) { - code = code * 8 + "01234567".indexOf(source[index++]); - } - } - escapedCh = String.fromCharCode(code); - } else { - escapedCh = ch; - } +var lookahead, + extra, + lastToken; - return { - ch: escapedCh, - octal: octal +function resetExtra() { + extra = { + tokens: null, + range: false, + loc: false, + comment: false, + comments: [], + tolerant: false, + errors: [], + strict: false, + ecmaFeatures: {} }; -} - -function scanStringLiteral() { - var str = "", - ch, - escapedSequence, - octal = false, - start = index, - startLineNumber = lineNumber, - startLineStart = lineStart, - quote = source[index]; - - assert((quote === "'" || quote === "\""), - "String literal must starts with a quote"); - - ++index; - - while (index < length) { - ch = source[index++]; - - if (syntax.isLineTerminator(ch.charCodeAt(0))) { - break; - } else if (ch === quote) { - quote = ""; - break; - } else if (ch === "\\") { - ch = source[index++]; - escapedSequence = scanEscapeSequence(ch); - str += escapedSequence.ch; - octal = escapedSequence.octal || octal; - } else { - str += ch; - } - } - - if (quote !== "") { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - return { - type: Token.StringLiteral, - value: str, - octal: octal, - startLineNumber: startLineNumber, - startLineStart: startLineStart, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -/** - * Scan a template string and return a token. This scans both the first and - * subsequent pieces of a template string and assumes that the first backtick - * or the closing } have already been scanned. - * @returns {Token} The template string token. - * @private - */ -function scanTemplate() { - var cooked = "", - ch, - escapedSequence, - start = index, - terminated = false, - tail = false, - head = (source[index] === "`"); - - ++index; - - while (index < length) { - ch = source[index++]; - - if (ch === "`") { - tail = true; - terminated = true; - break; - } else if (ch === "$") { - if (source[index] === "{") { - ++index; - terminated = true; - break; - } - cooked += ch; - } else if (ch === "\\") { - ch = source[index++]; - escapedSequence = scanEscapeSequence(ch); - - if (escapedSequence.octal) { - throwError({}, Messages.TemplateOctalLiteral); - } - - cooked += escapedSequence.ch; - - } else if (syntax.isLineTerminator(ch.charCodeAt(0))) { - ++lineNumber; - if (ch === "\r" && source[index] === "\n") { - ++index; - } - lineStart = index; - cooked += "\n"; - } else { - cooked += ch; - } - } - - if (!terminated) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - if (index > state.curlyLastIndex) { - state.curlyLastIndex = index; - - if (!tail) { - state.curlyStack.push("template"); - } - - if (!head) { - state.curlyStack.pop(); - } - } - - return { - type: Token.Template, - value: { - cooked: cooked, - raw: source.slice(start + 1, index - ((tail) ? 1 : 2)) - }, - head: head, - tail: tail, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function testRegExp(pattern, flags) { - var tmp = pattern, - validFlags = "gmsi"; - - if (extra.ecmaFeatures.regexYFlag) { - validFlags += "y"; - } - - if (extra.ecmaFeatures.regexUFlag) { - validFlags += "u"; - } - - if (!RegExp("^[" + validFlags + "]*$").test(flags)) { - throwError({}, Messages.InvalidRegExpFlag); - } - - - if (flags.indexOf("u") >= 0) { - // Replace each astral symbol and every Unicode code point - // escape sequence with a single ASCII symbol to avoid throwing on - // regular expressions that are only valid in combination with the - // `/u` flag. - // Note: replacing with the ASCII symbol `x` might cause false - // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a - // perfectly valid pattern that is equivalent to `[a-b]`, but it - // would be replaced by `[x-b]` which throws an error. - tmp = tmp - .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) { - if (parseInt($1, 16) <= 0x10FFFF) { - return "x"; - } - throwError({}, Messages.InvalidRegExp); - }) - .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x"); - } - - // First, detect invalid regular expressions. - try { - RegExp(tmp); - } catch (e) { - throwError({}, Messages.InvalidRegExp); - } - - // Return a regular expression object for this pattern-flag pair, or - // `null` in case the current environment doesn't support the flags it - // uses. - try { - return new RegExp(pattern, flags); - } catch (exception) { - return null; - } -} - -function scanRegExpBody() { - var ch, str, classMarker, terminated, body; - - ch = source[index]; - assert(ch === "/", "Regular expression literal must start with a slash"); - str = source[index++]; - - classMarker = false; - terminated = false; - while (index < length) { - ch = source[index++]; - str += ch; - if (ch === "\\") { - ch = source[index++]; - // ECMA-262 7.8.5 - if (syntax.isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } - str += ch; - } else if (syntax.isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } else if (classMarker) { - if (ch === "]") { - classMarker = false; - } - } else { - if (ch === "/") { - terminated = true; - break; - } else if (ch === "[") { - classMarker = true; - } - } - } - - if (!terminated) { - throwError({}, Messages.UnterminatedRegExp); - } - - // Exclude leading and trailing slash. - body = str.substr(1, str.length - 2); - return { - value: body, - literal: str - }; -} - -function scanRegExpFlags() { - var ch, str, flags, restore; - - str = ""; - flags = ""; - while (index < length) { - ch = source[index]; - if (!syntax.isIdentifierPart(ch.charCodeAt(0))) { - break; - } - - ++index; - if (ch === "\\" && index < length) { - ch = source[index]; - if (ch === "u") { - ++index; - restore = index; - ch = scanHexEscape("u"); - if (ch) { - flags += ch; - for (str += "\\u"; restore < index; ++restore) { - str += source[restore]; - } - } else { - index = restore; - flags += "u"; - str += "\\u"; - } - throwErrorTolerant({}, Messages.UnexpectedToken, "ILLEGAL"); - } else { - str += "\\"; - throwErrorTolerant({}, Messages.UnexpectedToken, "ILLEGAL"); - } - } else { - flags += ch; - str += ch; - } - } - - return { - value: flags, - literal: str - }; -} - -function scanRegExp() { - var start, body, flags, value; - - lookahead = null; - skipComment(); - start = index; - - body = scanRegExpBody(); - flags = scanRegExpFlags(); - value = testRegExp(body.value, flags.value); - - if (extra.tokenize) { - return { - type: Token.RegularExpression, - value: value, - regex: { - pattern: body.value, - flags: flags.value - }, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - return { - literal: body.literal + flags.literal, - value: value, - regex: { - pattern: body.value, - flags: flags.value - }, - range: [start, index] - }; -} - -function collectRegex() { - var pos, loc, regex, token; - - skipComment(); - - pos = index; - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; - - regex = scanRegExp(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - - /* istanbul ignore next */ - if (!extra.tokenize) { - // Pop the previous token, which is likely "/" or "/=" - if (extra.tokens.length > 0) { - token = extra.tokens[extra.tokens.length - 1]; - if (token.range[0] === pos && token.type === "Punctuator") { - if (token.value === "/" || token.value === "/=") { - extra.tokens.pop(); - } - } - } - - extra.tokens.push({ - type: "RegularExpression", - value: regex.literal, - regex: regex.regex, - range: [pos, index], - loc: loc - }); - } - - return regex; -} - -function isIdentifierName(token) { - return token.type === Token.Identifier || - token.type === Token.Keyword || - token.type === Token.BooleanLiteral || - token.type === Token.NullLiteral; -} - -function advanceSlash() { - var prevToken, - checkToken; - // Using the following algorithm: - // https://github.com/mozilla/sweet.js/wiki/design - prevToken = extra.tokens[extra.tokens.length - 1]; - if (!prevToken) { - // Nothing before that: it cannot be a division. - return collectRegex(); - } - if (prevToken.type === "Punctuator") { - if (prevToken.value === "]") { - return scanPunctuator(); - } - if (prevToken.value === ")") { - checkToken = extra.tokens[extra.openParenToken - 1]; - if (checkToken && - checkToken.type === "Keyword" && - (checkToken.value === "if" || - checkToken.value === "while" || - checkToken.value === "for" || - checkToken.value === "with")) { - return collectRegex(); - } - return scanPunctuator(); - } - if (prevToken.value === "}") { - // Dividing a function by anything makes little sense, - // but we have to check for that. - if (extra.tokens[extra.openCurlyToken - 3] && - extra.tokens[extra.openCurlyToken - 3].type === "Keyword") { - // Anonymous function. - checkToken = extra.tokens[extra.openCurlyToken - 4]; - if (!checkToken) { - return scanPunctuator(); - } - } else if (extra.tokens[extra.openCurlyToken - 4] && - extra.tokens[extra.openCurlyToken - 4].type === "Keyword") { - // Named function. - checkToken = extra.tokens[extra.openCurlyToken - 5]; - if (!checkToken) { - return collectRegex(); - } - } else { - return scanPunctuator(); - } - // checkToken determines whether the function is - // a declaration or an expression. - if (FnExprTokens.indexOf(checkToken.value) >= 0) { - // It is an expression. - return scanPunctuator(); - } - // It is a declaration. - return collectRegex(); - } - return collectRegex(); - } - if (prevToken.type === "Keyword") { - return collectRegex(); - } - return scanPunctuator(); -} - -function advance() { - var ch, - allowJSX = extra.ecmaFeatures.jsx, - allowTemplateStrings = extra.ecmaFeatures.templateStrings; - - /* - * If JSX isn't allowed or JSX is allowed and we're not inside an JSX child, - * then skip any comments. - */ - if (!allowJSX || !state.inJSXChild) { - skipComment(); - } - - if (index >= length) { - return { - type: Token.EOF, - lineNumber: lineNumber, - lineStart: lineStart, - range: [index, index] - }; - } - - // if inside an JSX child, then abort regular tokenization - if (allowJSX && state.inJSXChild) { - return advanceJSXChild(); - } - - ch = source.charCodeAt(index); - - // Very common: ( and ) and ; - if (ch === 0x28 || ch === 0x29 || ch === 0x3B) { - return scanPunctuator(); - } - - // String literal starts with single quote (U+0027) or double quote (U+0022). - if (ch === 0x27 || ch === 0x22) { - if (allowJSX && state.inJSXTag) { - return scanJSXStringLiteral(); - } - - return scanStringLiteral(); - } - - if (allowJSX && state.inJSXTag && syntax.isJSXIdentifierStart(ch)) { - return scanJSXIdentifier(); - } - - // Template strings start with backtick (U+0096) or closing curly brace (125) and backtick. - if (allowTemplateStrings) { - - // template strings start with backtick (96) or open curly (125) but only if the open - // curly closes a previously opened curly from a template. - if (ch === 96 || (ch === 125 && state.curlyStack[state.curlyStack.length - 1] === "template")) { - return scanTemplate(); - } - } - - if (syntax.isIdentifierStart(ch)) { - return scanIdentifier(); - } - - // Dot (.) U+002E can also start a floating-point number, hence the need - // to check the next character. - if (ch === 0x2E) { - if (syntax.isDecimalDigit(source.charCodeAt(index + 1))) { - return scanNumericLiteral(); - } - return scanPunctuator(); - } - - if (syntax.isDecimalDigit(ch)) { - return scanNumericLiteral(); - } - - // Slash (/) U+002F can also start a regex. - if (extra.tokenize && ch === 0x2F) { - return advanceSlash(); - } - - return scanPunctuator(); -} - -function collectToken() { - var loc, token, range, value, entry, - allowJSX = extra.ecmaFeatures.jsx; - - /* istanbul ignore else */ - if (!allowJSX || !state.inJSXChild) { - skipComment(); - } - - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; - - token = advance(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - - if (token.type !== Token.EOF) { - range = [token.range[0], token.range[1]]; - value = source.slice(token.range[0], token.range[1]); - entry = { - type: TokenName[token.type], - value: value, - range: range, - loc: loc - }; - if (token.regex) { - entry.regex = { - pattern: token.regex.pattern, - flags: token.regex.flags - }; - } - extra.tokens.push(entry); - } - - return token; -} - -function lex() { - var token; - - token = lookahead; - index = token.range[1]; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - lookahead = (typeof extra.tokens !== "undefined") ? collectToken() : advance(); - - index = token.range[1]; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - return token; -} - -function peek() { - var pos, - line, - start; - - pos = index; - line = lineNumber; - start = lineStart; - - lookahead = (typeof extra.tokens !== "undefined") ? collectToken() : advance(); - - index = pos; - lineNumber = line; - lineStart = start; -} - -function lookahead2() { - var adv, pos, line, start, result; - - // If we are collecting the tokens, don't grab the next one yet. - /* istanbul ignore next */ - adv = (typeof extra.advance === "function") ? extra.advance : advance; - - pos = index; - line = lineNumber; - start = lineStart; - - // Scan for the next immediate token. - /* istanbul ignore if */ - if (lookahead === null) { - lookahead = adv(); - } - index = lookahead.range[1]; - lineNumber = lookahead.lineNumber; - lineStart = lookahead.lineStart; - - // Grab the token right after. - result = adv(); - index = pos; - lineNumber = line; - lineStart = start; - - return result; -} - - -//------------------------------------------------------------------------------ -// JSX -//------------------------------------------------------------------------------ - -function getQualifiedJSXName(object) { - if (object.type === astNodeTypes.JSXIdentifier) { - return object.name; - } - if (object.type === astNodeTypes.JSXNamespacedName) { - return object.namespace.name + ":" + object.name.name; - } - /* istanbul ignore else */ - if (object.type === astNodeTypes.JSXMemberExpression) { - return ( - getQualifiedJSXName(object.object) + "." + - getQualifiedJSXName(object.property) - ); - } - /* istanbul ignore next */ - throwUnexpected(object); -} - -function scanJSXIdentifier() { - var ch, start, value = ""; - - start = index; - while (index < length) { - ch = source.charCodeAt(index); - if (!syntax.isJSXIdentifierPart(ch)) { - break; - } - value += source[index++]; - } - - return { - type: Token.JSXIdentifier, - value: value, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function scanJSXEntity() { - var ch, str = "", start = index, count = 0, code; - ch = source[index]; - assert(ch === "&", "Entity must start with an ampersand"); - index++; - while (index < length && count++ < 10) { - ch = source[index++]; - if (ch === ";") { - break; - } - str += ch; - } - - // Well-formed entity (ending was found). - if (ch === ";") { - // Numeric entity. - if (str[0] === "#") { - if (str[1] === "x") { - code = +("0" + str.substr(1)); - } else { - // Removing leading zeros in order to avoid treating as octal in old browsers. - code = +str.substr(1).replace(Regex.LeadingZeros, ""); - } - - if (!isNaN(code)) { - return String.fromCharCode(code); - } - /* istanbul ignore else */ - } else if (XHTMLEntities[str]) { - return XHTMLEntities[str]; - } - } - - // Treat non-entity sequences as regular text. - index = start + 1; - return "&"; -} - -function scanJSXText(stopChars) { - var ch, str = "", start; - start = index; - while (index < length) { - ch = source[index]; - if (stopChars.indexOf(ch) !== -1) { - break; - } - if (ch === "&") { - str += scanJSXEntity(); - } else { - index++; - if (ch === "\r" && source[index] === "\n") { - str += ch; - ch = source[index]; - index++; - } - if (syntax.isLineTerminator(ch.charCodeAt(0))) { - ++lineNumber; - lineStart = index; - } - str += ch; - } - } - return { - type: Token.JSXText, - value: str, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; -} - -function scanJSXStringLiteral() { - var innerToken, quote, start; - - quote = source[index]; - assert((quote === "\"" || quote === "'"), - "String literal must starts with a quote"); - - start = index; - ++index; - - innerToken = scanJSXText([quote]); - - if (quote !== source[index]) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - ++index; - - innerToken.range = [start, index]; - - return innerToken; -} - -/* - * Between JSX opening and closing tags (e.g. HERE), anything that - * is not another JSX tag and is not an expression wrapped by {} is text. - */ -function advanceJSXChild() { - var ch = source.charCodeAt(index); - - // { (123) and < (60) - if (ch !== 123 && ch !== 60) { - return scanJSXText(["<", "{"]); - } - - return scanPunctuator(); -} - -function parseJSXIdentifier() { - var token, marker = markerCreate(); - - if (lookahead.type !== Token.JSXIdentifier) { - throwUnexpected(lookahead); - } - - token = lex(); - return markerApply(marker, astNodeFactory.createJSXIdentifier(token.value)); -} - -function parseJSXNamespacedName() { - var namespace, name, marker = markerCreate(); - - namespace = parseJSXIdentifier(); - expect(":"); - name = parseJSXIdentifier(); - - return markerApply(marker, astNodeFactory.createJSXNamespacedName(namespace, name)); -} - -function parseJSXMemberExpression() { - var marker = markerCreate(), - expr = parseJSXIdentifier(); - - while (match(".")) { - lex(); - expr = markerApply(marker, astNodeFactory.createJSXMemberExpression(expr, parseJSXIdentifier())); - } - - return expr; -} - -function parseJSXElementName() { - if (lookahead2().value === ":") { - return parseJSXNamespacedName(); - } - if (lookahead2().value === ".") { - return parseJSXMemberExpression(); - } - - return parseJSXIdentifier(); -} - -function parseJSXAttributeName() { - if (lookahead2().value === ":") { - return parseJSXNamespacedName(); - } - - return parseJSXIdentifier(); -} - -function parseJSXAttributeValue() { - var value, marker; - if (match("{")) { - value = parseJSXExpressionContainer(); - if (value.expression.type === astNodeTypes.JSXEmptyExpression) { - throwError( - value, - "JSX attributes must only be assigned a non-empty " + - "expression" - ); - } - } else if (match("<")) { - value = parseJSXElement(); - } else if (lookahead.type === Token.JSXText) { - marker = markerCreate(); - value = markerApply(marker, astNodeFactory.createLiteralFromSource(lex(), source)); - } else { - throwError({}, Messages.InvalidJSXAttributeValue); - } - return value; -} - -function parseJSXEmptyExpression() { - var marker = markerCreatePreserveWhitespace(); - while (source.charAt(index) !== "}") { - index++; - } - return markerApply(marker, astNodeFactory.createJSXEmptyExpression()); -} - -function parseJSXExpressionContainer() { - var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = false; - - expect("{"); - - if (match("}")) { - expression = parseJSXEmptyExpression(); - } else { - expression = parseExpression(); - } - - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - - expect("}"); - - return markerApply(marker, astNodeFactory.createJSXExpressionContainer(expression)); -} - -function parseJSXSpreadAttribute() { - var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = false; - state.inJSXSpreadAttribute = true; - - expect("{"); - expect("..."); - - state.inJSXSpreadAttribute = false; - - expression = parseAssignmentExpression(); - - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - - expect("}"); - - return markerApply(marker, astNodeFactory.createJSXSpreadAttribute(expression)); -} - -function parseJSXAttribute() { - var name, marker; - - if (match("{")) { - return parseJSXSpreadAttribute(); - } - - marker = markerCreate(); - - name = parseJSXAttributeName(); - - // HTML empty attribute - if (match("=")) { - lex(); - return markerApply(marker, astNodeFactory.createJSXAttribute(name, parseJSXAttributeValue())); - } - - return markerApply(marker, astNodeFactory.createJSXAttribute(name)); -} - -function parseJSXChild() { - var token, marker; - if (match("{")) { - token = parseJSXExpressionContainer(); - } else if (lookahead.type === Token.JSXText) { - marker = markerCreatePreserveWhitespace(); - token = markerApply(marker, astNodeFactory.createLiteralFromSource(lex(), source)); - } else { - token = parseJSXElement(); - } - return token; -} - -function parseJSXClosingElement() { - var name, origInJSXChild, origInJSXTag, marker = markerCreate(); - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = true; - expect("<"); - expect("/"); - name = parseJSXElementName(); - // Because advance() (called by lex() called by expect()) expects there - // to be a valid token after >, it needs to know whether to look for a - // standard JS token or an JSX text node - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - expect(">"); - return markerApply(marker, astNodeFactory.createJSXClosingElement(name)); -} - -function parseJSXOpeningElement() { - var name, attributes = [], selfClosing = false, origInJSXChild, - origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = true; - - expect("<"); - - name = parseJSXElementName(); - - while (index < length && - lookahead.value !== "/" && - lookahead.value !== ">") { - attributes.push(parseJSXAttribute()); - } - - state.inJSXTag = origInJSXTag; - - if (lookahead.value === "/") { - expect("/"); - // Because advance() (called by lex() called by expect()) expects - // there to be a valid token after >, it needs to know whether to - // look for a standard JS token or an JSX text node - state.inJSXChild = origInJSXChild; - expect(">"); - selfClosing = true; - } else { - state.inJSXChild = true; - expect(">"); - } - return markerApply(marker, astNodeFactory.createJSXOpeningElement(name, attributes, selfClosing)); -} - -function parseJSXElement() { - var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - openingElement = parseJSXOpeningElement(); - - if (!openingElement.selfClosing) { - while (index < length) { - state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because one
two
; - * - * the default error message is a bit incomprehensible. Since it"s - * rarely (never?) useful to write a less-than sign after an JSX - * element, we disallow it here in the parser in order to provide a - * better error message. (In the rare case that the less-than operator - * was intended, the left tag can be wrapped in parentheses.) - */ - if (!origInJSXChild && match("<")) { - throwError(lookahead, Messages.AdjacentJSXElements); - } - - return markerApply(marker, astNodeFactory.createJSXElement(openingElement, closingElement, children)); -} - -//------------------------------------------------------------------------------ -// Location markers -//------------------------------------------------------------------------------ - -/** - * Applies location information to the given node by using the given marker. - * The marker indicates the point at which the node is said to have to begun - * in the source code. - * @param {Object} marker The marker to use for the node. - * @param {ASTNode} node The AST node to apply location information to. - * @returns {ASTNode} The node that was passed in. - * @private - */ -function markerApply(marker, node) { - - // add range information to the node if present - if (extra.range) { - node.range = [marker.offset, index]; - } - - // add location information the node if present - if (extra.loc) { - node.loc = { - start: { - line: marker.line, - column: marker.col - }, - end: { - line: lineNumber, - column: index - lineStart - } - }; - // Attach extra.source information to the location, if present - if (extra.source) { - node.loc.source = extra.source; - } - } - - // attach leading and trailing comments if requested - if (extra.attachComment) { - commentAttachment.processComment(node); - } - - return node; -} - -/** - * Creates a location marker in the source code. Location markers are used for - * tracking where tokens and nodes appear in the source code. - * @returns {Object} A marker object or undefined if the parser doesn't have - * any location information. - * @private - */ -function markerCreate() { - - if (!extra.loc && !extra.range) { - return undefined; - } - - skipComment(); - - return { - offset: index, - line: lineNumber, - col: index - lineStart - }; -} - -/** - * Creates a location marker in the source code. Location markers are used for - * tracking where tokens and nodes appear in the source code. This method - * doesn't skip comments or extra whitespace which is important for JSX. - * @returns {Object} A marker object or undefined if the parser doesn't have - * any location information. - * @private - */ -function markerCreatePreserveWhitespace() { - - if (!extra.loc && !extra.range) { - return undefined; - } - - return { - offset: index, - line: lineNumber, - col: index - lineStart - }; -} - - -//------------------------------------------------------------------------------ -// Syntax Tree Delegate -//------------------------------------------------------------------------------ - -// Return true if there is a line terminator before the next token. - -function peekLineTerminator() { - var pos, line, start, found; - - pos = index; - line = lineNumber; - start = lineStart; - skipComment(); - found = lineNumber !== line; - index = pos; - lineNumber = line; - lineStart = start; - - return found; -} - -// Throw an exception - -function throwError(token, messageFormat) { - - var error, - args = Array.prototype.slice.call(arguments, 2), - msg = messageFormat.replace( - /%(\d)/g, - function (whole, index) { - assert(index < args.length, "Message reference must be in range"); - return args[index]; - } - ); - - if (typeof token.lineNumber === "number") { - error = new Error("Line " + token.lineNumber + ": " + msg); - error.index = token.range[0]; - error.lineNumber = token.lineNumber; - error.column = token.range[0] - token.lineStart + 1; - } else { - error = new Error("Line " + lineNumber + ": " + msg); - error.index = index; - error.lineNumber = lineNumber; - error.column = index - lineStart + 1; - } - - error.description = msg; - throw error; -} - -function throwErrorTolerant() { - try { - throwError.apply(null, arguments); - } catch (e) { - if (extra.errors) { - extra.errors.push(e); - } else { - throw e; - } - } -} - - -// Throw an exception because of the token. - -function throwUnexpected(token) { - - if (token.type === Token.EOF) { - throwError(token, Messages.UnexpectedEOS); - } - - if (token.type === Token.NumericLiteral) { - throwError(token, Messages.UnexpectedNumber); - } - - if (token.type === Token.StringLiteral || token.type === Token.JSXText) { - throwError(token, Messages.UnexpectedString); - } - - if (token.type === Token.Identifier) { - throwError(token, Messages.UnexpectedIdentifier); - } - - if (token.type === Token.Keyword) { - if (syntax.isFutureReservedWord(token.value)) { - throwError(token, Messages.UnexpectedReserved); - } else if (strict && syntax.isStrictModeReservedWord(token.value, extra.ecmaFeatures)) { - throwErrorTolerant(token, Messages.StrictReservedWord); - return; - } - throwError(token, Messages.UnexpectedToken, token.value); - } - - if (token.type === Token.Template) { - throwError(token, Messages.UnexpectedTemplate, token.value.raw); - } - - // BooleanLiteral, NullLiteral, or Punctuator. - throwError(token, Messages.UnexpectedToken, token.value); -} - -// Expect the next token to match the specified punctuator. -// If not, an exception will be thrown. - -function expect(value) { - var token = lex(); - if (token.type !== Token.Punctuator || token.value !== value) { - throwUnexpected(token); - } -} - -// Expect the next token to match the specified keyword. -// If not, an exception will be thrown. - -function expectKeyword(keyword) { - var token = lex(); - if (token.type !== Token.Keyword || token.value !== keyword) { - throwUnexpected(token); - } -} - -// Return true if the next token matches the specified punctuator. - -function match(value) { - return lookahead.type === Token.Punctuator && lookahead.value === value; -} - -// Return true if the next token matches the specified keyword - -function matchKeyword(keyword) { - return lookahead.type === Token.Keyword && lookahead.value === keyword; -} - -// Return true if the next token matches the specified contextual keyword -// (where an identifier is sometimes a keyword depending on the context) - -function matchContextualKeyword(keyword) { - return lookahead.type === Token.Identifier && lookahead.value === keyword; -} - -// Return true if the next token is an assignment operator - -function matchAssign() { - var op; - - if (lookahead.type !== Token.Punctuator) { - return false; - } - op = lookahead.value; - return op === "=" || - op === "*=" || - op === "/=" || - op === "%=" || - op === "+=" || - op === "-=" || - op === "<<=" || - op === ">>=" || - op === ">>>=" || - op === "&=" || - op === "^=" || - op === "|="; -} - -function consumeSemicolon() { - var line; - - // Catch the very common case first: immediately a semicolon (U+003B). - if (source.charCodeAt(index) === 0x3B || match(";")) { - lex(); - return; - } - - line = lineNumber; - skipComment(); - if (lineNumber !== line) { - return; - } - - if (lookahead.type !== Token.EOF && !match("}")) { - throwUnexpected(lookahead); - } -} - -// Return true if provided expression is LeftHandSideExpression - -function isLeftHandSide(expr) { - return expr.type === astNodeTypes.Identifier || expr.type === astNodeTypes.MemberExpression; -} - -// 11.1.4 Array Initialiser - -function parseArrayInitialiser() { - var elements = [], - marker = markerCreate(), - tmp; - - expect("["); - - while (!match("]")) { - if (match(",")) { - lex(); // only get here when you have [a,,] or similar - elements.push(null); - } else { - tmp = parseSpreadOrAssignmentExpression(); - elements.push(tmp); - if (!(match("]"))) { - expect(","); // handles the common case of comma-separated values - } - } - } - - expect("]"); - - return markerApply(marker, astNodeFactory.createArrayExpression(elements)); -} - -// 11.1.5 Object Initialiser - -function parsePropertyFunction(paramInfo, options) { - var previousStrict = strict, - previousYieldAllowed = state.yieldAllowed, - generator = options ? options.generator : false, - body; - - state.yieldAllowed = generator; - - /* - * Esprima uses parseConciseBody() here, which is incorrect. Object literal - * methods must have braces. - */ - body = parseFunctionSourceElements(); - - if (strict && paramInfo.firstRestricted) { - throwErrorTolerant(paramInfo.firstRestricted, Messages.StrictParamName); - } - - if (strict && paramInfo.stricted) { - throwErrorTolerant(paramInfo.stricted, paramInfo.message); - } - - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - - return markerApply(options.marker, astNodeFactory.createFunctionExpression( - null, - paramInfo.params, - body, - generator, - body.type !== astNodeTypes.BlockStatement - )); -} - -function parsePropertyMethodFunction(options) { - var previousStrict = strict, - marker = markerCreate(), - params, - method; - - strict = true; - - params = parseParams(); - - if (params.stricted) { - throwErrorTolerant(params.stricted, params.message); - } - - method = parsePropertyFunction(params, { - generator: options ? options.generator : false, - marker: marker - }); - - strict = previousStrict; - - return method; -} - -function parseObjectPropertyKey() { - var marker = markerCreate(), - token = lex(), - allowObjectLiteralComputed = extra.ecmaFeatures.objectLiteralComputedProperties, - expr, - result; - - // Note: This function is called only from parseObjectProperty(), where - // EOF and Punctuator tokens are already filtered out. - - switch (token.type) { - case Token.StringLiteral: - case Token.NumericLiteral: - if (strict && token.octal) { - throwErrorTolerant(token, Messages.StrictOctalLiteral); - } - return markerApply(marker, astNodeFactory.createLiteralFromSource(token, source)); - - case Token.Identifier: - case Token.BooleanLiteral: - case Token.NullLiteral: - case Token.Keyword: - return markerApply(marker, astNodeFactory.createIdentifier(token.value)); - - case Token.Punctuator: - if ((!state.inObjectLiteral || allowObjectLiteralComputed) && - token.value === "[") { - // For computed properties we should skip the [ and ], and - // capture in marker only the assignment expression itself. - marker = markerCreate(); - expr = parseAssignmentExpression(); - result = markerApply(marker, expr); - expect("]"); - return result; - } - - // no default - } - - throwUnexpected(token); -} - -function lookaheadPropertyName() { - switch (lookahead.type) { - case Token.Identifier: - case Token.StringLiteral: - case Token.BooleanLiteral: - case Token.NullLiteral: - case Token.NumericLiteral: - case Token.Keyword: - return true; - case Token.Punctuator: - return lookahead.value === "["; - // no default - } - return false; -} - -// This function is to try to parse a MethodDefinition as defined in 14.3. But in the case of object literals, -// it might be called at a position where there is in fact a short hand identifier pattern or a data property. -// This can only be determined after we consumed up to the left parentheses. -// In order to avoid back tracking, it returns `null` if the position is not a MethodDefinition and the caller -// is responsible to visit other options. -function tryParseMethodDefinition(token, key, computed, marker) { - var value, options, methodMarker; - - if (token.type === Token.Identifier) { - // check for `get` and `set`; - - if (token.value === "get" && lookaheadPropertyName()) { - - computed = match("["); - key = parseObjectPropertyKey(); - methodMarker = markerCreate(); - expect("("); - expect(")"); - - value = parsePropertyFunction({ - params: [], - stricted: null, - firstRestricted: null, - message: null - }, { - marker: methodMarker - }); - - return markerApply(marker, astNodeFactory.createProperty("get", key, value, false, false, computed)); - - } else if (token.value === "set" && lookaheadPropertyName()) { - computed = match("["); - key = parseObjectPropertyKey(); - methodMarker = markerCreate(); - expect("("); - - options = { - params: [], - defaultCount: 0, - stricted: null, - firstRestricted: null, - paramSet: new StringMap() - }; - if (match(")")) { - throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value); - } else { - parseParam(options); - } - expect(")"); - - value = parsePropertyFunction(options, { marker: methodMarker }); - return markerApply(marker, astNodeFactory.createProperty("set", key, value, false, false, computed)); - } - } - - if (match("(")) { - value = parsePropertyMethodFunction(); - return markerApply(marker, astNodeFactory.createProperty("init", key, value, true, false, computed)); - } - - // Not a MethodDefinition. - return null; -} - -/** - * Parses Generator Properties - * @param {ASTNode} key The property key (usually an identifier). - * @param {Object} marker The marker to use for the node. - * @returns {ASTNode} The generator property node. - */ -function parseGeneratorProperty(key, marker) { - - var computed = (lookahead.type === Token.Punctuator && lookahead.value === "["); - - if (!match("(")) { - throwUnexpected(lex()); - } - - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - key, - parsePropertyMethodFunction({ generator: true }), - true, - false, - computed - ) - ); -} - -// TODO(nzakas): Update to match Esprima -function parseObjectProperty() { - var token, key, id, computed, methodMarker, options; - var allowComputed = extra.ecmaFeatures.objectLiteralComputedProperties, - allowMethod = extra.ecmaFeatures.objectLiteralShorthandMethods, - allowShorthand = extra.ecmaFeatures.objectLiteralShorthandProperties, - allowGenerators = extra.ecmaFeatures.generators, - allowDestructuring = extra.ecmaFeatures.destructuring, - allowSpread = extra.ecmaFeatures.experimentalObjectRestSpread, - marker = markerCreate(); - - token = lookahead; - computed = (token.value === "[" && token.type === Token.Punctuator); - - if (token.type === Token.Identifier || (allowComputed && computed)) { - - id = parseObjectPropertyKey(); - - /* - * Check for getters and setters. Be careful! "get" and "set" are legal - * method names. It's only a getter or setter if followed by a space. - */ - if (token.value === "get" && - !(match(":") || match("(") || match(",") || match("}"))) { - computed = (lookahead.value === "["); - key = parseObjectPropertyKey(); - methodMarker = markerCreate(); - expect("("); - expect(")"); - - return markerApply( - marker, - astNodeFactory.createProperty( - "get", - key, - parsePropertyFunction({ - generator: false - }, { - marker: methodMarker - }), - false, - false, - computed - ) - ); - } - - if (token.value === "set" && - !(match(":") || match("(") || match(",") || match("}"))) { - computed = (lookahead.value === "["); - key = parseObjectPropertyKey(); - methodMarker = markerCreate(); - expect("("); - - options = { - params: [], - defaultCount: 0, - stricted: null, - firstRestricted: null, - paramSet: new StringMap() - }; - - if (match(")")) { - throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value); - } else { - parseParam(options); - } - - expect(")"); - - return markerApply( - marker, - astNodeFactory.createProperty( - "set", - key, - parsePropertyFunction(options, { - marker: methodMarker - }), - false, - false, - computed - ) - ); - } - - // normal property (key:value) - if (match(":")) { - lex(); - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - id, - parseAssignmentExpression(), - false, - false, - computed - ) - ); - } - - // method shorthand (key(){...}) - if (allowMethod && match("(")) { - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - id, - parsePropertyMethodFunction({ generator: false }), - true, - false, - computed - ) - ); - } - - // destructuring defaults (shorthand syntax) - if (allowDestructuring && match("=")) { - lex(); - var value = parseAssignmentExpression(); - var prop = markerApply(marker, astNodeFactory.createAssignmentExpression("=", id, value)); - prop.type = astNodeTypes.AssignmentPattern; - var fullProperty = astNodeFactory.createProperty( - "init", - id, - prop, - false, - true, // shorthand - computed - ); - return markerApply(marker, fullProperty); - } - - /* - * Only other possibility is that this is a shorthand property. Computed - * properties cannot use shorthand notation, so that's a syntax error. - * If shorthand properties aren't allow, then this is an automatic - * syntax error. Destructuring is another case with a similar shorthand syntax. - */ - if (computed || (!allowShorthand && !allowDestructuring)) { - throwUnexpected(lookahead); - } - - // shorthand property - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - id, - id, - false, - true, - false - ) - ); - } - - // object spread property - if (allowSpread && match("...")) { - lex(); - return markerApply(marker, astNodeFactory.createExperimentalSpreadProperty(parseAssignmentExpression())); - } - - // only possibility in this branch is a shorthand generator - if (token.type === Token.EOF || token.type === Token.Punctuator) { - if (!allowGenerators || !match("*") || !allowMethod) { - throwUnexpected(token); - } - - lex(); - - id = parseObjectPropertyKey(); - - return parseGeneratorProperty(id, marker); - - } - - /* - * If we've made it here, then that means the property name is represented - * by a string (i.e, { "foo": 2}). The only options here are normal - * property with a colon or a method. - */ - key = parseObjectPropertyKey(); - - // check for property value - if (match(":")) { - lex(); - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - key, - parseAssignmentExpression(), - false, - false, - false - ) - ); - } - - // check for method - if (allowMethod && match("(")) { - return markerApply( - marker, - astNodeFactory.createProperty( - "init", - key, - parsePropertyMethodFunction(), - true, - false, - false - ) - ); - } - - // no other options, this is bad - throwUnexpected(lex()); -} - -function getFieldName(key) { - var toString = String; - if (key.type === astNodeTypes.Identifier) { - return key.name; - } - return toString(key.value); -} - -function parseObjectInitialiser() { - var marker = markerCreate(), - allowDuplicates = extra.ecmaFeatures.objectLiteralDuplicateProperties, - properties = [], - property, - name, - propertyFn, - kind, - storedKind, - previousInObjectLiteral = state.inObjectLiteral, - kindMap = new StringMap(); - - state.inObjectLiteral = true; - - expect("{"); - - while (!match("}")) { - - property = parseObjectProperty(); - - if (!property.computed && property.type.indexOf("Experimental") === -1) { - - name = getFieldName(property.key); - propertyFn = (property.kind === "get") ? PropertyKind.Get : PropertyKind.Set; - kind = (property.kind === "init") ? PropertyKind.Data : propertyFn; - - if (kindMap.has(name)) { - storedKind = kindMap.get(name); - if (storedKind === PropertyKind.Data) { - if (kind === PropertyKind.Data && name === "__proto__" && allowDuplicates) { - // Duplicate '__proto__' literal properties are forbidden in ES 6 - throwErrorTolerant({}, Messages.DuplicatePrototypeProperty); - } else if (strict && kind === PropertyKind.Data && !allowDuplicates) { - // Duplicate literal properties are only forbidden in ES 5 strict mode - throwErrorTolerant({}, Messages.StrictDuplicateProperty); - } else if (kind !== PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } - } else { - if (kind === PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } else if (storedKind & kind) { - throwErrorTolerant({}, Messages.AccessorGetSet); - } - } - kindMap.set(name, storedKind | kind); - } else { - kindMap.set(name, kind); - } - } - - properties.push(property); - - if (!match("}")) { - expect(","); - } - } - - expect("}"); - - state.inObjectLiteral = previousInObjectLiteral; - - return markerApply(marker, astNodeFactory.createObjectExpression(properties)); -} - -/** - * Parse a template string element and return its ASTNode representation - * @param {Object} option Parsing & scanning options - * @param {Object} option.head True if this element is the first in the - * template string, false otherwise. - * @returns {ASTNode} The template element node with marker info applied - * @private - */ -function parseTemplateElement(option) { - var marker, token; - - if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) { - throwError({}, Messages.UnexpectedToken, "ILLEGAL"); - } - - marker = markerCreate(); - token = lex(); - - return markerApply( - marker, - astNodeFactory.createTemplateElement( - { - raw: token.value.raw, - cooked: token.value.cooked - }, - token.tail - ) - ); -} - -/** - * Parse a template string literal and return its ASTNode representation - * @returns {ASTNode} The template literal node with marker info applied - * @private - */ -function parseTemplateLiteral() { - var quasi, quasis, expressions, marker = markerCreate(); - - quasi = parseTemplateElement({ head: true }); - quasis = [ quasi ]; - expressions = []; - - while (!quasi.tail) { - expressions.push(parseExpression()); - quasi = parseTemplateElement({ head: false }); - quasis.push(quasi); - } - - return markerApply(marker, astNodeFactory.createTemplateLiteral(quasis, expressions)); -} - -// 11.1.6 The Grouping Operator - -function parseGroupExpression() { - var expr; - - expect("("); - - ++state.parenthesisCount; - - expr = parseExpression(); - - expect(")"); - - return expr; -} - - -// 11.1 Primary Expressions - -function parsePrimaryExpression() { - var type, token, expr, - marker, - allowJSX = extra.ecmaFeatures.jsx, - allowClasses = extra.ecmaFeatures.classes, - allowSuper = allowClasses || extra.ecmaFeatures.superInFunctions; - - if (match("(")) { - return parseGroupExpression(); - } - - if (match("[")) { - return parseArrayInitialiser(); - } - - if (match("{")) { - return parseObjectInitialiser(); - } - - if (allowJSX && match("<")) { - return parseJSXElement(); - } - - type = lookahead.type; - marker = markerCreate(); - - if (type === Token.Identifier) { - expr = astNodeFactory.createIdentifier(lex().value); - } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { - if (strict && lookahead.octal) { - throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); - } - expr = astNodeFactory.createLiteralFromSource(lex(), source); - } else if (type === Token.Keyword) { - if (matchKeyword("function")) { - return parseFunctionExpression(); - } - - if (allowSuper && matchKeyword("super") && state.inFunctionBody) { - marker = markerCreate(); - lex(); - return markerApply(marker, astNodeFactory.createSuper()); - } - - if (matchKeyword("this")) { - marker = markerCreate(); - lex(); - return markerApply(marker, astNodeFactory.createThisExpression()); - } - - if (allowClasses && matchKeyword("class")) { - return parseClassExpression(); - } - - throwUnexpected(lex()); - } else if (type === Token.BooleanLiteral) { - token = lex(); - token.value = (token.value === "true"); - expr = astNodeFactory.createLiteralFromSource(token, source); - } else if (type === Token.NullLiteral) { - token = lex(); - token.value = null; - expr = astNodeFactory.createLiteralFromSource(token, source); - } else if (match("/") || match("/=")) { - if (typeof extra.tokens !== "undefined") { - expr = astNodeFactory.createLiteralFromSource(collectRegex(), source); - } else { - expr = astNodeFactory.createLiteralFromSource(scanRegExp(), source); - } - peek(); - } else if (type === Token.Template) { - return parseTemplateLiteral(); - } else { - throwUnexpected(lex()); - } - - return markerApply(marker, expr); -} - -// 11.2 Left-Hand-Side Expressions - -function parseArguments() { - var args = [], arg; - - expect("("); - if (!match(")")) { - while (index < length) { - arg = parseSpreadOrAssignmentExpression(); - args.push(arg); - - if (match(")")) { - break; - } - - expect(","); - } - } - - expect(")"); - - return args; -} - -function parseSpreadOrAssignmentExpression() { - if (match("...")) { - var marker = markerCreate(); - lex(); - return markerApply(marker, astNodeFactory.createSpreadElement(parseAssignmentExpression())); - } - return parseAssignmentExpression(); -} - -function parseNonComputedProperty() { - var token, - marker = markerCreate(); - - token = lex(); - - if (!isIdentifierName(token)) { - throwUnexpected(token); - } - - return markerApply(marker, astNodeFactory.createIdentifier(token.value)); -} - -function parseNonComputedMember() { - expect("."); - - return parseNonComputedProperty(); -} - -function parseComputedMember() { - var expr; - - expect("["); - - expr = parseExpression(); - - expect("]"); - - return expr; -} - -function parseNewExpression() { - var callee, args, - marker = markerCreate(); - - expectKeyword("new"); - - if (extra.ecmaFeatures.newTarget && match(".")) { - lex(); - if (lookahead.type === Token.Identifier && lookahead.value === "target") { - if (state.inFunctionBody) { - lex(); - return markerApply(marker, astNodeFactory.createMetaProperty("new", "target")); - } - } - - throwUnexpected(lookahead); - } - - callee = parseLeftHandSideExpression(); - args = match("(") ? parseArguments() : []; - - return markerApply(marker, astNodeFactory.createNewExpression(callee, args)); -} - -function parseLeftHandSideExpressionAllowCall() { - var expr, args, - previousAllowIn = state.allowIn, - marker = markerCreate(); - - state.allowIn = true; - expr = matchKeyword("new") ? parseNewExpression() : parsePrimaryExpression(); - state.allowIn = previousAllowIn; - - // only start parsing template literal if the lookahead is a head (beginning with `) - while (match(".") || match("[") || match("(") || (lookahead.type === Token.Template && lookahead.head)) { - if (match("(")) { - args = parseArguments(); - expr = markerApply(marker, astNodeFactory.createCallExpression(expr, args)); - } else if (match("[")) { - expr = markerApply(marker, astNodeFactory.createMemberExpression("[", expr, parseComputedMember())); - } else if (match(".")) { - expr = markerApply(marker, astNodeFactory.createMemberExpression(".", expr, parseNonComputedMember())); - } else { - expr = markerApply(marker, astNodeFactory.createTaggedTemplateExpression(expr, parseTemplateLiteral())); - } - } - - return expr; -} - -function parseLeftHandSideExpression() { - var expr, - previousAllowIn = state.allowIn, - marker = markerCreate(); - - expr = matchKeyword("new") ? parseNewExpression() : parsePrimaryExpression(); - state.allowIn = previousAllowIn; - - // only start parsing template literal if the lookahead is a head (beginning with `) - while (match(".") || match("[") || (lookahead.type === Token.Template && lookahead.head)) { - if (match("[")) { - expr = markerApply(marker, astNodeFactory.createMemberExpression("[", expr, parseComputedMember())); - } else if (match(".")) { - expr = markerApply(marker, astNodeFactory.createMemberExpression(".", expr, parseNonComputedMember())); - } else { - expr = markerApply(marker, astNodeFactory.createTaggedTemplateExpression(expr, parseTemplateLiteral())); - } - } - - return expr; -} - - -// 11.3 Postfix Expressions - -function parsePostfixExpression() { - var expr, token, - marker = markerCreate(); - - expr = parseLeftHandSideExpressionAllowCall(); - - if (lookahead.type === Token.Punctuator) { - if ((match("++") || match("--")) && !peekLineTerminator()) { - // 11.3.1, 11.3.2 - if (strict && expr.type === astNodeTypes.Identifier && syntax.isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPostfix); - } - - if (!isLeftHandSide(expr)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - - token = lex(); - expr = markerApply(marker, astNodeFactory.createPostfixExpression(token.value, expr)); - } - } - - return expr; -} - -// 11.4 Unary Operators - -function parseUnaryExpression() { - var token, expr, - marker; - - if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { - expr = parsePostfixExpression(); - } else if (match("++") || match("--")) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - // 11.4.4, 11.4.5 - if (strict && expr.type === astNodeTypes.Identifier && syntax.isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPrefix); - } - - if (!isLeftHandSide(expr)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - - expr = astNodeFactory.createUnaryExpression(token.value, expr); - expr = markerApply(marker, expr); - } else if (match("+") || match("-") || match("~") || match("!")) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - expr = astNodeFactory.createUnaryExpression(token.value, expr); - expr = markerApply(marker, expr); - } else if (matchKeyword("delete") || matchKeyword("void") || matchKeyword("typeof")) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - expr = astNodeFactory.createUnaryExpression(token.value, expr); - expr = markerApply(marker, expr); - if (strict && expr.operator === "delete" && expr.argument.type === astNodeTypes.Identifier) { - throwErrorTolerant({}, Messages.StrictDelete); - } - } else { - expr = parsePostfixExpression(); - } - - return expr; -} - -function binaryPrecedence(token, allowIn) { - var prec = 0; - - if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { - return 0; - } - - switch (token.value) { - case "||": - prec = 1; - break; - - case "&&": - prec = 2; - break; - - case "|": - prec = 3; - break; - - case "^": - prec = 4; - break; - - case "&": - prec = 5; - break; - - case "==": - case "!=": - case "===": - case "!==": - prec = 6; - break; - - case "<": - case ">": - case "<=": - case ">=": - case "instanceof": - prec = 7; - break; - - case "in": - prec = allowIn ? 7 : 0; - break; - - case "<<": - case ">>": - case ">>>": - prec = 8; - break; - - case "+": - case "-": - prec = 9; - break; - - case "*": - case "/": - case "%": - prec = 11; - break; - - default: - break; - } - - return prec; -} - -// 11.5 Multiplicative Operators -// 11.6 Additive Operators -// 11.7 Bitwise Shift Operators -// 11.8 Relational Operators -// 11.9 Equality Operators -// 11.10 Binary Bitwise Operators -// 11.11 Binary Logical Operators -function parseBinaryExpression() { - var expr, token, prec, previousAllowIn, stack, right, operator, left, i, - marker, markers; - - previousAllowIn = state.allowIn; - state.allowIn = true; - - marker = markerCreate(); - left = parseUnaryExpression(); - - token = lookahead; - prec = binaryPrecedence(token, previousAllowIn); - if (prec === 0) { - return left; - } - token.prec = prec; - lex(); - - markers = [marker, markerCreate()]; - right = parseUnaryExpression(); - - stack = [left, token, right]; - - while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) { - - // Reduce: make a binary expression from the three topmost entries. - while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { - right = stack.pop(); - operator = stack.pop().value; - left = stack.pop(); - expr = astNodeFactory.createBinaryExpression(operator, left, right); - markers.pop(); - marker = markers.pop(); - markerApply(marker, expr); - stack.push(expr); - markers.push(marker); - } - - // Shift. - token = lex(); - token.prec = prec; - stack.push(token); - markers.push(markerCreate()); - expr = parseUnaryExpression(); - stack.push(expr); - } - - state.allowIn = previousAllowIn; - - // Final reduce to clean-up the stack. - i = stack.length - 1; - expr = stack[i]; - markers.pop(); - while (i > 1) { - expr = astNodeFactory.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); - i -= 2; - marker = markers.pop(); - markerApply(marker, expr); - } - - return expr; -} - -// 11.12 Conditional Operator - -function parseConditionalExpression() { - var expr, previousAllowIn, consequent, alternate, - marker = markerCreate(); - - expr = parseBinaryExpression(); - - if (match("?")) { - lex(); - previousAllowIn = state.allowIn; - state.allowIn = true; - consequent = parseAssignmentExpression(); - state.allowIn = previousAllowIn; - expect(":"); - alternate = parseAssignmentExpression(); - - expr = astNodeFactory.createConditionalExpression(expr, consequent, alternate); - markerApply(marker, expr); - } - - return expr; -} - -// [ES6] 14.2 Arrow Function - -function parseConciseBody() { - if (match("{")) { - return parseFunctionSourceElements(); - } - return parseAssignmentExpression(); -} - -function reinterpretAsCoverFormalsList(expressions) { - var i, len, param, params, options, - allowRestParams = extra.ecmaFeatures.restParams; - - params = []; - options = { - paramSet: new StringMap() - }; - - for (i = 0, len = expressions.length; i < len; i += 1) { - param = expressions[i]; - if (param.type === astNodeTypes.Identifier) { - params.push(param); - validateParam(options, param, param.name); - } else if (param.type === astNodeTypes.ObjectExpression || param.type === astNodeTypes.ArrayExpression) { - reinterpretAsDestructuredParameter(options, param); - params.push(param); - } else if (param.type === astNodeTypes.SpreadElement) { - assert(i === len - 1, "It is guaranteed that SpreadElement is last element by parseExpression"); - if (param.argument.type !== astNodeTypes.Identifier) { - throwError({}, Messages.UnexpectedToken, "["); - } - - if (!allowRestParams) { - // can't get correct line/column here :( - throwError({}, Messages.UnexpectedToken, "."); - } - - validateParam(options, param.argument, param.argument.name); - param.type = astNodeTypes.RestElement; - params.push(param); - } else if (param.type === astNodeTypes.RestElement) { - params.push(param); - validateParam(options, param.argument, param.argument.name); - } else if (param.type === astNodeTypes.AssignmentExpression) { - - // TODO: Find a less hacky way of doing this - param.type = astNodeTypes.AssignmentPattern; - delete param.operator; - - if (param.right.type === astNodeTypes.YieldExpression) { - if (param.right.argument) { - throwUnexpected(lookahead); - } - - param.right.type = astNodeTypes.Identifier; - param.right.name = "yield"; - delete param.right.argument; - delete param.right.delegate; - } - - params.push(param); - validateParam(options, param.left, param.left.name); - } else { - return null; - } - } - - if (options.message === Messages.StrictParamDupe) { - throwError( - strict ? options.stricted : options.firstRestricted, - options.message - ); - } - - return { - params: params, - stricted: options.stricted, - firstRestricted: options.firstRestricted, - message: options.message - }; -} - -function parseArrowFunctionExpression(options, marker) { - var previousStrict, body; - var arrowStart = lineNumber; - - expect("=>"); - previousStrict = strict; - - if (lineNumber > arrowStart) { - throwError({}, Messages.UnexpectedToken, "=>"); - } - - body = parseConciseBody(); - - if (strict && options.firstRestricted) { - throwError(options.firstRestricted, options.message); - } - if (strict && options.stricted) { - throwErrorTolerant(options.stricted, options.message); - } - - strict = previousStrict; - return markerApply(marker, astNodeFactory.createArrowFunctionExpression( - options.params, - body, - body.type !== astNodeTypes.BlockStatement - )); -} - -// 11.13 Assignment Operators - -// 12.14.5 AssignmentPattern - -function reinterpretAsAssignmentBindingPattern(expr) { - var i, len, property, element, - allowDestructuring = extra.ecmaFeatures.destructuring, - allowRest = extra.ecmaFeatures.experimentalObjectRestSpread; - - if (!allowDestructuring) { - throwUnexpected(lex()); - } - - if (expr.type === astNodeTypes.ObjectExpression) { - expr.type = astNodeTypes.ObjectPattern; - for (i = 0, len = expr.properties.length; i < len; i += 1) { - property = expr.properties[i]; - - if (allowRest && property.type === astNodeTypes.ExperimentalSpreadProperty) { - - // only allow identifiers - if (property.argument.type !== astNodeTypes.Identifier) { - throwErrorTolerant({}, "Invalid object rest."); - } - - property.type = astNodeTypes.ExperimentalRestProperty; - return; - } - - if (property.kind !== "init") { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - reinterpretAsAssignmentBindingPattern(property.value); - } - } else if (expr.type === astNodeTypes.ArrayExpression) { - expr.type = astNodeTypes.ArrayPattern; - for (i = 0, len = expr.elements.length; i < len; i += 1) { - element = expr.elements[i]; - /* istanbul ignore else */ - if (element) { - reinterpretAsAssignmentBindingPattern(element); - } - } - } else if (expr.type === astNodeTypes.Identifier) { - if (syntax.isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - } else if (expr.type === astNodeTypes.SpreadElement) { - reinterpretAsAssignmentBindingPattern(expr.argument); - if (expr.argument.type === astNodeTypes.ObjectPattern) { - throwErrorTolerant({}, Messages.ObjectPatternAsSpread); - } - } else if (expr.type === "AssignmentExpression" && expr.operator === "=") { - expr.type = astNodeTypes.AssignmentPattern; - } else { - /* istanbul ignore else */ - if (expr.type !== astNodeTypes.MemberExpression && - expr.type !== astNodeTypes.CallExpression && - expr.type !== astNodeTypes.NewExpression && - expr.type !== astNodeTypes.AssignmentPattern - ) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - } -} - -// 13.2.3 BindingPattern - -function reinterpretAsDestructuredParameter(options, expr) { - var i, len, property, element, - allowDestructuring = extra.ecmaFeatures.destructuring; - - if (!allowDestructuring) { - throwUnexpected(lex()); - } - - if (expr.type === astNodeTypes.ObjectExpression) { - expr.type = astNodeTypes.ObjectPattern; - for (i = 0, len = expr.properties.length; i < len; i += 1) { - property = expr.properties[i]; - if (property.kind !== "init") { - throwErrorTolerant({}, Messages.InvalidLHSInFormalsList); - } - reinterpretAsDestructuredParameter(options, property.value); - } - } else if (expr.type === astNodeTypes.ArrayExpression) { - expr.type = astNodeTypes.ArrayPattern; - for (i = 0, len = expr.elements.length; i < len; i += 1) { - element = expr.elements[i]; - if (element) { - reinterpretAsDestructuredParameter(options, element); - } - } - } else if (expr.type === astNodeTypes.Identifier) { - validateParam(options, expr, expr.name); - } else if (expr.type === astNodeTypes.SpreadElement) { - // BindingRestElement only allows BindingIdentifier - if (expr.argument.type !== astNodeTypes.Identifier) { - throwErrorTolerant({}, Messages.InvalidLHSInFormalsList); - } - validateParam(options, expr.argument, expr.argument.name); - } else if (expr.type === astNodeTypes.AssignmentExpression && expr.operator === "=") { - expr.type = astNodeTypes.AssignmentPattern; - } else if (expr.type !== astNodeTypes.AssignmentPattern) { - throwError({}, Messages.InvalidLHSInFormalsList); - } -} - -function parseAssignmentExpression() { - var token, left, right, node, params, - marker, - startsWithParen = false, - oldParenthesisCount = state.parenthesisCount, - allowGenerators = extra.ecmaFeatures.generators; - - // Note that 'yield' is treated as a keyword in strict mode, but a - // contextual keyword (identifier) in non-strict mode, so we need - // to use matchKeyword and matchContextualKeyword appropriately. - if (allowGenerators && ((state.yieldAllowed && matchContextualKeyword("yield")) || (strict && matchKeyword("yield")))) { - return parseYieldExpression(); - } - - marker = markerCreate(); - - if (match("(")) { - token = lookahead2(); - if ((token.value === ")" && token.type === Token.Punctuator) || token.value === "...") { - params = parseParams(); - if (!match("=>")) { - throwUnexpected(lex()); - } - return parseArrowFunctionExpression(params, marker); - } - startsWithParen = true; - } - - // revert to the previous lookahead style object - token = lookahead; - node = left = parseConditionalExpression(); - - if (match("=>") && - (state.parenthesisCount === oldParenthesisCount || - state.parenthesisCount === (oldParenthesisCount + 1))) { - if (node.type === astNodeTypes.Identifier) { - params = reinterpretAsCoverFormalsList([ node ]); - } else if (node.type === astNodeTypes.AssignmentExpression || - node.type === astNodeTypes.ArrayExpression || - node.type === astNodeTypes.ObjectExpression) { - if (!startsWithParen) { - throwUnexpected(lex()); - } - params = reinterpretAsCoverFormalsList([ node ]); - } else if (node.type === astNodeTypes.SequenceExpression) { - params = reinterpretAsCoverFormalsList(node.expressions); - } - - if (params) { - state.parenthesisCount--; - return parseArrowFunctionExpression(params, marker); - } - } - - if (matchAssign()) { - - // 11.13.1 - if (strict && left.type === astNodeTypes.Identifier && syntax.isRestrictedWord(left.name)) { - throwErrorTolerant(token, Messages.StrictLHSAssignment); - } - - // ES.next draf 11.13 Runtime Semantics step 1 - if (match("=") && (node.type === astNodeTypes.ObjectExpression || node.type === astNodeTypes.ArrayExpression)) { - reinterpretAsAssignmentBindingPattern(node); - } else if (!isLeftHandSide(node)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - - token = lex(); - right = parseAssignmentExpression(); - - node = markerApply(marker, astNodeFactory.createAssignmentExpression(token.value, left, right)); - } - - return node; -} - -// 11.14 Comma Operator - -function parseExpression() { - var marker = markerCreate(), - expr = parseAssignmentExpression(), - expressions = [ expr ], - sequence, spreadFound; - - if (match(",")) { - while (index < length) { - if (!match(",")) { - break; - } - lex(); - expr = parseSpreadOrAssignmentExpression(); - expressions.push(expr); - - if (expr.type === astNodeTypes.SpreadElement) { - spreadFound = true; - if (!match(")")) { - throwError({}, Messages.ElementAfterSpreadElement); - } - break; - } - } - - sequence = markerApply(marker, astNodeFactory.createSequenceExpression(expressions)); - } - - if (spreadFound && lookahead2().value !== "=>") { - throwError({}, Messages.IllegalSpread); - } - - return sequence || expr; -} - -// 12.1 Block - -function parseStatementList() { - var list = [], - statement; - - while (index < length) { - if (match("}")) { - break; - } - statement = parseSourceElement(); - if (typeof statement === "undefined") { - break; - } - list.push(statement); - } - - return list; -} - -function parseBlock() { - var block, - marker = markerCreate(); - - expect("{"); - - block = parseStatementList(); - - expect("}"); - - return markerApply(marker, astNodeFactory.createBlockStatement(block)); -} - -// 12.2 Variable Statement - -function parseVariableIdentifier() { - var token, - marker = markerCreate(); - - token = lex(); - - if (token.type !== Token.Identifier) { - if (strict && token.type === Token.Keyword && syntax.isStrictModeReservedWord(token.value, extra.ecmaFeatures)) { - throwErrorTolerant(token, Messages.StrictReservedWord); - } else { - throwUnexpected(token); - } - } - - return markerApply(marker, astNodeFactory.createIdentifier(token.value)); -} - -function parseVariableDeclaration(kind) { - var id, - marker = markerCreate(), - init = null; - if (match("{")) { - id = parseObjectInitialiser(); - reinterpretAsAssignmentBindingPattern(id); - } else if (match("[")) { - id = parseArrayInitialiser(); - reinterpretAsAssignmentBindingPattern(id); - } else { - /* istanbul ignore next */ - id = state.allowKeyword ? parseNonComputedProperty() : parseVariableIdentifier(); - // 12.2.1 - if (strict && syntax.isRestrictedWord(id.name)) { - throwErrorTolerant({}, Messages.StrictVarName); - } - } - - // TODO: Verify against feature flags - if (kind === "const") { - if (!match("=")) { - throwError({}, Messages.NoUnintializedConst); - } - expect("="); - init = parseAssignmentExpression(); - } else if (match("=")) { - lex(); - init = parseAssignmentExpression(); - } - - return markerApply(marker, astNodeFactory.createVariableDeclarator(id, init)); -} - -function parseVariableDeclarationList(kind) { - var list = []; - - do { - list.push(parseVariableDeclaration(kind)); - if (!match(",")) { - break; - } - lex(); - } while (index < length); - - return list; -} - -function parseVariableStatement() { - var declarations; - - expectKeyword("var"); - - declarations = parseVariableDeclarationList(); - - consumeSemicolon(); - - return astNodeFactory.createVariableDeclaration(declarations, "var"); -} - -// kind may be `const` or `let` -// Both are experimental and not in the specification yet. -// see http://wiki.ecmascript.org/doku.php?id=harmony:const -// and http://wiki.ecmascript.org/doku.php?id=harmony:let -function parseConstLetDeclaration(kind) { - var declarations, - marker = markerCreate(); - - expectKeyword(kind); - - declarations = parseVariableDeclarationList(kind); - - consumeSemicolon(); - - return markerApply(marker, astNodeFactory.createVariableDeclaration(declarations, kind)); -} - - -function parseRestElement() { - var param, - marker = markerCreate(); - - lex(); - - if (match("{")) { - throwError(lookahead, Messages.ObjectPatternAsRestParameter); - } - - param = parseVariableIdentifier(); - - if (match("=")) { - throwError(lookahead, Messages.DefaultRestParameter); - } - - if (!match(")")) { - throwError(lookahead, Messages.ParameterAfterRestParameter); - } - - return markerApply(marker, astNodeFactory.createRestElement(param)); -} - -// 12.3 Empty Statement - -function parseEmptyStatement() { - expect(";"); - return astNodeFactory.createEmptyStatement(); -} - -// 12.4 Expression Statement - -function parseExpressionStatement() { - var expr = parseExpression(); - consumeSemicolon(); - return astNodeFactory.createExpressionStatement(expr); -} - -// 12.5 If statement - -function parseIfStatement() { - var test, consequent, alternate; - - expectKeyword("if"); - - expect("("); - - test = parseExpression(); - - expect(")"); - - consequent = parseStatement(); - - if (matchKeyword("else")) { - lex(); - alternate = parseStatement(); - } else { - alternate = null; - } - - return astNodeFactory.createIfStatement(test, consequent, alternate); -} - -// 12.6 Iteration Statements - -function parseDoWhileStatement() { - var body, test, oldInIteration; - - expectKeyword("do"); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); - - state.inIteration = oldInIteration; - - expectKeyword("while"); - - expect("("); - - test = parseExpression(); - - expect(")"); - - if (match(";")) { - lex(); - } - - return astNodeFactory.createDoWhileStatement(test, body); -} - -function parseWhileStatement() { - var test, body, oldInIteration; - - expectKeyword("while"); - - expect("("); - - test = parseExpression(); - - expect(")"); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); - - state.inIteration = oldInIteration; - - return astNodeFactory.createWhileStatement(test, body); -} - -function parseForVariableDeclaration() { - var token, declarations, - marker = markerCreate(); - - token = lex(); - declarations = parseVariableDeclarationList(); - - return markerApply(marker, astNodeFactory.createVariableDeclaration(declarations, token.value)); -} - -function parseForStatement(opts) { - var init, test, update, left, right, body, operator, oldInIteration; - var allowForOf = extra.ecmaFeatures.forOf, - allowBlockBindings = extra.ecmaFeatures.blockBindings; - - init = test = update = null; - - expectKeyword("for"); - - expect("("); - - if (match(";")) { - lex(); - } else { - - if (matchKeyword("var") || - (allowBlockBindings && (matchKeyword("let") || matchKeyword("const"))) - ) { - state.allowIn = false; - init = parseForVariableDeclaration(); - state.allowIn = true; - - if (init.declarations.length === 1) { - if (matchKeyword("in") || (allowForOf && matchContextualKeyword("of"))) { - operator = lookahead; - - // TODO: is "var" check here really needed? wasn"t in 1.2.2 - if (!((operator.value === "in" || init.kind !== "var") && init.declarations[0].init)) { - lex(); - left = init; - right = parseExpression(); - init = null; - } - } - } - - } else { - state.allowIn = false; - init = parseExpression(); - state.allowIn = true; - - if (init.type === astNodeTypes.ArrayExpression) { - init.type = astNodeTypes.ArrayPattern; - } - - - if (allowForOf && matchContextualKeyword("of")) { - operator = lex(); - left = init; - right = parseExpression(); - init = null; - } else if (matchKeyword("in")) { - // LeftHandSideExpression - if (!isLeftHandSide(init)) { - throwErrorTolerant({}, Messages.InvalidLHSInForIn); - } - - operator = lex(); - left = init; - right = parseExpression(); - init = null; - } - } - - if (typeof left === "undefined") { - expect(";"); - } - } - - if (typeof left === "undefined") { - - if (!match(";")) { - test = parseExpression(); - } - expect(";"); - - if (!match(")")) { - update = parseExpression(); - } - } - - expect(")"); - - oldInIteration = state.inIteration; - state.inIteration = true; - - if (!(opts !== undefined && opts.ignoreBody)) { - body = parseStatement(); - } - - state.inIteration = oldInIteration; - - if (typeof left === "undefined") { - return astNodeFactory.createForStatement(init, test, update, body); - } - - if (extra.ecmaFeatures.forOf && operator.value === "of") { - return astNodeFactory.createForOfStatement(left, right, body); - } - - return astNodeFactory.createForInStatement(left, right, body); -} - -// 12.7 The continue statement - -function parseContinueStatement() { - var label = null; - - expectKeyword("continue"); - - // Optimize the most common form: "continue;". - if (source.charCodeAt(index) === 0x3B) { - lex(); - - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return astNodeFactory.createContinueStatement(null); - } - - if (peekLineTerminator()) { - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return astNodeFactory.createContinueStatement(null); - } - - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); - - if (!state.labelSet.has(label.name)) { - throwError({}, Messages.UnknownLabel, label.name); - } - } - - consumeSemicolon(); - - if (label === null && !state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return astNodeFactory.createContinueStatement(label); -} - -// 12.8 The break statement - -function parseBreakStatement() { - var label = null; - - expectKeyword("break"); - - // Catch the very common case first: immediately a semicolon (U+003B). - if (source.charCodeAt(index) === 0x3B) { - lex(); - - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return astNodeFactory.createBreakStatement(null); - } - - if (peekLineTerminator()) { - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return astNodeFactory.createBreakStatement(null); - } - - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); - - if (!state.labelSet.has(label.name)) { - throwError({}, Messages.UnknownLabel, label.name); - } - } - - consumeSemicolon(); - - if (label === null && !(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return astNodeFactory.createBreakStatement(label); -} - -// 12.9 The return statement - -function parseReturnStatement() { - var argument = null; - - expectKeyword("return"); - - if (!state.inFunctionBody && !extra.ecmaFeatures.globalReturn) { - throwErrorTolerant({}, Messages.IllegalReturn); - } - - // "return" followed by a space and an identifier is very common. - if (source.charCodeAt(index) === 0x20) { - if (syntax.isIdentifierStart(source.charCodeAt(index + 1))) { - argument = parseExpression(); - consumeSemicolon(); - return astNodeFactory.createReturnStatement(argument); - } - } - - if (peekLineTerminator()) { - return astNodeFactory.createReturnStatement(null); - } - - if (!match(";")) { - if (!match("}") && lookahead.type !== Token.EOF) { - argument = parseExpression(); - } - } - - consumeSemicolon(); - - return astNodeFactory.createReturnStatement(argument); -} - -// 12.10 The with statement - -function parseWithStatement() { - var object, body; - - if (strict) { - // TODO(ikarienator): Should we update the test cases instead? - skipComment(); - throwErrorTolerant({}, Messages.StrictModeWith); - } - - expectKeyword("with"); - - expect("("); - - object = parseExpression(); - - expect(")"); - - body = parseStatement(); - - return astNodeFactory.createWithStatement(object, body); -} - -// 12.10 The swith statement - -function parseSwitchCase() { - var test, consequent = [], statement, - marker = markerCreate(); - - if (matchKeyword("default")) { - lex(); - test = null; - } else { - expectKeyword("case"); - test = parseExpression(); - } - expect(":"); - - while (index < length) { - if (match("}") || matchKeyword("default") || matchKeyword("case")) { - break; - } - statement = parseSourceElement(); - if (typeof statement === "undefined") { - break; - } - consequent.push(statement); - } - - return markerApply(marker, astNodeFactory.createSwitchCase(test, consequent)); -} - -function parseSwitchStatement() { - var discriminant, cases, clause, oldInSwitch, defaultFound; - - expectKeyword("switch"); - - expect("("); - - discriminant = parseExpression(); - - expect(")"); - - expect("{"); - - cases = []; - - if (match("}")) { - lex(); - return astNodeFactory.createSwitchStatement(discriminant, cases); - } - - oldInSwitch = state.inSwitch; - state.inSwitch = true; - defaultFound = false; - - while (index < length) { - if (match("}")) { - break; - } - clause = parseSwitchCase(); - if (clause.test === null) { - if (defaultFound) { - throwError({}, Messages.MultipleDefaultsInSwitch); - } - defaultFound = true; - } - cases.push(clause); - } - - state.inSwitch = oldInSwitch; - - expect("}"); - - return astNodeFactory.createSwitchStatement(discriminant, cases); -} - -// 12.13 The throw statement - -function parseThrowStatement() { - var argument; - - expectKeyword("throw"); - - if (peekLineTerminator()) { - throwError({}, Messages.NewlineAfterThrow); - } - - argument = parseExpression(); - - consumeSemicolon(); - - return astNodeFactory.createThrowStatement(argument); -} - -// 12.14 The try statement - -function parseCatchClause() { - var param, body, - marker = markerCreate(), - allowDestructuring = extra.ecmaFeatures.destructuring, - options = { - paramSet: new StringMap() - }; - - expectKeyword("catch"); - - expect("("); - if (match(")")) { - throwUnexpected(lookahead); - } - - if (match("[")) { - if (!allowDestructuring) { - throwUnexpected(lookahead); - } - param = parseArrayInitialiser(); - reinterpretAsDestructuredParameter(options, param); - } else if (match("{")) { - - if (!allowDestructuring) { - throwUnexpected(lookahead); - } - param = parseObjectInitialiser(); - reinterpretAsDestructuredParameter(options, param); - } else { - param = parseVariableIdentifier(); - } - - // 12.14.1 - if (strict && param.name && syntax.isRestrictedWord(param.name)) { - throwErrorTolerant({}, Messages.StrictCatchVariable); - } - - expect(")"); - body = parseBlock(); - return markerApply(marker, astNodeFactory.createCatchClause(param, body)); -} - -function parseTryStatement() { - var block, handler = null, finalizer = null; - - expectKeyword("try"); - - block = parseBlock(); - - if (matchKeyword("catch")) { - handler = parseCatchClause(); - } - - if (matchKeyword("finally")) { - lex(); - finalizer = parseBlock(); - } - - if (!handler && !finalizer) { - throwError({}, Messages.NoCatchOrFinally); - } - - return astNodeFactory.createTryStatement(block, handler, finalizer); -} - -// 12.15 The debugger statement - -function parseDebuggerStatement() { - expectKeyword("debugger"); - - consumeSemicolon(); - - return astNodeFactory.createDebuggerStatement(); -} - -// 12 Statements - -function parseStatement() { - var type = lookahead.type, - expr, - labeledBody, - marker; - - if (type === Token.EOF) { - throwUnexpected(lookahead); - } - - if (type === Token.Punctuator && lookahead.value === "{") { - return parseBlock(); - } - - marker = markerCreate(); - - if (type === Token.Punctuator) { - switch (lookahead.value) { - case ";": - return markerApply(marker, parseEmptyStatement()); - case "{": - return parseBlock(); - case "(": - return markerApply(marker, parseExpressionStatement()); - default: - break; - } - } - - marker = markerCreate(); - - if (type === Token.Keyword) { - switch (lookahead.value) { - case "break": - return markerApply(marker, parseBreakStatement()); - case "continue": - return markerApply(marker, parseContinueStatement()); - case "debugger": - return markerApply(marker, parseDebuggerStatement()); - case "do": - return markerApply(marker, parseDoWhileStatement()); - case "for": - return markerApply(marker, parseForStatement()); - case "function": - return markerApply(marker, parseFunctionDeclaration()); - case "if": - return markerApply(marker, parseIfStatement()); - case "return": - return markerApply(marker, parseReturnStatement()); - case "switch": - return markerApply(marker, parseSwitchStatement()); - case "throw": - return markerApply(marker, parseThrowStatement()); - case "try": - return markerApply(marker, parseTryStatement()); - case "var": - return markerApply(marker, parseVariableStatement()); - case "while": - return markerApply(marker, parseWhileStatement()); - case "with": - return markerApply(marker, parseWithStatement()); - default: - break; - } - } - - marker = markerCreate(); - expr = parseExpression(); - - // 12.12 Labelled Statements - if ((expr.type === astNodeTypes.Identifier) && match(":")) { - lex(); - - if (state.labelSet.has(expr.name)) { - throwError({}, Messages.Redeclaration, "Label", expr.name); - } - - state.labelSet.set(expr.name, true); - labeledBody = parseStatement(); - state.labelSet.delete(expr.name); - return markerApply(marker, astNodeFactory.createLabeledStatement(expr, labeledBody)); - } - - consumeSemicolon(); - - return markerApply(marker, astNodeFactory.createExpressionStatement(expr)); -} - -// 13 Function Definition - -// function parseConciseBody() { -// if (match("{")) { -// return parseFunctionSourceElements(); -// } -// return parseAssignmentExpression(); -// } - -function parseFunctionSourceElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted, - oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesisCount, - marker = markerCreate(); - - expect("{"); - - while (index < length) { - if (lookahead.type !== Token.StringLiteral) { - break; - } - token = lookahead; - - sourceElement = parseSourceElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== astNodeTypes.Literal) { - // this is not directive - break; - } - directive = source.slice(token.range[0] + 1, token.range[1] - 1); - if (directive === "use strict") { - strict = true; - - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } - } - - oldLabelSet = state.labelSet; - oldInIteration = state.inIteration; - oldInSwitch = state.inSwitch; - oldInFunctionBody = state.inFunctionBody; - oldParenthesisCount = state.parenthesisCount; - - state.labelSet = new StringMap(); - state.inIteration = false; - state.inSwitch = false; - state.inFunctionBody = true; - - while (index < length) { - - if (match("}")) { - break; - } - - sourceElement = parseSourceElement(); - - if (typeof sourceElement === "undefined") { - break; - } - - sourceElements.push(sourceElement); - } - - expect("}"); - - state.labelSet = oldLabelSet; - state.inIteration = oldInIteration; - state.inSwitch = oldInSwitch; - state.inFunctionBody = oldInFunctionBody; - state.parenthesisCount = oldParenthesisCount; - - return markerApply(marker, astNodeFactory.createBlockStatement(sourceElements)); -} - -function validateParam(options, param, name) { - - if (strict) { - if (syntax.isRestrictedWord(name)) { - options.stricted = param; - options.message = Messages.StrictParamName; - } - - if (options.paramSet.has(name)) { - options.stricted = param; - options.message = Messages.StrictParamDupe; - } - } else if (!options.firstRestricted) { - if (syntax.isRestrictedWord(name)) { - options.firstRestricted = param; - options.message = Messages.StrictParamName; - } else if (syntax.isStrictModeReservedWord(name, extra.ecmaFeatures)) { - options.firstRestricted = param; - options.message = Messages.StrictReservedWord; - } else if (options.paramSet.has(name)) { - options.firstRestricted = param; - options.message = Messages.StrictParamDupe; - } - } - options.paramSet.set(name, true); -} - -function parseParam(options) { - var token, param, def, - allowRestParams = extra.ecmaFeatures.restParams, - allowDestructuring = extra.ecmaFeatures.destructuring, - allowDefaultParams = extra.ecmaFeatures.defaultParams, - marker = markerCreate(); - - token = lookahead; - if (token.value === "...") { - if (!allowRestParams) { - throwUnexpected(lookahead); - } - param = parseRestElement(); - validateParam(options, param.argument, param.argument.name); - options.params.push(param); - return false; - } - - if (match("[")) { - if (!allowDestructuring) { - throwUnexpected(lookahead); - } - param = parseArrayInitialiser(); - reinterpretAsDestructuredParameter(options, param); - } else if (match("{")) { - if (!allowDestructuring) { - throwUnexpected(lookahead); - } - param = parseObjectInitialiser(); - reinterpretAsDestructuredParameter(options, param); - } else { - param = parseVariableIdentifier(); - validateParam(options, token, token.value); - } - - if (match("=")) { - if (allowDefaultParams || allowDestructuring) { - lex(); - def = parseAssignmentExpression(); - ++options.defaultCount; - } else { - throwUnexpected(lookahead); - } - } - - if (def) { - options.params.push(markerApply( - marker, - astNodeFactory.createAssignmentPattern( - param, - def - ) - )); - } else { - options.params.push(param); - } - - return !match(")"); -} - - -function parseParams(firstRestricted) { - var options; - - options = { - params: [], - defaultCount: 0, - firstRestricted: firstRestricted - }; - - expect("("); - - if (!match(")")) { - options.paramSet = new StringMap(); - while (index < length) { - if (!parseParam(options)) { - break; - } - expect(","); - } - } - - expect(")"); - - return { - params: options.params, - stricted: options.stricted, - firstRestricted: options.firstRestricted, - message: options.message - }; -} - -function parseFunctionDeclaration(identifierIsOptional) { - var id = null, body, token, tmp, firstRestricted, message, previousStrict, previousYieldAllowed, generator, - marker = markerCreate(), - allowGenerators = extra.ecmaFeatures.generators; - - expectKeyword("function"); - - generator = false; - if (allowGenerators && match("*")) { - lex(); - generator = true; - } - - if (!identifierIsOptional || !match("(")) { - - token = lookahead; - - id = parseVariableIdentifier(); - - if (strict) { - if (syntax.isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (syntax.isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (syntax.isStrictModeReservedWord(token.value, extra.ecmaFeatures)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } - } - } - - tmp = parseParams(firstRestricted); - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; - } +} - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = generator; - body = parseFunctionSourceElements(); - if (strict && firstRestricted) { - throwError(firstRestricted, message); - } - if (strict && tmp.stricted) { - throwErrorTolerant(tmp.stricted, message); - } - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - - return markerApply( - marker, - astNodeFactory.createFunctionDeclaration( - id, - tmp.params, - body, - generator, - false - ) - ); - } +var tt = acorn.tokTypes, + Parser = acorn.Parser, + pp = Parser.prototype, + getLineInfo = acorn.getLineInfo; -function parseFunctionExpression() { - var token, id = null, firstRestricted, message, tmp, body, previousStrict, previousYieldAllowed, generator, - marker = markerCreate(), - allowGenerators = extra.ecmaFeatures.generators; +// custom type for JSX attribute values +tt.jsxAttrValueToken = {}; - expectKeyword("function"); +function isValidNode(node) { + var ecma = extra.ecmaFeatures; - generator = false; + switch (node.type) { + case "Identifier": + return !ecma.modules || node.name !== "await"; - if (allowGenerators && match("*")) { - lex(); - generator = true; - } + case "VariableDeclaration": + return node.kind === "var" || ecma.blockBindings; - if (!match("(")) { - token = lookahead; - id = parseVariableIdentifier(); - if (strict) { - if (syntax.isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (syntax.isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (syntax.isStrictModeReservedWord(token.value, extra.ecmaFeatures)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } - } - } + case "ObjectPattern": + case "ArrayPattern": + return ecma.destructuring; - tmp = parseParams(firstRestricted); - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; - } + case "AssignmentPattern": + // TODO: enhance analysis for separate options + return ecma.destructuring || ecma.defaultParams; - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = generator; + case "RestElement": + // TODO: enhance analysis for separate options + return ecma.destructuring || ecma.restParams; - body = parseFunctionSourceElements(); + case "ForOfStatement": + return ecma.forOf; - if (strict && firstRestricted) { - throwError(firstRestricted, message); - } - if (strict && tmp.stricted) { - throwErrorTolerant(tmp.stricted, message); - } - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - - return markerApply( - marker, - astNodeFactory.createFunctionExpression( - id, - tmp.params, - body, - generator, - false - ) - ); -} + case "Property": + if (node.computed && !ecma.objectLiteralComputedProperties) { + return false; + } -function parseYieldExpression() { - var yieldToken, delegateFlag, expr, marker = markerCreate(); + if (node.method && !ecma.objectLiteralShorthandMethods) { + return false; + } - yieldToken = lex(); - assert(yieldToken.value === "yield", "Called parseYieldExpression with non-yield lookahead."); + if (node.shorthand) { + return ecma.objectLiteralShorthandProperties || ecma.destructuring; + } + // TODO: analyse for objectLiteralDuplicateProperties: false in ES6 + return true; - if (!state.yieldAllowed) { - throwErrorTolerant({}, Messages.IllegalYield); - } + case "FunctionExpression": + case "FunctionDeclaration": + if (node.generator && !ecma.generators) { + return false; + } + return true; - delegateFlag = false; - if (match("*")) { - lex(); - delegateFlag = true; - } + case "YieldExpression": + return ecma.generators; - if (peekLineTerminator()) { - return markerApply(marker, astNodeFactory.createYieldExpression(null, delegateFlag)); - } + // TODO: only use ecma.spread. For now, experimentalObjectRestSpread + // starts out as SpreadElement before being converted. + case "SpreadElement": + return ecma.spread || ecma.experimentalObjectRestSpread; - if (!match(";") && !match(")")) { - if (!match("}") && lookahead.type !== Token.EOF) { - expr = parseAssignmentExpression(); - } - } + case "ExperimentalSpreadProperty": + case "ExperimentalRestProperty": + return ecma.experimentalObjectRestSpread; - return markerApply(marker, astNodeFactory.createYieldExpression(expr, delegateFlag)); -} + case "ClassDeclaration": + case "ClassExpression": + return ecma.classes; -// Modules grammar from: -// people.mozilla.org/~jorendorff/es6-draft.html + case "Super": + return ecma.classes; -function parseModuleSpecifier() { - var marker = markerCreate(), - specifier; + case "ImportDeclaration": + case "ExportNamedDeclaration": + case "ExportDefaultDeclaration": + case "ExportAllDeclaration": + return ecma.modules; - if (lookahead.type !== Token.StringLiteral) { - throwError({}, Messages.InvalidModuleSpecifier); + default: + return true; } - specifier = astNodeFactory.createLiteralFromSource(lex(), source); - return markerApply(marker, specifier); } -function parseExportSpecifier() { - var exported, local, marker = markerCreate(); - if (matchKeyword("default")) { - lex(); - local = markerApply(marker, astNodeFactory.createIdentifier("default")); - // export {default} from "something"; - } else { - local = parseVariableIdentifier(); +function esprimaFinishNode(result) { + // ensure that parsed node was allowed through ecmaFeatures + if (!isValidNode(result)) { + this.unexpected(result.start); } - if (matchContextualKeyword("as")) { - lex(); - exported = parseNonComputedProperty(); + + // https://github.com/marijnh/acorn/issues/323 + if (result.type === "TryStatement") { + delete result.guardedHandlers; + } else if (result.type === "CatchClause") { + delete result.guard; } - return markerApply(marker, astNodeFactory.createExportSpecifier(local, exported)); -} -function parseExportNamedDeclaration() { - var declaration = null, - isExportFromIdentifier, - src = null, specifiers = [], - marker = markerCreate(); - - expectKeyword("export"); - - // non-default export - if (lookahead.type === Token.Keyword) { - // covers: - // export var f = 1; - switch (lookahead.value) { - case "let": - case "const": - case "var": - case "class": - case "function": - declaration = parseSourceElement(); - return markerApply(marker, astNodeFactory.createExportNamedDeclaration(declaration, specifiers, null)); - default: - break; + // https://github.com/marijnh/acorn/issues/324 + if (result.type === "MetaProperty") { + if (!this.inFunction) { + this.unexpected(result.start); } } - expect("{"); - if (!match("}")) { - do { - isExportFromIdentifier = isExportFromIdentifier || matchKeyword("default"); - specifiers.push(parseExportSpecifier()); - } while (match(",") && lex() && !match("}")); - } - expect("}"); - - if (matchContextualKeyword("from")) { - // covering: - // export {default} from "foo"; - // export {foo} from "foo"; - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - } else if (isExportFromIdentifier) { - // covering: - // export {default}; // missing fromClause - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); - } else { - // cover - // export {foo}; - consumeSemicolon(); - } - return markerApply(marker, astNodeFactory.createExportNamedDeclaration(declaration, specifiers, src)); -} + // Acorn doesn't count the opening and closing backticks as part of templates + // so we have to adjust ranges/locations appropriately. + if (result.type === "TemplateElement") { -function parseExportDefaultDeclaration() { - var declaration = null, - expression = null, - possibleIdentifierToken, - allowClasses = extra.ecmaFeatures.classes, - marker = markerCreate(); - - // covers: - // export default ... - expectKeyword("export"); - expectKeyword("default"); - - if (matchKeyword("function") || matchKeyword("class")) { - possibleIdentifierToken = lookahead2(); - if (possibleIdentifierToken.type === Token.Identifier) { - // covers: - // export default function foo () {} - // export default class foo {} - declaration = parseSourceElement(); - return markerApply(marker, astNodeFactory.createExportDefaultDeclaration(declaration)); - } - // covers: - // export default function () {} - // export default class {} - if (lookahead.value === "function") { - declaration = parseFunctionDeclaration(true); - return markerApply(marker, astNodeFactory.createExportDefaultDeclaration(declaration)); - } else if (allowClasses && lookahead.value === "class") { - declaration = parseClassDeclaration(true); - return markerApply(marker, astNodeFactory.createExportDefaultDeclaration(declaration)); + // additional adjustment needed if ${ is the last token + var terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === "${"; + + if (result.range) { + result.range[0]--; + result.range[1] += (terminalDollarBraceL ? 2 : 1); } - } - if (matchContextualKeyword("from")) { - throwError({}, Messages.UnexpectedToken, lookahead.value); + if (result.loc) { + result.loc.start.column--; + result.loc.end.column += (terminalDollarBraceL ? 2 : 1); + } } - // covers: - // export default {}; - // export default []; - // export default (1 + 2); - if (match("{")) { - expression = parseObjectInitialiser(); - } else if (match("[")) { - expression = parseArrayInitialiser(); - } else { - expression = parseAssignmentExpression(); + // Acorn currently uses expressions instead of declarations in default exports + if (result.type === "ExportDefaultDeclaration") { + if (/^(Class|Function)Expression$/.test(result.declaration.type)) { + result.declaration.type = result.declaration.type.replace("Expression", "Declaration"); + } } - consumeSemicolon(); - return markerApply(marker, astNodeFactory.createExportDefaultDeclaration(expression)); -} - -function parseExportAllDeclaration() { - var src, - marker = markerCreate(); - - // covers: - // export * from "foo"; - expectKeyword("export"); - expect("*"); - if (!matchContextualKeyword("from")) { - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); + // Acorn uses undefined instead of null, which affects serialization + if (result.type === "Literal" && result.value === undefined) { + result.value = null; } - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - return markerApply(marker, astNodeFactory.createExportAllDeclaration(src)); -} + // hide acorn-specific properties from comparison + // but leave for internal needs: + Object.defineProperties(result, { + start: { enumerable: false }, + end: { enumerable: false } + }); -function parseExportDeclaration() { - if (state.inFunctionBody) { - throwError({}, Messages.IllegalExportDeclaration); - } - var declarationType = lookahead2().value; - if (declarationType === "default") { - return parseExportDefaultDeclaration(); - } else if (declarationType === "*") { - return parseExportAllDeclaration(); - } else { - return parseExportNamedDeclaration(); + if (extra.attachComment) { + commentAttachment.processComment(result); } -} -function parseImportSpecifier() { - // import {} ...; - var local, imported, marker = markerCreate(); - - imported = parseNonComputedProperty(); - if (matchContextualKeyword("as")) { - lex(); - local = parseVariableIdentifier(); + if (result.type.indexOf("Function") > -1 && !result.generator) { + result.generator = false; } - return markerApply(marker, astNodeFactory.createImportSpecifier(local, imported)); -} - -function parseNamedImports() { - var specifiers = []; - // {foo, bar as bas} - expect("{"); - if (!match("}")) { - do { - specifiers.push(parseImportSpecifier()); - } while (match(",") && lex() && !match("}")); - } - expect("}"); - return specifiers; + return result; } -function parseImportDefaultSpecifier() { - // import ...; - var local, marker = markerCreate(); - - local = parseNonComputedProperty(); +function isValidToken(parser) { + var ecma = extra.ecmaFeatures; + var type = parser.type; - return markerApply(marker, astNodeFactory.createImportDefaultSpecifier(local)); -} - -function parseImportNamespaceSpecifier() { - // import <* as foo> ...; - var local, marker = markerCreate(); + switch (type) { + case tt.arrow: + return ecma.arrowFunctions; - expect("*"); - if (!matchContextualKeyword("as")) { - throwError({}, Messages.NoAsAfterImportNamespace); - } - lex(); - local = parseNonComputedProperty(); + case tt.num: + switch (parser.input.substr(parser.start, 2).toLowerCase()) { + case "0b": + return ecma.binaryLiterals; - return markerApply(marker, astNodeFactory.createImportNamespaceSpecifier(local)); -} + case "0o": + return ecma.octalLiterals; -function parseImportDeclaration() { - var specifiers, src, marker = markerCreate(); + default: + return true; + } + break; - if (state.inFunctionBody) { - throwError({}, Messages.IllegalImportDeclaration); - } + case tt.regexp: + var flags = parser.value.flags; + if (flags.indexOf("y") >= 0 && !ecma.regexYFlag) { + return false; + } + if (flags.indexOf("u") >= 0 && !ecma.regexUFlag) { + return false; + } + return true; - expectKeyword("import"); - specifiers = []; + case tt.ellipsis: + return ecma.restParams || ecma.spread || ecma.experimentalObjectRestSpread; - if (lookahead.type === Token.StringLiteral) { - // covers: - // import "foo"; - src = parseModuleSpecifier(); - consumeSemicolon(); - return markerApply(marker, astNodeFactory.createImportDeclaration(specifiers, src)); - } + case tt.backQuote: + case tt.template: + case tt.dollarBraceL: + return ecma.templateStrings; - if (!matchKeyword("default") && isIdentifierName(lookahead)) { - // covers: - // import foo - // import foo, ... - specifiers.push(parseImportDefaultSpecifier()); - if (match(",")) { - lex(); - } - } - if (match("*")) { - // covers: - // import foo, * as foo - // import * as foo - specifiers.push(parseImportNamespaceSpecifier()); - } else if (match("{")) { - // covers: - // import foo, {bar} - // import {bar} - specifiers = specifiers.concat(parseNamedImports()); - } + case tt.jsxName: + case tt.jsxText: + case tt.jsxTagStart: + case tt.jsxTagEnd: + return ecma.jsx; - if (!matchContextualKeyword("from")) { - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); + default: + return true; } - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - - return markerApply(marker, astNodeFactory.createImportDeclaration(specifiers, src)); } -// 14 Functions and classes - -// 14.1 Functions is defined above (13 in ES5) -// 14.2 Arrow Functions Definitions is defined in (7.3 assignments) - -// 14.3 Method Definitions -// 14.3.7 +function wrapFinishNode(finishNode) { + return function () { + var result = finishNode.apply(this, arguments); + return esprimaFinishNode.call(this, result); + }; +} -// 14.5 Class Definitions +pp.extend("finishNode", wrapFinishNode); -function parseClassBody() { - var hasConstructor = false, generator = false, - allowGenerators = extra.ecmaFeatures.generators, - token, isStatic, body = [], method, computed, key; +pp.extend("finishNodeAt", wrapFinishNode); - var existingProps = {}, - topMarker = markerCreate(), - marker; +pp.extend("next", function(next) { + return function () { + if (!isValidToken(this)) { + this.unexpected(); + } + return next.apply(this, arguments); + }; +}); - existingProps.static = new StringMap(); - existingProps.prototype = new StringMap(); +pp.extend("checkPropClash", function(checkPropClash) { - expect("{"); + return function() { + var ecmaVersion = this.options.ecmaVersion, + dupeProps = extra.ecmaFeatures.objectLiteralDuplicateProperties, + result; - while (!match("}")) { - // extra semicolons are fine - if (match(";")) { - lex(); - continue; + /* + * If duplicate properties are not allowed, switch back to ES5 mode for + * validating object properties. + */ + if (!dupeProps) { + this.options.ecmaVersion = 5; } - token = lookahead; - isStatic = false; - generator = match("*"); - computed = match("["); - marker = markerCreate(); + result = checkPropClash.apply(this, arguments); + this.options.ecmaVersion = ecmaVersion; + return result; + }; - if (generator) { - if (!allowGenerators) { - throwUnexpected(lookahead); - } - lex(); - } +}); - key = parseObjectPropertyKey(); +pp.extend("toAssignableList", function(toAssignableList) { - // static generator methods - if (key.name === "static" && match("*")) { - if (!allowGenerators) { - throwUnexpected(lookahead); + return function (exprList) { + if (exprList.length) { + var last = exprList[exprList.length - 1]; + + if ((last.type === "SpreadElement" && !extra.ecmaFeatures.destructuring) || + (last.type === "RestElement" && !extra.ecmaFeatures.restParams)) { + this.unexpected(last.start); } - generator = true; - lex(); } - if (key.name === "static" && lookaheadPropertyName()) { - token = lookahead; - isStatic = true; - computed = match("["); - key = parseObjectPropertyKey(); - } + return toAssignableList.apply(this, arguments); + }; +}); - if (generator) { - method = parseGeneratorProperty(key, marker); - } else { - method = tryParseMethodDefinition(token, key, computed, marker, generator); - } - if (method) { - method.static = isStatic; - if (method.kind === "init") { - method.kind = "method"; - } +// needed for experimental object rest/spread +pp.extend("checkLVal", function(checkLVal) { - if (!isStatic) { + return function(expr, isBinding, checkClashes) { - if (!method.computed && (method.key.name || (method.key.value && method.key.value.toString())) === "constructor") { - if (method.kind !== "method" || !method.method || method.value.generator) { - throwUnexpected(token, Messages.ConstructorSpecialMethod); - } - if (hasConstructor) { - throwUnexpected(token, Messages.DuplicateConstructor); - } else { - hasConstructor = true; - } - method.kind = "constructor"; - } - } else { - if (!method.computed && (method.key.name || method.key.value.toString()) === "prototype") { - throwUnexpected(token, Messages.StaticPrototype); + if (extra.ecmaFeatures.experimentalObjectRestSpread && expr.type === "ObjectPattern") { + for (var i = 0; i < expr.properties.length; i++) { + if (expr.properties[i].type.indexOf("Experimental") === -1) { + this.checkLVal(expr.properties[i].value, isBinding, checkClashes); } } - method.type = astNodeTypes.MethodDefinition; - delete method.method; - delete method.shorthand; - body.push(method); - } else { - throwUnexpected(lookahead); + return; } - } - - lex(); - return markerApply(topMarker, astNodeFactory.createClassBody(body)); -} - -function parseClassExpression() { - var id = null, superClass = null, marker = markerCreate(), - previousStrict = strict, classBody; - - // classes run in strict mode - strict = true; - expectKeyword("class"); - - if (lookahead.type === Token.Identifier) { - id = parseVariableIdentifier(); - } - - if (matchKeyword("extends")) { - lex(); - superClass = parseLeftHandSideExpressionAllowCall(); - } - - classBody = parseClassBody(); - strict = previousStrict; - - return markerApply(marker, astNodeFactory.createClassExpression(id, superClass, classBody)); -} - -function parseClassDeclaration(identifierIsOptional) { - var id = null, superClass = null, marker = markerCreate(), - previousStrict = strict, classBody; - - // classes run in strict mode - strict = true; - - expectKeyword("class"); - - if (!identifierIsOptional || lookahead.type === Token.Identifier) { - id = parseVariableIdentifier(); - } - - if (matchKeyword("extends")) { - lex(); - superClass = parseLeftHandSideExpressionAllowCall(); - } - - classBody = parseClassBody(); - strict = previousStrict; - - return markerApply(marker, astNodeFactory.createClassDeclaration(id, superClass, classBody)); -} - -// 15 Program - -function parseSourceElement() { + return checkLVal.apply(this, arguments); + }; +}); - var allowClasses = extra.ecmaFeatures.classes, - allowModules = extra.ecmaFeatures.modules, - allowBlockBindings = extra.ecmaFeatures.blockBindings; +pp.parseObjectRest = function () { + var node = this.startNode(); + this.next(); + node.argument = this.parseIdent(); + return this.finishNode(node, "ExperimentalRestProperty"); +}; - if (lookahead.type === Token.Keyword) { - switch (lookahead.value) { - case "export": - if (!allowModules) { - throwErrorTolerant({}, Messages.IllegalExportDeclaration); - } - return parseExportDeclaration(); - case "import": - if (!allowModules) { - throwErrorTolerant({}, Messages.IllegalImportDeclaration); - } - return parseImportDeclaration(); - case "function": - return parseFunctionDeclaration(); - case "class": - if (allowClasses) { - return parseClassDeclaration(); - } - break; - case "const": - case "let": - if (allowBlockBindings) { - return parseConstLetDeclaration(lookahead.value); - } - /* falls through */ - default: - return parseStatement(); - } - } - if (lookahead.type !== Token.EOF) { - return parseStatement(); - } -} +pp.parseObj = function (isPattern, refShorthandDefaultPos) { + var node = this.startNode(), + first = true, + propHash = {}; + node.properties = []; + this.next(); + while (!this.eat(tt.braceR)) { + if (!first) { + this.expect(tt.comma); + if (this.afterTrailingComma(tt.braceR)) break; + } else first = false; + + var prop = this.startNode(), + isGenerator = undefined, + startPos = undefined, + startLoc = undefined; + + if (extra.ecmaFeatures.experimentalObjectRestSpread && this.type === tt.ellipsis) { + if (isPattern) { + prop = this.parseObjectRest(); + } else { + prop = this.parseSpread(); + prop.type = "ExperimentalSpreadProperty"; + } + node.properties.push(prop); + continue; + } + + if (this.options.ecmaVersion >= 6) { + prop.method = false; + prop.shorthand = false; + if (isPattern || refShorthandDefaultPos) { + startPos = this.start; + startLoc = this.startLoc; + } + if (!isPattern) isGenerator = this.eat(tt.star); + } + this.parsePropertyName(prop); + this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos); + this.checkPropClash(prop, propHash); + node.properties.push(this.finishNode(prop, "Property")); + } + return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression"); +}; -function parseSourceElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted; - while (index < length) { - token = lookahead; - if (token.type !== Token.StringLiteral) { - break; - } +pp.raise = function(pos, message) { + var loc = getLineInfo(this.input, pos); + var err = new SyntaxError(message); + err.index = pos; + err.lineNumber = loc.line; + err.column = loc.column + 1; // acorn uses 0-based columns + throw err; +}; - sourceElement = parseSourceElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== astNodeTypes.Literal) { - // this is not directive - break; - } - directive = source.slice(token.range[0] + 1, token.range[1] - 1); - if (directive === "use strict") { - strict = true; - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; +pp.unexpected = function(pos) { + var message = "Unexpected token"; + if (pos != null) { + this.pos = pos; + if (this.options.locations) { + while (this.pos < this.lineStart) { + this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1; + --this.curLine; } } + this.nextToken(); } - - while (index < length) { - sourceElement = parseSourceElement(); - /* istanbul ignore if */ - if (typeof sourceElement === "undefined") { - break; - } - sourceElements.push(sourceElement); + if (this.end > this.start) { + message += " " + this.input.slice(this.start, this.end); } - return sourceElements; -} - -function parseProgram() { - var body, - marker, - isModule = !!extra.ecmaFeatures.modules; - - skipComment(); - peek(); - marker = markerCreate(); - strict = isModule; - - body = parseSourceElements(); - return markerApply(marker, astNodeFactory.createProgram(body, isModule ? "module" : "script")); -} - -function filterTokenLocation() { - var i, entry, token, tokens = []; + this.raise(this.start, message); +}; - for (i = 0; i < extra.tokens.length; ++i) { - entry = extra.tokens[i]; - token = { - type: entry.type, - value: entry.value - }; - if (entry.regex) { - token.regex = { - pattern: entry.regex.pattern, - flags: entry.regex.flags - }; - } - if (extra.range) { - token.range = entry.range; - } - if (extra.loc) { - token.loc = entry.loc; +/* + * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX + * uses regular tt.string without any distinction between this and regular JS + * strings. As such, we intercept an attempt to read a JSX string and set a flag + * on extra so that when tokens are converted, the next token will be switched + * to JSXText via onToken. + */ +pp.extend("jsx_readString", function(jsxReadString) { + return function() { + var result = jsxReadString.apply(this, arguments); + if (this.type === tt.string) { + extra.jsxAttrValueToken = true; } - tokens.push(token); - } - extra.tokens = tokens; -} + return result; + } +}); //------------------------------------------------------------------------------ // Tokenizer @@ -5274,101 +474,69 @@ function filterTokenLocation() { function tokenize(code, options) { var toString, - tokens; + tokens, + translator = new TokenTranslator(tt, code); toString = String; if (typeof code !== "string" && !(code instanceof String)) { code = toString(code); } - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; lookahead = null; - state = { - allowIn: true, - labelSet: {}, - parenthesisCount: 0, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - lastCommentStart: -1, - yieldAllowed: false, - curlyStack: [], - curlyLastIndex: 0, - inJSXSpreadAttribute: false, - inJSXChild: false, - inJSXTag: false - }; - - extra = { - ecmaFeatures: defaultFeatures - }; // Options matching. options = options || {}; + var acornOptions = { + ecmaVersion: 6 + }; + + resetExtra(); + // Of course we collect tokens here. options.tokens = true; extra.tokens = []; - extra.tokenize = true; - - // The following two fields are necessary to compute the Regex tokens. - extra.openParenToken = -1; - extra.openCurlyToken = -1; extra.range = (typeof options.range === "boolean") && options.range; + acornOptions.ranges = extra.range; + extra.loc = (typeof options.loc === "boolean") && options.loc; + acornOptions.locations = extra.loc; - if (typeof options.comment === "boolean" && options.comment) { - extra.comments = []; - } - if (typeof options.tolerant === "boolean" && options.tolerant) { - extra.errors = []; + extra.comment = typeof options.comment === "boolean" && options.comment; + + if (extra.comment) { + acornOptions.onComment = function() { + var comment = convertAcornCommentToEsprimaComment.apply(this, arguments); + extra.comments.push(comment); + }; } + extra.tolerant = typeof options.tolerant === "boolean" && options.tolerant; + // apply parsing flags if (options.ecmaFeatures && typeof options.ecmaFeatures === "object") { extra.ecmaFeatures = options.ecmaFeatures; } try { - peek(); - if (lookahead.type === Token.EOF) { - return extra.tokens; - } + var tokenizer = acorn.tokenizer(code, acornOptions); - lex(); - while (lookahead.type !== Token.EOF) { - try { - lex(); - } catch (lexError) { - if (extra.errors) { - extra.errors.push(lexError); - // We have to break on the first error - // to avoid infinite loops. - break; - } else { - throw lexError; - } - } + while ((lookahead = tokenizer.getToken()).type !== tt.eof) { + translator.onToken(lookahead, extra); } - filterTokenLocation(); + // filterTokenLocation(); tokens = extra.tokens; - if (typeof extra.comments !== "undefined") { + if (extra.comment) { tokens.comments = extra.comments; } - if (typeof extra.errors !== "undefined") { + if (extra.tolerant) { tokens.errors = extra.errors; } } catch (e) { throw e; - } finally { - extra = {}; } return tokens; } @@ -5377,42 +545,44 @@ function tokenize(code, options) { // Parser //------------------------------------------------------------------------------ + + + +function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) { + var comment = { + type: block ? "Block" : "Line", + value: text + }; + + if (typeof start === "number") { + comment.range = [start, end]; + } + + if (typeof startLoc === "object") { + comment.loc = { + start: startLoc, + end: endLoc + }; + } + + return comment; +} + function parse(code, options) { - var program, toString; - toString = String; + var program, + toString = String, + translator, + acornOptions = { + ecmaVersion: 5 + }; + if (typeof code !== "string" && !(code instanceof String)) { code = toString(code); } - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; - lookahead = null; - state = { - allowIn: true, - labelSet: new StringMap(), - parenthesisCount: 0, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - lastCommentStart: -1, - yieldAllowed: false, - curlyStack: [], - curlyLastIndex: 0, - inJSXSpreadAttribute: false, - inJSXChild: false, - inJSXTag: false - }; - - extra = { - ecmaFeatures: Object.create(defaultFeatures) - }; - - // for template strings - state.curlyStack = []; + resetExtra(); + commentAttachment.reset(); if (typeof options !== "undefined") { extra.range = (typeof options.range === "boolean") && options.range; @@ -5425,6 +595,7 @@ function parse(code, options) { if (typeof options.tokens === "boolean" && options.tokens) { extra.tokens = []; + translator = new TokenTranslator(tt, code); } if (typeof options.comment === "boolean" && options.comment) { extra.comments = []; @@ -5441,60 +612,120 @@ function parse(code, options) { if (options.sourceType === "module") { extra.ecmaFeatures = { arrowFunctions: true, - blockBindings: true, - regexUFlag: true, - regexYFlag: true, - templateStrings: true, binaryLiterals: true, - octalLiterals: true, - unicodeCodePointEscapes: true, - superInFunctions: true, - defaultParams: true, - restParams: true, + blockBindings: true, + classes: true, + destructuring: true, forOf: true, + generators: true, + modules: true, objectLiteralComputedProperties: true, + objectLiteralDuplicateProperties: true, objectLiteralShorthandMethods: true, objectLiteralShorthandProperties: true, - objectLiteralDuplicateProperties: true, - generators: true, - destructuring: true, - classes: true, - modules: true, - newTarget: true + octalLiterals: true, + regexUFlag: true, + regexYFlag: true, + restParams: true, + spread: true, + templateStrings: true, + unicodeCodePointEscapes: true, }; + acornOptions.ecmaVersion = 6; + acornOptions.sourceType = "module"; } // apply parsing flags after sourceType to allow overriding if (options.ecmaFeatures && typeof options.ecmaFeatures === "object") { + var flags = Object.keys(options.ecmaFeatures); + // if it's a module, augment the ecmaFeatures - if (options.sourceType === "module") { - Object.keys(options.ecmaFeatures).forEach(function(key) { - extra.ecmaFeatures[key] = options.ecmaFeatures[key]; - }); - } else { - extra.ecmaFeatures = options.ecmaFeatures; - } + flags.forEach(function(key) { + var value = extra.ecmaFeatures[key] = options.ecmaFeatures[key]; + + if (value) { + switch (key) { + case "globalReturn": + acornOptions.allowReturnOutsideFunction = true; + break; + + case "modules": + acornOptions.sourceType = "module"; + // falls through + + default: + acornOptions.ecmaVersion = 6; + } + } + }); + } - } - try { - program = parseProgram(); - if (typeof extra.comments !== "undefined") { - program.comments = extra.comments; + acornOptions.onToken = function(token) { + if (extra.tokens) { + translator.onToken(token, extra); + } + + if (token.type !== tt.eof) { + lastToken = token; + } + }; + + if (extra.attachComment || extra.comment) { + acornOptions.onComment = function() { + var comment = convertAcornCommentToEsprimaComment.apply(this, arguments); + extra.comments.push(comment); + + if (extra.attachComment) { + commentAttachment.addComment(comment); + } + }; } - if (typeof extra.tokens !== "undefined") { - filterTokenLocation(); - program.tokens = extra.tokens; + + if (extra.range) { + acornOptions.ranges = true; + } + + if (extra.loc) { + acornOptions.locations = true; } - if (typeof extra.errors !== "undefined") { - program.errors = extra.errors; + + if (extra.ecmaFeatures.jsx) { + if (extra.ecmaFeatures.spread !== false) { + extra.ecmaFeatures.spread = true; + } + acornOptions.plugins = { jsx: true }; } - } catch (e) { - throw e; - } finally { - extra = {}; + } + + program = acorn.parse(code, acornOptions); + program.sourceType = extra.ecmaFeatures.modules ? "module" : "script"; + + if (extra.comment || extra.attachComment) { + program.comments = extra.comments; + } + + if (extra.tokens) { + program.tokens = extra.tokens; + } + + /* + * Adjust opening and closing position of program to match Esprima. + * Acorn always starts programs at range 0 whereas Esprima starts at the + * first AST node's start (the only real difference is when there's leading + * whitespace or leading comments). Acorn also counts trailing whitespace + * as part of the program whereas Esprima only counts up to the last token. + */ + if (program.range) { + program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0]; + program.range[1] = lastToken.range[1]; + } + + if (program.loc) { + program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start; + program.loc.end = lastToken.loc.end; } return program; diff --git a/lib/ast-node-factory.js b/lib/ast-node-factory.js deleted file mode 100644 index 8d867393..00000000 --- a/lib/ast-node-factory.js +++ /dev/null @@ -1,964 +0,0 @@ -/** - * @fileoverview A factory for creating AST nodes - * @author Fred K. Schott - * @copyright 2014 Fred K. Schott. All rights reserved. - * @copyright 2011-2013 Ariya Hidayat - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -var astNodeTypes = require("./ast-node-types"); - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -module.exports = { - - /** - * Create an Array Expression ASTNode out of an array of elements - * @param {ASTNode[]} elements An array of ASTNode elements - * @returns {ASTNode} An ASTNode representing the entire array expression - */ - createArrayExpression: function(elements) { - return { - type: astNodeTypes.ArrayExpression, - elements: elements - }; - }, - - /** - * Create an Arrow Function Expression ASTNode - * @param {ASTNode} params The function arguments - * @param {ASTNode} body The function body - * @param {boolean} expression True if the arrow function is created via an expression. - * Always false for declarations, but kept here to be in sync with - * FunctionExpression objects. - * @returns {ASTNode} An ASTNode representing the entire arrow function expression - */ - createArrowFunctionExpression: function (params, body, expression) { - return { - type: astNodeTypes.ArrowFunctionExpression, - id: null, - params: params, - body: body, - generator: false, - expression: expression - }; - }, - - /** - * Create an ASTNode representation of an assignment expression - * @param {ASTNode} operator The assignment operator - * @param {ASTNode} left The left operand - * @param {ASTNode} right The right operand - * @returns {ASTNode} An ASTNode representing the entire assignment expression - */ - createAssignmentExpression: function(operator, left, right) { - return { - type: astNodeTypes.AssignmentExpression, - operator: operator, - left: left, - right: right - }; - }, - - /** - * Create an ASTNode representation of an assignment pattern (default parameters) - * @param {ASTNode} left The left operand - * @param {ASTNode} right The right operand - * @returns {ASTNode} An ASTNode representing the entire assignment pattern - */ - createAssignmentPattern: function(left, right) { - return { - type: astNodeTypes.AssignmentPattern, - left: left, - right: right - }; - }, - - /** - * Create an ASTNode representation of a binary expression - * @param {ASTNode} operator The assignment operator - * @param {ASTNode} left The left operand - * @param {ASTNode} right The right operand - * @returns {ASTNode} An ASTNode representing the entire binary expression - */ - createBinaryExpression: function(operator, left, right) { - var type = (operator === "||" || operator === "&&") ? astNodeTypes.LogicalExpression : - astNodeTypes.BinaryExpression; - return { - type: type, - operator: operator, - left: left, - right: right - }; - }, - - /** - * Create an ASTNode representation of a block statement - * @param {ASTNode} body The block statement body - * @returns {ASTNode} An ASTNode representing the entire block statement - */ - createBlockStatement: function(body) { - return { - type: astNodeTypes.BlockStatement, - body: body - }; - }, - - /** - * Create an ASTNode representation of a break statement - * @param {ASTNode} label The break statement label - * @returns {ASTNode} An ASTNode representing the break statement - */ - createBreakStatement: function(label) { - return { - type: astNodeTypes.BreakStatement, - label: label - }; - }, - - /** - * Create an ASTNode representation of a call expression - * @param {ASTNode} callee The function being called - * @param {ASTNode[]} args An array of ASTNodes representing the function call arguments - * @returns {ASTNode} An ASTNode representing the entire call expression - */ - createCallExpression: function(callee, args) { - return { - type: astNodeTypes.CallExpression, - callee: callee, - "arguments": args - }; - }, - - /** - * Create an ASTNode representation of a catch clause/block - * @param {ASTNode} param Any catch clause exeption/conditional parameter information - * @param {ASTNode} body The catch block body - * @returns {ASTNode} An ASTNode representing the entire catch clause - */ - createCatchClause: function(param, body) { - return { - type: astNodeTypes.CatchClause, - param: param, - body: body - }; - }, - - /** - * Creates an ASTNode representation of a class body. - * @param {ASTNode} body The node representing the body of the class. - * @returns {ASTNode} An ASTNode representing the class body. - */ - createClassBody: function(body) { - return { - type: astNodeTypes.ClassBody, - body: body - }; - }, - - createClassExpression: function(id, superClass, body) { - return { - type: astNodeTypes.ClassExpression, - id: id, - superClass: superClass, - body: body - }; - }, - - createClassDeclaration: function(id, superClass, body) { - return { - type: astNodeTypes.ClassDeclaration, - id: id, - superClass: superClass, - body: body - }; - }, - - createMethodDefinition: function(propertyType, kind, key, value, computed) { - return { - type: astNodeTypes.MethodDefinition, - key: key, - value: value, - kind: kind, - "static": propertyType === "static", - computed: computed - }; - }, - - createMetaProperty: function(meta, property) { - return { - type: astNodeTypes.MetaProperty, - meta: meta, - property: property - }; - }, - - /** - * Create an ASTNode representation of a conditional expression - * @param {ASTNode} test The conditional to evaluate - * @param {ASTNode} consequent The code to be run if the test returns true - * @param {ASTNode} alternate The code to be run if the test returns false - * @returns {ASTNode} An ASTNode representing the entire conditional expression - */ - createConditionalExpression: function(test, consequent, alternate) { - return { - type: astNodeTypes.ConditionalExpression, - test: test, - consequent: consequent, - alternate: alternate - }; - }, - - /** - * Create an ASTNode representation of a continue statement - * @param {?ASTNode} label The optional continue label (null if not set) - * @returns {ASTNode} An ASTNode representing the continue statement - */ - createContinueStatement: function(label) { - return { - type: astNodeTypes.ContinueStatement, - label: label - }; - }, - - /** - * Create an ASTNode representation of a debugger statement - * @returns {ASTNode} An ASTNode representing the debugger statement - */ - createDebuggerStatement: function() { - return { - type: astNodeTypes.DebuggerStatement - }; - }, - - /** - * Create an ASTNode representation of an empty statement - * @returns {ASTNode} An ASTNode representing an empty statement - */ - createEmptyStatement: function() { - return { - type: astNodeTypes.EmptyStatement - }; - }, - - /** - * Create an ASTNode representation of an expression statement - * @param {ASTNode} expression The expression - * @returns {ASTNode} An ASTNode representing an expression statement - */ - createExpressionStatement: function(expression) { - return { - type: astNodeTypes.ExpressionStatement, - expression: expression - }; - }, - - /** - * Create an ASTNode representation of a while statement - * @param {ASTNode} test The while conditional - * @param {ASTNode} body The while loop body - * @returns {ASTNode} An ASTNode representing a while statement - */ - createWhileStatement: function(test, body) { - return { - type: astNodeTypes.WhileStatement, - test: test, - body: body - }; - }, - - /** - * Create an ASTNode representation of a do..while statement - * @param {ASTNode} test The do..while conditional - * @param {ASTNode} body The do..while loop body - * @returns {ASTNode} An ASTNode representing a do..while statement - */ - createDoWhileStatement: function(test, body) { - return { - type: astNodeTypes.DoWhileStatement, - body: body, - test: test - }; - }, - - /** - * Create an ASTNode representation of a for statement - * @param {ASTNode} init The initialization expression - * @param {ASTNode} test The conditional test expression - * @param {ASTNode} update The update expression - * @param {ASTNode} body The statement body - * @returns {ASTNode} An ASTNode representing a for statement - */ - createForStatement: function(init, test, update, body) { - return { - type: astNodeTypes.ForStatement, - init: init, - test: test, - update: update, - body: body - }; - }, - - /** - * Create an ASTNode representation of a for..in statement - * @param {ASTNode} left The left-side variable for the property name - * @param {ASTNode} right The right-side object - * @param {ASTNode} body The statement body - * @returns {ASTNode} An ASTNode representing a for..in statement - */ - createForInStatement: function(left, right, body) { - return { - type: astNodeTypes.ForInStatement, - left: left, - right: right, - body: body, - each: false - }; - }, - - /** - * Create an ASTNode representation of a for..of statement - * @param {ASTNode} left The left-side variable for the property value - * @param {ASTNode} right The right-side object - * @param {ASTNode} body The statement body - * @returns {ASTNode} An ASTNode representing a for..of statement - */ - createForOfStatement: function(left, right, body) { - return { - type: astNodeTypes.ForOfStatement, - left: left, - right: right, - body: body - }; - }, - - /** - * Create an ASTNode representation of a function declaration - * @param {ASTNode} id The function name - * @param {ASTNode} params The function arguments - * @param {ASTNode} body The function body - * @param {boolean} generator True if the function is a generator, false if not. - * @param {boolean} expression True if the function is created via an expression. - * Always false for declarations, but kept here to be in sync with - * FunctionExpression objects. - * @returns {ASTNode} An ASTNode representing a function declaration - */ - createFunctionDeclaration: function (id, params, body, generator, expression) { - return { - type: astNodeTypes.FunctionDeclaration, - id: id, - params: params || [], - body: body, - generator: !!generator, - expression: !!expression - }; - }, - - /** - * Create an ASTNode representation of a function expression - * @param {ASTNode} id The function name - * @param {ASTNode} params The function arguments - * @param {ASTNode} body The function body - * @param {boolean} generator True if the function is a generator, false if not. - * @param {boolean} expression True if the function is created via an expression. - * @returns {ASTNode} An ASTNode representing a function declaration - */ - createFunctionExpression: function (id, params, body, generator, expression) { - return { - type: astNodeTypes.FunctionExpression, - id: id, - params: params || [], - body: body, - generator: !!generator, - expression: !!expression - }; - }, - - /** - * Create an ASTNode representation of an identifier - * @param {ASTNode} name The identifier name - * @returns {ASTNode} An ASTNode representing an identifier - */ - createIdentifier: function(name) { - return { - type: astNodeTypes.Identifier, - name: name - }; - }, - - /** - * Create an ASTNode representation of an if statement - * @param {ASTNode} test The if conditional expression - * @param {ASTNode} consequent The consequent if statement to run - * @param {ASTNode} alternate the "else" alternate statement - * @returns {ASTNode} An ASTNode representing an if statement - */ - createIfStatement: function(test, consequent, alternate) { - return { - type: astNodeTypes.IfStatement, - test: test, - consequent: consequent, - alternate: alternate - }; - }, - - /** - * Create an ASTNode representation of a labeled statement - * @param {ASTNode} label The statement label - * @param {ASTNode} body The labeled statement body - * @returns {ASTNode} An ASTNode representing a labeled statement - */ - createLabeledStatement: function(label, body) { - return { - type: astNodeTypes.LabeledStatement, - label: label, - body: body - }; - }, - - /** - * Create an ASTNode literal from the source code - * @param {ASTNode} token The ASTNode token - * @param {string} source The source code to get the literal from - * @returns {ASTNode} An ASTNode representing the new literal - */ - createLiteralFromSource: function(token, source) { - var node = { - type: astNodeTypes.Literal, - value: token.value, - raw: source.slice(token.range[0], token.range[1]) - }; - - // regular expressions have regex properties - if (token.regex) { - node.regex = token.regex; - } - - return node; - }, - - /** - * Create an ASTNode template element - * @param {Object} value Data on the element value - * @param {string} value.raw The raw template string - * @param {string} value.cooked The processed template string - * @param {boolean} tail True if this is the final element in a template string - * @returns {ASTNode} An ASTNode representing the template string element - */ - createTemplateElement: function(value, tail) { - return { - type: astNodeTypes.TemplateElement, - value: value, - tail: tail - }; - }, - - /** - * Create an ASTNode template literal - * @param {ASTNode[]} quasis An array of the template string elements - * @param {ASTNode[]} expressions An array of the template string expressions - * @returns {ASTNode} An ASTNode representing the template string - */ - createTemplateLiteral: function(quasis, expressions) { - return { - type: astNodeTypes.TemplateLiteral, - quasis: quasis, - expressions: expressions - }; - }, - - /** - * Create an ASTNode representation of a spread element - * @param {ASTNode} argument The array being spread - * @returns {ASTNode} An ASTNode representing a spread element - */ - createSpreadElement: function(argument) { - return { - type: astNodeTypes.SpreadElement, - argument: argument - }; - }, - - /** - * Create an ASTNode representation of an experimental rest property - * @param {ASTNode} argument The identifier being rested - * @returns {ASTNode} An ASTNode representing a rest element - */ - createExperimentalRestProperty: function(argument) { - return { - type: astNodeTypes.ExperimentalRestProperty, - argument: argument - }; - }, - - /** - * Create an ASTNode representation of an experimental spread property - * @param {ASTNode} argument The identifier being spread - * @returns {ASTNode} An ASTNode representing a spread element - */ - createExperimentalSpreadProperty: function(argument) { - return { - type: astNodeTypes.ExperimentalSpreadProperty, - argument: argument - }; - }, - - /** - * Create an ASTNode tagged template expression - * @param {ASTNode} tag The tag expression - * @param {ASTNode} quasi A TemplateLiteral ASTNode representing - * the template string itself. - * @returns {ASTNode} An ASTNode representing the tagged template - */ - createTaggedTemplateExpression: function(tag, quasi) { - return { - type: astNodeTypes.TaggedTemplateExpression, - tag: tag, - quasi: quasi - }; - }, - - /** - * Create an ASTNode representation of a member expression - * @param {string} accessor The member access method (bracket or period) - * @param {ASTNode} object The object being referenced - * @param {ASTNode} property The object-property being referenced - * @returns {ASTNode} An ASTNode representing a member expression - */ - createMemberExpression: function(accessor, object, property) { - return { - type: astNodeTypes.MemberExpression, - computed: accessor === "[", - object: object, - property: property - }; - }, - - /** - * Create an ASTNode representation of a new expression - * @param {ASTNode} callee The constructor for the new object type - * @param {ASTNode} args The arguments passed to the constructor - * @returns {ASTNode} An ASTNode representing a new expression - */ - createNewExpression: function(callee, args) { - return { - type: astNodeTypes.NewExpression, - callee: callee, - "arguments": args - }; - }, - - /** - * Create an ASTNode representation of a new object expression - * @param {ASTNode[]} properties An array of ASTNodes that represent all object - * properties and associated values - * @returns {ASTNode} An ASTNode representing a new object expression - */ - createObjectExpression: function(properties) { - return { - type: astNodeTypes.ObjectExpression, - properties: properties - }; - }, - - /** - * Create an ASTNode representation of a postfix expression - * @param {string} operator The postfix operator ("++", "--", etc.) - * @param {ASTNode} argument The operator argument - * @returns {ASTNode} An ASTNode representing a postfix expression - */ - createPostfixExpression: function(operator, argument) { - return { - type: astNodeTypes.UpdateExpression, - operator: operator, - argument: argument, - prefix: false - }; - }, - - /** - * Create an ASTNode representation of an entire program - * @param {ASTNode} body The program body - * @param {string} sourceType Either "module" or "script". - * @returns {ASTNode} An ASTNode representing an entire program - */ - createProgram: function(body, sourceType) { - return { - type: astNodeTypes.Program, - body: body, - sourceType: sourceType - }; - }, - - /** - * Create an ASTNode representation of an object property - * @param {string} kind The type of property represented ("get", "set", etc.) - * @param {ASTNode} key The property key - * @param {ASTNode} value The new property value - * @param {boolean} method True if the property is also a method (value is a function) - * @param {boolean} shorthand True if the property is shorthand - * @param {boolean} computed True if the property value has been computed - * @returns {ASTNode} An ASTNode representing an object property - */ - createProperty: function(kind, key, value, method, shorthand, computed) { - return { - type: astNodeTypes.Property, - key: key, - value: value, - kind: kind, - method: method, - shorthand: shorthand, - computed: computed - }; - }, - - /** - * Create an ASTNode representation of a rest element - * @param {ASTNode} argument The rest argument - * @returns {ASTNode} An ASTNode representing a rest element - */ - createRestElement: function (argument) { - return { - type: astNodeTypes.RestElement, - argument: argument - }; - }, - - /** - * Create an ASTNode representation of a return statement - * @param {?ASTNode} argument The return argument, null if no argument is provided - * @returns {ASTNode} An ASTNode representing a return statement - */ - createReturnStatement: function(argument) { - return { - type: astNodeTypes.ReturnStatement, - argument: argument - }; - }, - - /** - * Create an ASTNode representation of a sequence of expressions - * @param {ASTNode[]} expressions An array containing each expression, in order - * @returns {ASTNode} An ASTNode representing a sequence of expressions - */ - createSequenceExpression: function(expressions) { - return { - type: astNodeTypes.SequenceExpression, - expressions: expressions - }; - }, - - /** - * Create an ASTNode representation of super - * @returns {ASTNode} An ASTNode representing super - */ - createSuper: function() { - return { - type: astNodeTypes.Super - }; - }, - - /** - * Create an ASTNode representation of a switch case statement - * @param {ASTNode} test The case value to test against the switch value - * @param {ASTNode} consequent The consequent case statement - * @returns {ASTNode} An ASTNode representing a switch case - */ - createSwitchCase: function(test, consequent) { - return { - type: astNodeTypes.SwitchCase, - test: test, - consequent: consequent - }; - }, - - /** - * Create an ASTNode representation of a switch statement - * @param {ASTNode} discriminant An expression to test against each case value - * @param {ASTNode[]} cases An array of switch case statements - * @returns {ASTNode} An ASTNode representing a switch statement - */ - createSwitchStatement: function(discriminant, cases) { - return { - type: astNodeTypes.SwitchStatement, - discriminant: discriminant, - cases: cases - }; - }, - - /** - * Create an ASTNode representation of a this statement - * @returns {ASTNode} An ASTNode representing a this statement - */ - createThisExpression: function() { - return { - type: astNodeTypes.ThisExpression - }; - }, - - /** - * Create an ASTNode representation of a throw statement - * @param {ASTNode} argument The argument to throw - * @returns {ASTNode} An ASTNode representing a throw statement - */ - createThrowStatement: function(argument) { - return { - type: astNodeTypes.ThrowStatement, - argument: argument - }; - }, - - /** - * Create an ASTNode representation of a try statement - * @param {ASTNode} block The try block - * @param {ASTNode} handler A catch handler - * @param {?ASTNode} finalizer The final code block to run after the try/catch has run - * @returns {ASTNode} An ASTNode representing a try statement - */ - createTryStatement: function(block, handler, finalizer) { - return { - type: astNodeTypes.TryStatement, - block: block, - handler: handler, - finalizer: finalizer - }; - }, - - /** - * Create an ASTNode representation of a unary expression - * @param {string} operator The unary operator - * @param {ASTNode} argument The unary operand - * @returns {ASTNode} An ASTNode representing a unary expression - */ - createUnaryExpression: function(operator, argument) { - if (operator === "++" || operator === "--") { - return { - type: astNodeTypes.UpdateExpression, - operator: operator, - argument: argument, - prefix: true - }; - } - return { - type: astNodeTypes.UnaryExpression, - operator: operator, - argument: argument, - prefix: true - }; - }, - - /** - * Create an ASTNode representation of a variable declaration - * @param {ASTNode[]} declarations An array of variable declarations - * @param {string} kind The kind of variable created ("var", "let", etc.) - * @returns {ASTNode} An ASTNode representing a variable declaration - */ - createVariableDeclaration: function(declarations, kind) { - return { - type: astNodeTypes.VariableDeclaration, - declarations: declarations, - kind: kind - }; - }, - - /** - * Create an ASTNode representation of a variable declarator - * @param {ASTNode} id The variable ID - * @param {ASTNode} init The variable's initial value - * @returns {ASTNode} An ASTNode representing a variable declarator - */ - createVariableDeclarator: function(id, init) { - return { - type: astNodeTypes.VariableDeclarator, - id: id, - init: init - }; - }, - - /** - * Create an ASTNode representation of a with statement - * @param {ASTNode} object The with statement object expression - * @param {ASTNode} body The with statement body - * @returns {ASTNode} An ASTNode representing a with statement - */ - createWithStatement: function(object, body) { - return { - type: astNodeTypes.WithStatement, - object: object, - body: body - }; - }, - - createYieldExpression: function(argument, delegate) { - return { - type: astNodeTypes.YieldExpression, - argument: argument || null, - delegate: delegate - }; - }, - - createJSXAttribute: function(name, value) { - return { - type: astNodeTypes.JSXAttribute, - name: name, - value: value || null - }; - }, - - createJSXSpreadAttribute: function(argument) { - return { - type: astNodeTypes.JSXSpreadAttribute, - argument: argument - }; - }, - - createJSXIdentifier: function(name) { - return { - type: astNodeTypes.JSXIdentifier, - name: name - }; - }, - - createJSXNamespacedName: function(namespace, name) { - return { - type: astNodeTypes.JSXNamespacedName, - namespace: namespace, - name: name - }; - }, - - createJSXMemberExpression: function(object, property) { - return { - type: astNodeTypes.JSXMemberExpression, - object: object, - property: property - }; - }, - - createJSXElement: function(openingElement, closingElement, children) { - return { - type: astNodeTypes.JSXElement, - openingElement: openingElement, - closingElement: closingElement, - children: children - }; - }, - - createJSXEmptyExpression: function() { - return { - type: astNodeTypes.JSXEmptyExpression - }; - }, - - createJSXExpressionContainer: function(expression) { - return { - type: astNodeTypes.JSXExpressionContainer, - expression: expression - }; - }, - - createJSXOpeningElement: function(name, attributes, selfClosing) { - return { - type: astNodeTypes.JSXOpeningElement, - name: name, - selfClosing: selfClosing, - attributes: attributes - }; - }, - - createJSXClosingElement: function(name) { - return { - type: astNodeTypes.JSXClosingElement, - name: name - }; - }, - - createExportSpecifier: function(local, exported) { - return { - type: astNodeTypes.ExportSpecifier, - exported: exported || local, - local: local - }; - }, - - createImportDefaultSpecifier: function(local) { - return { - type: astNodeTypes.ImportDefaultSpecifier, - local: local - }; - }, - - createImportNamespaceSpecifier: function(local) { - return { - type: astNodeTypes.ImportNamespaceSpecifier, - local: local - }; - }, - - createExportNamedDeclaration: function(declaration, specifiers, source) { - return { - type: astNodeTypes.ExportNamedDeclaration, - declaration: declaration, - specifiers: specifiers, - source: source - }; - }, - - createExportDefaultDeclaration: function(declaration) { - return { - type: astNodeTypes.ExportDefaultDeclaration, - declaration: declaration - }; - }, - - createExportAllDeclaration: function(source) { - return { - type: astNodeTypes.ExportAllDeclaration, - source: source - }; - }, - - createImportSpecifier: function(local, imported) { - return { - type: astNodeTypes.ImportSpecifier, - local: local || imported, - imported: imported - }; - }, - - createImportDeclaration: function(specifiers, source) { - return { - type: astNodeTypes.ImportDeclaration, - specifiers: specifiers, - source: source - }; - } - -}; diff --git a/lib/features.js b/lib/features.js index 209137dc..850d675b 100644 --- a/lib/features.js +++ b/lib/features.js @@ -44,7 +44,7 @@ module.exports = { arrowFunctions: false, // enable parsing of let and const - blockBindings: true, + blockBindings: false, // enable parsing of destructured arrays and objects destructuring: false, @@ -94,9 +94,6 @@ module.exports = { // support the spread operator spread: false, - // enable super in functions - superInFunctions: false, - // enable parsing of classes classes: false, diff --git a/lib/messages.js b/lib/messages.js deleted file mode 100644 index b0f324f8..00000000 --- a/lib/messages.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @fileoverview Error messages returned by the parser. - * @author Nicholas C. Zakas - * @copyright 2014 Nicholas C. Zakas. All rights reserved. - * @copyright 2011-2013 Ariya Hidayat - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// None! - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -// error messages should be identical to V8 where possible -module.exports = { - UnexpectedToken: "Unexpected token %0", - UnexpectedNumber: "Unexpected number", - UnexpectedString: "Unexpected string", - UnexpectedIdentifier: "Unexpected identifier", - UnexpectedReserved: "Unexpected reserved word", - UnexpectedTemplate: "Unexpected quasi %0", - UnexpectedEOS: "Unexpected end of input", - NewlineAfterThrow: "Illegal newline after throw", - InvalidRegExp: "Invalid regular expression", - InvalidRegExpFlag: "Invalid regular expression flag", - UnterminatedRegExp: "Invalid regular expression: missing /", - InvalidLHSInAssignment: "Invalid left-hand side in assignment", - InvalidLHSInFormalsList: "Invalid left-hand side in formals list", - InvalidLHSInForIn: "Invalid left-hand side in for-in", - MultipleDefaultsInSwitch: "More than one default clause in switch statement", - NoCatchOrFinally: "Missing catch or finally after try", - NoUnintializedConst: "Const must be initialized", - UnknownLabel: "Undefined label '%0'", - Redeclaration: "%0 '%1' has already been declared", - IllegalContinue: "Illegal continue statement", - IllegalBreak: "Illegal break statement", - IllegalReturn: "Illegal return statement", - IllegalYield: "Illegal yield expression", - IllegalSpread: "Illegal spread element", - StrictModeWith: "Strict mode code may not include a with statement", - StrictCatchVariable: "Catch variable may not be eval or arguments in strict mode", - StrictVarName: "Variable name may not be eval or arguments in strict mode", - StrictParamName: "Parameter name eval or arguments is not allowed in strict mode", - StrictParamDupe: "Strict mode function may not have duplicate parameter names", - TemplateOctalLiteral: "Octal literals are not allowed in template strings.", - ParameterAfterRestParameter: "Rest parameter must be last formal parameter", - DefaultRestParameter: "Rest parameter can not have a default value", - ElementAfterSpreadElement: "Spread must be the final element of an element list", - ObjectPatternAsRestParameter: "Invalid rest parameter", - ObjectPatternAsSpread: "Invalid spread argument", - StrictFunctionName: "Function name may not be eval or arguments in strict mode", - StrictOctalLiteral: "Octal literals are not allowed in strict mode.", - StrictDelete: "Delete of an unqualified identifier in strict mode.", - StrictDuplicateProperty: "Duplicate data property in object literal not allowed in strict mode", - DuplicatePrototypeProperty: "Duplicate '__proto__' property in object literal are not allowed", - ConstructorSpecialMethod: "Class constructor may not be an accessor", - DuplicateConstructor: "A class may only have one constructor", - StaticPrototype: "Classes may not have static property named prototype", - AccessorDataProperty: "Object literal may not have data and accessor property with the same name", - AccessorGetSet: "Object literal may not have multiple get/set accessors with the same name", - StrictLHSAssignment: "Assignment to eval or arguments is not allowed in strict mode", - StrictLHSPostfix: "Postfix increment/decrement may not have eval or arguments operand in strict mode", - StrictLHSPrefix: "Prefix increment/decrement may not have eval or arguments operand in strict mode", - StrictReservedWord: "Use of future reserved word in strict mode", - InvalidJSXAttributeValue: "JSX value should be either an expression or a quoted JSX text", - ExpectedJSXClosingTag: "Expected corresponding JSX closing tag for %0", - AdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag", - MissingFromClause: "Missing from clause", - NoAsAfterImportNamespace: "Missing as after import *", - InvalidModuleSpecifier: "Invalid module specifier", - IllegalImportDeclaration: "Illegal import declaration", - IllegalExportDeclaration: "Illegal export declaration" -}; diff --git a/lib/string-map.js b/lib/string-map.js deleted file mode 100644 index 97c87032..00000000 --- a/lib/string-map.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @fileoverview A simple map that helps avoid collisions on the Object prototype. - * @author Jamund Ferguson - * @copyright 2015 Jamund Ferguson. All rights reserved. - * @copyright 2011-2013 Ariya Hidayat - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -function StringMap() { - this.$data = {}; -} - -StringMap.prototype.get = function (key) { - key = "$" + key; - return this.$data[key]; -}; - -StringMap.prototype.set = function (key, value) { - key = "$" + key; - this.$data[key] = value; - return this; -}; - -StringMap.prototype.has = function (key) { - key = "$" + key; - return Object.prototype.hasOwnProperty.call(this.$data, key); -}; - -StringMap.prototype.delete = function (key) { - key = "$" + key; - return delete this.$data[key]; -}; - -module.exports = StringMap; diff --git a/lib/syntax.js b/lib/syntax.js deleted file mode 100644 index b69754a8..00000000 --- a/lib/syntax.js +++ /dev/null @@ -1,189 +0,0 @@ -/** - * @fileoverview Various syntax/pattern checks for parsing. - * @author Nicholas C. Zakas - * @copyright 2014 Nicholas C. Zakas. All rights reserved. - * @copyright 2011-2013 Ariya Hidayat - * @copyright 2012-2013 Mathias Bynens - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// None! - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -// See also tools/generate-identifier-regex.js. -var Regex = { - NonAsciiIdentifierStart: new RegExp("[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]"), - NonAsciiIdentifierPart: new RegExp("[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]"), - LeadingZeros: new RegExp("^0+(?!$)") -}; - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -module.exports = { - - Regex: Regex, - - isDecimalDigit: function(ch) { - return (ch >= 48 && ch <= 57); // 0..9 - }, - - isHexDigit: function(ch) { - return "0123456789abcdefABCDEF".indexOf(ch) >= 0; - }, - - isOctalDigit: function(ch) { - return "01234567".indexOf(ch) >= 0; - }, - - // 7.2 White Space - - isWhiteSpace: function(ch) { - return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || - (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); - }, - - // 7.3 Line Terminators - - isLineTerminator: function(ch) { - return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); - }, - - // 7.6 Identifier Names and Identifiers - - isIdentifierStart: function(ch) { - return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) - (ch >= 0x41 && ch <= 0x5A) || // A..Z - (ch >= 0x61 && ch <= 0x7A) || // a..z - (ch === 0x5C) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); - }, - - isIdentifierPart: function(ch) { - return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) - (ch >= 0x41 && ch <= 0x5A) || // A..Z - (ch >= 0x61 && ch <= 0x7A) || // a..z - (ch >= 0x30 && ch <= 0x39) || // 0..9 - (ch === 0x5C) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); - }, - - // 7.6.1.2 Future Reserved Words - - isFutureReservedWord: function(id) { - switch (id) { - case "class": - case "enum": - case "export": - case "extends": - case "import": - case "super": - return true; - default: - return false; - } - }, - - isStrictModeReservedWord: function(id, ecmaFeatures) { - switch (id) { - case "implements": - case "interface": - case "package": - case "private": - case "protected": - case "public": - case "static": - case "yield": - case "let": - return true; - case "await": - return ecmaFeatures.modules; - default: - return false; - } - }, - - isRestrictedWord: function(id) { - return id === "eval" || id === "arguments"; - }, - - // 7.6.1.1 Keywords - - isKeyword: function(id, strict, ecmaFeatures) { - - if (strict && this.isStrictModeReservedWord(id, ecmaFeatures)) { - return true; - } - - // "const" is specialized as Keyword in V8. - // "yield" and "let" are for compatiblity with SpiderMonkey and ES.next. - // Some others are from future reserved words. - - switch (id.length) { - case 2: - return (id === "if") || (id === "in") || (id === "do"); - case 3: - return (id === "var") || (id === "for") || (id === "new") || - (id === "try") || (id === "let"); - case 4: - return (id === "this") || (id === "else") || (id === "case") || - (id === "void") || (id === "with") || (id === "enum"); - case 5: - return (id === "while") || (id === "break") || (id === "catch") || - (id === "throw") || (id === "const") || (!ecmaFeatures.generators && id === "yield") || - (id === "class") || (id === "super"); - case 6: - return (id === "return") || (id === "typeof") || (id === "delete") || - (id === "switch") || (id === "export") || (id === "import"); - case 7: - return (id === "default") || (id === "finally") || (id === "extends"); - case 8: - return (id === "function") || (id === "continue") || (id === "debugger"); - case 10: - return (id === "instanceof"); - default: - return false; - } - }, - - isJSXIdentifierStart: function(ch) { - // exclude backslash (\) - return (ch !== 92) && this.isIdentifierStart(ch); - }, - - isJSXIdentifierPart: function(ch) { - // exclude backslash (\) and add hyphen (-) - return (ch !== 92) && (ch === 45 || this.isIdentifierPart(ch)); - } - - -}; diff --git a/lib/token-translator.js b/lib/token-translator.js new file mode 100644 index 00000000..b7999623 --- /dev/null +++ b/lib/token-translator.js @@ -0,0 +1,260 @@ +/** + * @fileoverview Translates tokens between Acorn format and Esprima format. + * @author Nicholas C. Zakas + * @copyright 2015 Nicholas C. Zakas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + + +// Esprima Token Types +var Token = { + Boolean: "Boolean", + EOF: "", + Identifier: "Identifier", + Keyword: "Keyword", + Null: "Null", + Numeric: "Numeric", + Punctuator: "Punctuator", + String: "String", + RegularExpression: "RegularExpression", + Template: "Template", + JSXIdentifier: "JSXIdentifier", + JSXText: "JSXText" +}; + + +/** + * Converts part of a template into an Esprima token. + * @param {AcornToken[]} tokens The Acorn tokens representing the template. + * @param {string} code The source code. + * @return {EsprimaToken} The Esprima equivalent of the template token. + * @private + */ +function convertTemplatePart(tokens, code) { + var firstToken = tokens[0], + lastTemplateToken = tokens[tokens.length - 1]; + + var token = { + type: Token.Template, + value: code.slice(firstToken.start, lastTemplateToken.end) + }; + + if (firstToken.loc) { + token.loc = { + start: firstToken.loc.start, + end: lastTemplateToken.loc.end + }; + } + + if (firstToken.range) { + token.range = [firstToken.range[0], lastTemplateToken.range[1]]; + } + + return token; +} + +/** + * Contains logic to translate Acorn tokens into Esprima tokens. + * @param {Object} acornTokTypes The Acorn token types. + * @param {string} code The source code Acorn is parsing. This is necessary + * to correct the "value" property of some tokens. + * @constructor + */ +function TokenTranslator(acornTokTypes, code) { + + // token types + this._acornTokTypes = acornTokTypes; + + // token buffer for templates + this._tokens = []; + + // track the last curly brace + this._curlyBrace = null; + + // the source code + this._code = code; + +} + +TokenTranslator.prototype = { + constructor: TokenTranslator, + + /** + * Translates a single Esprima token to a single Acorn token. This may be + * inaccurate due to how templates are handled differently in Esprima and + * Acorn, but should be accurate for all other tokens. + * @param {AcornToken} token The Acorn token to translate. + * @returns {EsprimaToken} The Esprima version of the token. + */ + translate: function(token, extra) { + + var type = token.type, + tt = this._acornTokTypes; + + if (type === tt.name) { + token.type = Token.Identifier; + + // TODO: See if this is an Acorn bug + if (token.value === "static") { + token.type = Token.Keyword; + } + + } else if (type === tt.semi || type === tt.comma || + type === tt.parenL || type === tt.parenR || + type === tt.braceL || type === tt.braceR || + type === tt.dot || type === tt.bracketL || + type === tt.colon || type === tt.question || + type === tt.bracketR || type === tt.ellipsis || + type === tt.arrow || type === tt.jsxTagStart || + type === tt.jsxTagEnd || (type.binop && !type.keyword) || + type.isAssign) { + + token.type = Token.Punctuator; + token.value = this._code.slice(token.start, token.end); + } else if (type === tt.jsxName) { + token.type = Token.JSXIdentifier; + } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) { + token.type = Token.JSXText; + } else if (type.keyword) { + if (type.keyword === "true" || type.keyword === "false") { + token.type = Token.Boolean; + } else if (type.keyword === "null") { + token.type = Token.Null; + } else { + token.type = Token.Keyword; + } + } else if (type === tt.num) { + token.type = Token.Numeric; + token.value = this._code.slice(token.start, token.end); //String(token.value); + } else if (type === tt.string) { + + if (extra.jsxAttrValueToken) { + extra.jsxAttrValueToken = false; + token.type = Token.JSXText; + } else { + token.type = Token.String; + } + + token.value = this._code.slice(token.start, token.end); //JSON.stringify(token.value); + } else if (type === tt.regexp) { + token.type = Token.RegularExpression; + var value = token.value; + token.regex = { + flags: value.flags, + pattern: value.pattern + }; + token.value = "/" + value.pattern + "/" + value.flags; + } + + delete token.start; + delete token.end; + + return token; + }, + + /** + * Function to call during Acorn's onToken handler. + * @param {AcornToken} token The Acorn token. + * @param {EsprimaToken[]} tokens The array to push translated tokens onto. + * @returns {void} + */ + onToken: function(token, extra) { + + var that = this, + tt = this._acornTokTypes, + tokens = extra.tokens, + templateTokens = this._tokens; + + function translateTemplateTokens() { + tokens.push(convertTemplatePart(that._tokens, that._code)); + that._tokens = []; + } + + if (token.type === tt.eof) { + + // might be one last curlyBrace + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + } + + return; + } + + if (token.type === tt.backQuote) { + templateTokens.push(token); + + // it's the end + if (templateTokens.length > 1) { + translateTemplateTokens(); + } + + return; + } else if (token.type === tt.dollarBraceL) { + templateTokens.push(token); + translateTemplateTokens(); + return; + } else if (token.type === tt.braceR) { + + // if there's already a curly, it's not part of the template + if (this._curlyBrace) { + + tokens.push(this.translate(this._curlyBrace, extra)); + } + + // store new curly for later + this._curlyBrace = token; + return; + } else if (token.type === tt.template) { + if (this._curlyBrace) { + templateTokens.push(this._curlyBrace); + this._curlyBrace = null; + } + + templateTokens.push(token); + return; + } + + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + this._curlyBrace = null; + } + + tokens.push(this.translate(token, extra)); + } +}; + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = TokenTranslator; diff --git a/lib/xhtml-entities.js b/lib/xhtml-entities.js deleted file mode 100644 index 1ceda1ec..00000000 --- a/lib/xhtml-entities.js +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @fileoverview The list of XHTML entities that are valid in JSX. - * @author Nicholas C. Zakas - * @copyright 2014 Nicholas C. Zakas. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// None! - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -module.exports = { - quot: "\u0022", - amp: "&", - apos: "\u0027", - lt: "<", - gt: ">", - nbsp: "\u00A0", - iexcl: "\u00A1", - cent: "\u00A2", - pound: "\u00A3", - curren: "\u00A4", - yen: "\u00A5", - brvbar: "\u00A6", - sect: "\u00A7", - uml: "\u00A8", - copy: "\u00A9", - ordf: "\u00AA", - laquo: "\u00AB", - not: "\u00AC", - shy: "\u00AD", - reg: "\u00AE", - macr: "\u00AF", - deg: "\u00B0", - plusmn: "\u00B1", - sup2: "\u00B2", - sup3: "\u00B3", - acute: "\u00B4", - micro: "\u00B5", - para: "\u00B6", - middot: "\u00B7", - cedil: "\u00B8", - sup1: "\u00B9", - ordm: "\u00BA", - raquo: "\u00BB", - frac14: "\u00BC", - frac12: "\u00BD", - frac34: "\u00BE", - iquest: "\u00BF", - Agrave: "\u00C0", - Aacute: "\u00C1", - Acirc: "\u00C2", - Atilde: "\u00C3", - Auml: "\u00C4", - Aring: "\u00C5", - AElig: "\u00C6", - Ccedil: "\u00C7", - Egrave: "\u00C8", - Eacute: "\u00C9", - Ecirc: "\u00CA", - Euml: "\u00CB", - Igrave: "\u00CC", - Iacute: "\u00CD", - Icirc: "\u00CE", - Iuml: "\u00CF", - ETH: "\u00D0", - Ntilde: "\u00D1", - Ograve: "\u00D2", - Oacute: "\u00D3", - Ocirc: "\u00D4", - Otilde: "\u00D5", - Ouml: "\u00D6", - times: "\u00D7", - Oslash: "\u00D8", - Ugrave: "\u00D9", - Uacute: "\u00DA", - Ucirc: "\u00DB", - Uuml: "\u00DC", - Yacute: "\u00DD", - THORN: "\u00DE", - szlig: "\u00DF", - agrave: "\u00E0", - aacute: "\u00E1", - acirc: "\u00E2", - atilde: "\u00E3", - auml: "\u00E4", - aring: "\u00E5", - aelig: "\u00E6", - ccedil: "\u00E7", - egrave: "\u00E8", - eacute: "\u00E9", - ecirc: "\u00EA", - euml: "\u00EB", - igrave: "\u00EC", - iacute: "\u00ED", - icirc: "\u00EE", - iuml: "\u00EF", - eth: "\u00F0", - ntilde: "\u00F1", - ograve: "\u00F2", - oacute: "\u00F3", - ocirc: "\u00F4", - otilde: "\u00F5", - ouml: "\u00F6", - divide: "\u00F7", - oslash: "\u00F8", - ugrave: "\u00F9", - uacute: "\u00FA", - ucirc: "\u00FB", - uuml: "\u00FC", - yacute: "\u00FD", - thorn: "\u00FE", - yuml: "\u00FF", - OElig: "\u0152", - oelig: "\u0153", - Scaron: "\u0160", - scaron: "\u0161", - Yuml: "\u0178", - fnof: "\u0192", - circ: "\u02C6", - tilde: "\u02DC", - Alpha: "\u0391", - Beta: "\u0392", - Gamma: "\u0393", - Delta: "\u0394", - Epsilon: "\u0395", - Zeta: "\u0396", - Eta: "\u0397", - Theta: "\u0398", - Iota: "\u0399", - Kappa: "\u039A", - Lambda: "\u039B", - Mu: "\u039C", - Nu: "\u039D", - Xi: "\u039E", - Omicron: "\u039F", - Pi: "\u03A0", - Rho: "\u03A1", - Sigma: "\u03A3", - Tau: "\u03A4", - Upsilon: "\u03A5", - Phi: "\u03A6", - Chi: "\u03A7", - Psi: "\u03A8", - Omega: "\u03A9", - alpha: "\u03B1", - beta: "\u03B2", - gamma: "\u03B3", - delta: "\u03B4", - epsilon: "\u03B5", - zeta: "\u03B6", - eta: "\u03B7", - theta: "\u03B8", - iota: "\u03B9", - kappa: "\u03BA", - lambda: "\u03BB", - mu: "\u03BC", - nu: "\u03BD", - xi: "\u03BE", - omicron: "\u03BF", - pi: "\u03C0", - rho: "\u03C1", - sigmaf: "\u03C2", - sigma: "\u03C3", - tau: "\u03C4", - upsilon: "\u03C5", - phi: "\u03C6", - chi: "\u03C7", - psi: "\u03C8", - omega: "\u03C9", - thetasym: "\u03D1", - upsih: "\u03D2", - piv: "\u03D6", - ensp: "\u2002", - emsp: "\u2003", - thinsp: "\u2009", - zwnj: "\u200C", - zwj: "\u200D", - lrm: "\u200E", - rlm: "\u200F", - ndash: "\u2013", - mdash: "\u2014", - lsquo: "\u2018", - rsquo: "\u2019", - sbquo: "\u201A", - ldquo: "\u201C", - rdquo: "\u201D", - bdquo: "\u201E", - dagger: "\u2020", - Dagger: "\u2021", - bull: "\u2022", - hellip: "\u2026", - permil: "\u2030", - prime: "\u2032", - Prime: "\u2033", - lsaquo: "\u2039", - rsaquo: "\u203A", - oline: "\u203E", - frasl: "\u2044", - euro: "\u20AC", - image: "\u2111", - weierp: "\u2118", - real: "\u211C", - trade: "\u2122", - alefsym: "\u2135", - larr: "\u2190", - uarr: "\u2191", - rarr: "\u2192", - darr: "\u2193", - harr: "\u2194", - crarr: "\u21B5", - lArr: "\u21D0", - uArr: "\u21D1", - rArr: "\u21D2", - dArr: "\u21D3", - hArr: "\u21D4", - forall: "\u2200", - part: "\u2202", - exist: "\u2203", - empty: "\u2205", - nabla: "\u2207", - isin: "\u2208", - notin: "\u2209", - ni: "\u220B", - prod: "\u220F", - sum: "\u2211", - minus: "\u2212", - lowast: "\u2217", - radic: "\u221A", - prop: "\u221D", - infin: "\u221E", - ang: "\u2220", - and: "\u2227", - or: "\u2228", - cap: "\u2229", - cup: "\u222A", - "int": "\u222B", - there4: "\u2234", - sim: "\u223C", - cong: "\u2245", - asymp: "\u2248", - ne: "\u2260", - equiv: "\u2261", - le: "\u2264", - ge: "\u2265", - sub: "\u2282", - sup: "\u2283", - nsub: "\u2284", - sube: "\u2286", - supe: "\u2287", - oplus: "\u2295", - otimes: "\u2297", - perp: "\u22A5", - sdot: "\u22C5", - lceil: "\u2308", - rceil: "\u2309", - lfloor: "\u230A", - rfloor: "\u230B", - lang: "\u2329", - rang: "\u232A", - loz: "\u25CA", - spades: "\u2660", - clubs: "\u2663", - hearts: "\u2665", - diams: "\u2666" -}; diff --git a/package.json b/package.json index 1d936803..54d72a9b 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,13 @@ } ], "devDependencies": { + "acorn-jsx": "^2.0.1", "browserify": "^7.0.0", "chai": "^1.10.0", "complexity-report": "~0.6.1", "dateformat": "^1.0.11", - "eslint": "^0.9.2", + "eslint": "^1.6.0", + "eslint-config-eslint": "^1.0.1", "esprima": "git://github.com/jquery/esprima", "esprima-fb": "^8001.2001.0-dev-harmony-fb", "istanbul": "~0.2.6", @@ -79,5 +81,8 @@ "benchmark": "node test/benchmarks.js", "benchmark-quick": "node test/benchmarks.js quick" }, - "dependencies": {} + "dependencies": { + "acorn": "^2.5.2", + "acorn-jsx": "^2.0.1" + } } diff --git a/tests/fixtures/attach-comments/block-trailing-comment.result.js b/tests/fixtures/attach-comments/block-trailing-comment.result.js index e31305b7..2c604716 100644 --- a/tests/fixtures/attach-comments/block-trailing-comment.result.js +++ b/tests/fixtures/attach-comments/block-trailing-comment.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 6, + 10 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 6, + 9 + ], "callee": { "type": "Identifier", - "name": "a", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 2, @@ -24,37 +75,14 @@ module.exports = { "line": 2, "column": 5 } - } - }, - "arguments": [], - "range": [ - 6, - 9 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 7 - } - } - }, - "range": [ - 6, - 10 - ], - "loc": { - "start": { - "line": 2, - "column": 4 + "range": [ + 6, + 7 + ], + "name": "a" }, - "end": { - "line": 2, - "column": 8 - } + "arguments": [] }, "trailingComments": [ { @@ -77,38 +105,10 @@ module.exports = { } ] } - ], - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } + ] } ], "sourceType": "script", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, "comments": [ { "type": "Line", @@ -133,10 +133,6 @@ module.exports = { { "type": "Punctuator", "value": "{", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 2, @@ -164,15 +160,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 2, @@ -182,15 +178,15 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 2, @@ -200,15 +196,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 2, @@ -218,15 +214,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 4, @@ -236,7 +232,11 @@ module.exports = { "line": 4, "column": 1 } - } + }, + "range": [ + 25, + 26 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/comment-within-condition.result.js b/tests/fixtures/attach-comments/comment-within-condition.result.js index 799c3ab5..e4d46753 100644 --- a/tests/fixtures/attach-comments/comment-within-condition.result.js +++ b/tests/fixtures/attach-comments/comment-within-condition.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 10, + 29 + ], "body": [ { "type": "IfStatement", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 10, + 30 + ], "test": { "type": "Identifier", - "name": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 2, @@ -20,6 +43,11 @@ module.exports = { "column": 16 } }, + "range": [ + 25, + 26 + ], + "name": "a", "leadingComments": [ { "type": "Block", @@ -43,11 +71,6 @@ module.exports = { }, "consequent": { "type": "BlockStatement", - "body": [], - "range": [ - 28, - 30 - ], "loc": { "start": { "line": 2, @@ -57,23 +80,14 @@ module.exports = { "line": 2, "column": 20 } - } - }, - "alternate": null, - "range": [ - 10, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 0 }, - "end": { - "line": 2, - "column": 20 - } + "range": [ + 28, + 30 + ], + "body": [] }, + "alternate": null, "leadingComments": [ { "type": "Block", @@ -97,20 +111,6 @@ module.exports = { } ], "sourceType": "script", - "range": [ - 10, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 20 - } - }, "comments": [ { "type": "Block", @@ -153,10 +153,6 @@ module.exports = { { "type": "Keyword", "value": "if", - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 2, @@ -166,15 +162,15 @@ module.exports = { "line": 2, "column": 2 } - } + }, + "range": [ + 10, + 12 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 2, @@ -184,15 +180,15 @@ module.exports = { "line": 2, "column": 4 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 2, @@ -202,15 +198,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 2, @@ -220,15 +216,15 @@ module.exports = { "line": 2, "column": 17 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 2, @@ -238,15 +234,15 @@ module.exports = { "line": 2, "column": 19 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 2, @@ -256,7 +252,11 @@ module.exports = { "line": 2, "column": 20 } - } + }, + "range": [ + 29, + 30 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/export-default-anonymous-class.result.js b/tests/fixtures/attach-comments/export-default-anonymous-class.result.js index 34b376b6..a9ae2922 100644 --- a/tests/fixtures/attach-comments/export-default-anonymous-class.result.js +++ b/tests/fixtures/attach-comments/export-default-anonymous-class.result.js @@ -1,412 +1,6 @@ module.exports = { - "type": "Program", - "body": [ - { - "type": "ExportDefaultDeclaration", - "declaration": { - "type": "ClassDeclaration", - "id": null, - "superClass": null, - "body": { - "type": "ClassBody", - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "method1", - "range": [ - 103, - 110 - ], - "loc": { - "start": { - "line": 8, - "column": 4 - }, - "end": { - "line": 8, - "column": 11 - } - } - }, - "value": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "range": [ - 112, - 119 - ], - "loc": { - "start": { - "line": 8, - "column": 13 - }, - "end": { - "line": 9, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 110, - 119 - ], - "loc": { - "start": { - "line": 8, - "column": 11 - }, - "end": { - "line": 9, - "column": 5 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 103, - 119 - ], - "loc": { - "start": { - "line": 8, - "column": 4 - }, - "end": { - "line": 9, - "column": 5 - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * this is method1.\n ", - "range": [ - 63, - 98 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 7, - "column": 7 - } - } - } - ], - "static": false - } - ], - "range": [ - 57, - 121 - ], - "loc": { - "start": { - "line": 4, - "column": 21 - }, - "end": { - "line": 10, - "column": 1 - } - } - }, - "range": [ - 51, - 121 - ], - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 10, - "column": 1 - } - } - }, - "range": [ - 36, - 121 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 10, - "column": 1 - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * this is anonymous class.\n ", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - } - ], - "sourceType": "module", - "range": [ - 36, - 121 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 10, - "column": 1 - } - }, - "comments": [ - { - "type": "Block", - "value": "*\n * this is anonymous class.\n ", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - }, - { - "type": "Block", - "value": "*\n * this is method1.\n ", - "range": [ - 63, - 98 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 7, - "column": 7 - } - } - } - ], - "tokens": [ - { - "type": "Keyword", - "value": "export", - "range": [ - 36, - 42 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - { - "type": "Keyword", - "value": "default", - "range": [ - 43, - 50 - ], - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 14 - } - } - }, - { - "type": "Keyword", - "value": "class", - "range": [ - 51, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 20 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 57, - 58 - ], - "loc": { - "start": { - "line": 4, - "column": 21 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - { - "type": "Identifier", - "value": "method1", - "range": [ - 103, - 110 - ], - "loc": { - "start": { - "line": 8, - "column": 4 - }, - "end": { - "line": 8, - "column": 11 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 110, - 111 - ], - "loc": { - "start": { - "line": 8, - "column": 11 - }, - "end": { - "line": 8, - "column": 12 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 111, - 112 - ], - "loc": { - "start": { - "line": 8, - "column": 12 - }, - "end": { - "line": 8, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 112, - 113 - ], - "loc": { - "start": { - "line": 8, - "column": 13 - }, - "end": { - "line": 8, - "column": 14 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 118, - 119 - ], - "loc": { - "start": { - "line": 9, - "column": 4 - }, - "end": { - "line": 9, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 120, - 121 - ], - "loc": { - "start": { - "line": 10, - "column": 0 - }, - "end": { - "line": 10, - "column": 1 - } - } - } - ] -}; + "index": 43, + "lineNumber": 4, + "column": 8, + "message": "Unexpected token default" +}; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/surrounding-call-comments.result.js b/tests/fixtures/attach-comments/surrounding-call-comments.result.js index 297923f3..56bdf905 100644 --- a/tests/fixtures/attach-comments/surrounding-call-comments.result.js +++ b/tests/fixtures/attach-comments/surrounding-call-comments.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 0, + 42 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 60 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,23 +42,65 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 13, + 60 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 36, + 42 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 36, + 41 + ], "callee": { "type": "Identifier", - "name": "foo", - "range": [ - 36, - 39 - ], "loc": { "start": { "line": 3, @@ -45,37 +110,14 @@ module.exports = { "line": 3, "column": 7 } - } - }, - "arguments": [], - "range": [ - 36, - 41 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 9 - } - } - }, - "range": [ - 36, - 42 - ], - "loc": { - "start": { - "line": 3, - "column": 4 + "range": [ + 36, + 39 + ], + "name": "foo" }, - "end": { - "line": 3, - "column": 10 - } + "arguments": [] }, "leadingComments": [ { @@ -118,55 +160,13 @@ module.exports = { } ] } - ], - "range": [ - 13, - 60 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 5, - "column": 1 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 60 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 60 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, "comments": [ { "type": "Block", @@ -209,10 +209,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -276,15 +272,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -294,15 +290,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 36, - 39 - ], "loc": { "start": { "line": 3, @@ -312,15 +308,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 36, + 39 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 3, @@ -330,15 +326,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 39, + 40 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -348,15 +344,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 3, @@ -366,15 +362,15 @@ module.exports = { "line": 3, "column": 10 } - } + }, + "range": [ + 41, + 42 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 59, - 60 - ], "loc": { "start": { "line": 5, @@ -384,7 +380,11 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 59, + 60 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/surrounding-debugger-comments.result.js b/tests/fixtures/attach-comments/surrounding-debugger-comments.result.js index 320f49dc..3da7d2b1 100644 --- a/tests/fixtures/attach-comments/surrounding-debugger-comments.result.js +++ b/tests/fixtures/attach-comments/surrounding-debugger-comments.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 0, + 45 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 63 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,18 +42,33 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 13, + 63 + ], "body": [ { "type": "DebuggerStatement", - "range": [ - 36, - 45 - ], "loc": { "start": { "line": 3, @@ -41,6 +79,10 @@ module.exports = { "column": 13 } }, + "range": [ + 36, + 45 + ], "leadingComments": [ { "type": "Block", @@ -82,55 +124,13 @@ module.exports = { } ] } - ], - "range": [ - 13, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 5, - "column": 1 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, "comments": [ { "type": "Block", @@ -173,10 +173,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -186,15 +182,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -204,15 +200,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Keyword", "value": "debugger", - "range": [ - 36, - 44 - ], "loc": { "start": { "line": 3, @@ -276,15 +272,15 @@ module.exports = { "line": 3, "column": 12 } - } + }, + "range": [ + 36, + 44 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 3, @@ -294,15 +290,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 5, @@ -312,7 +308,11 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 62, + 63 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/surrounding-return-comments.result.js b/tests/fixtures/attach-comments/surrounding-return-comments.result.js index 51a48f0a..c0389f5e 100644 --- a/tests/fixtures/attach-comments/surrounding-return-comments.result.js +++ b/tests/fixtures/attach-comments/surrounding-return-comments.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 0, + 43 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 61 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,19 +42,33 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 13, + 61 + ], "body": [ { "type": "ReturnStatement", - "argument": null, - "range": [ - 36, - 43 - ], "loc": { "start": { "line": 3, @@ -42,6 +79,11 @@ module.exports = { "column": 11 } }, + "range": [ + 36, + 43 + ], + "argument": null, "leadingComments": [ { "type": "Block", @@ -83,55 +125,13 @@ module.exports = { } ] } - ], - "range": [ - 13, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 5, - "column": 1 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, "comments": [ { "type": "Block", @@ -174,10 +174,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -187,15 +183,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -205,15 +201,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -223,15 +219,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -241,15 +237,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -259,15 +255,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 36, - 42 - ], "loc": { "start": { "line": 3, @@ -277,15 +273,15 @@ module.exports = { "line": 3, "column": 10 } - } + }, + "range": [ + 36, + 42 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 3, @@ -295,15 +291,15 @@ module.exports = { "line": 3, "column": 11 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 60, - 61 - ], "loc": { "start": { "line": 5, @@ -313,7 +309,11 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 60, + 61 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/surrounding-throw-comments.result.js b/tests/fixtures/attach-comments/surrounding-throw-comments.result.js index e8003c25..b12bfc56 100644 --- a/tests/fixtures/attach-comments/surrounding-throw-comments.result.js +++ b/tests/fixtures/attach-comments/surrounding-throw-comments.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 0, + 45 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 63 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,22 +42,49 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 13, + 63 + ], "body": [ { "type": "ThrowStatement", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 36, + 45 + ], "argument": { "type": "Literal", - "value": 55, - "raw": "55", - "range": [ - 42, - 44 - ], "loc": { "start": { "line": 3, @@ -44,21 +94,13 @@ module.exports = { "line": 3, "column": 12 } - } - }, - "range": [ - 36, - 45 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 13 - } + "range": [ + 42, + 44 + ], + "value": 55, + "raw": "55" }, "leadingComments": [ { @@ -101,55 +143,13 @@ module.exports = { } ] } - ], - "range": [ - 13, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 5, - "column": 1 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, "comments": [ { "type": "Block", @@ -192,10 +192,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -205,15 +201,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -223,15 +219,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -241,15 +237,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -259,15 +255,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -277,15 +273,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Keyword", "value": "throw", - "range": [ - 36, - 41 - ], "loc": { "start": { "line": 3, @@ -295,15 +291,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 36, + 41 + ] }, { "type": "Numeric", "value": "55", - "range": [ - 42, - 44 - ], "loc": { "start": { "line": 3, @@ -313,15 +309,15 @@ module.exports = { "line": 3, "column": 12 } - } + }, + "range": [ + 42, + 44 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 3, @@ -331,15 +327,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 5, @@ -349,7 +345,11 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 62, + 63 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/surrounding-while-loop-comments.result.js b/tests/fixtures/attach-comments/surrounding-while-loop-comments.result.js index c3524d4e..c87e926e 100644 --- a/tests/fixtures/attach-comments/surrounding-while-loop-comments.result.js +++ b/tests/fixtures/attach-comments/surrounding-while-loop-comments.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 66 + } + }, + "range": [ + 0, + 66 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "range": [ + 0, + 68 + ], "id": { "type": "Identifier", - "name": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,22 +42,49 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "f" }, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "range": [ + 13, + 68 + ], "body": [ { "type": "WhileStatement", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 30, + 46 + ], "test": { "type": "Literal", - "value": true, - "raw": "true", - "range": [ - 37, - 41 - ], "loc": { "start": { "line": 1, @@ -44,15 +94,16 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 37, + 41 + ], + "value": true, + "raw": "true" }, "body": { "type": "BlockStatement", - "body": [], - "range": [ - 43, - 46 - ], "loc": { "start": { "line": 1, @@ -62,21 +113,12 @@ module.exports = { "line": 1, "column": 46 } - } - }, - "range": [ - 30, - 46 - ], - "loc": { - "start": { - "line": 1, - "column": 30 }, - "end": { - "line": 1, - "column": 46 - } + "range": [ + 43, + 46 + ], + "body": [] }, "leadingComments": [ { @@ -121,16 +163,39 @@ module.exports = { }, { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 57 + }, + "end": { + "line": 1, + "column": 66 + } + }, + "range": [ + 57, + 66 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 65 + } + }, + "range": [ + 61, + 65 + ], "id": { "type": "Identifier", - "name": "each", - "range": [ - 61, - 65 - ], "loc": { "start": { "line": 1, @@ -140,40 +205,17 @@ module.exports = { "line": 1, "column": 65 } - } - }, - "init": null, - "range": [ - 61, - 65 - ], - "loc": { - "start": { - "line": 1, - "column": 61 }, - "end": { - "line": 1, - "column": 65 - } - } + "range": [ + 61, + 65 + ], + "name": "each" + }, + "init": null } ], "kind": "var", - "range": [ - 57, - 66 - ], - "loc": { - "start": { - "line": 1, - "column": 57 - }, - "end": { - "line": 1, - "column": 66 - } - }, "leadingComments": [ { "type": "Block", @@ -195,55 +237,13 @@ module.exports = { } ] } - ], - "range": [ - 13, - 68 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 68 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 68 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 68 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 68 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 68 - } - }, "comments": [ { "type": "Block", @@ -286,10 +286,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -299,15 +295,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -317,15 +313,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -335,15 +331,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -353,15 +349,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -371,15 +367,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Keyword", "value": "while", - "range": [ - 30, - 35 - ], "loc": { "start": { "line": 1, @@ -389,15 +385,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 30, + 35 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -407,15 +403,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Boolean", "value": "true", - "range": [ - 37, - 41 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 37, + 41 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 42 } - } + }, + "range": [ + 41, + 42 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 43, - 44 - ], "loc": { "start": { "line": 1, @@ -461,15 +457,15 @@ module.exports = { "line": 1, "column": 44 } - } + }, + "range": [ + 43, + 44 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 1, @@ -479,15 +475,15 @@ module.exports = { "line": 1, "column": 46 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 57, - 60 - ], "loc": { "start": { "line": 1, @@ -497,15 +493,15 @@ module.exports = { "line": 1, "column": 60 } - } + }, + "range": [ + 57, + 60 + ] }, { "type": "Identifier", "value": "each", - "range": [ - 61, - 65 - ], "loc": { "start": { "line": 1, @@ -515,15 +511,15 @@ module.exports = { "line": 1, "column": 65 } - } + }, + "range": [ + 61, + 65 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 65, - 66 - ], "loc": { "start": { "line": 1, @@ -533,15 +529,15 @@ module.exports = { "line": 1, "column": 66 } - } + }, + "range": [ + 65, + 66 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 67, - 68 - ], "loc": { "start": { "line": 1, @@ -551,7 +547,11 @@ module.exports = { "line": 1, "column": 68 } - } + }, + "range": [ + 67, + 68 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/switch-fallthrough-comment-in-function.result.js b/tests/fixtures/attach-comments/switch-fallthrough-comment-in-function.result.js index ec09a3de..9e208476 100644 --- a/tests/fixtures/attach-comments/switch-fallthrough-comment-in-function.result.js +++ b/tests/fixtures/attach-comments/switch-fallthrough-comment-in-function.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "range": [ + 0, + 133 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 0, + 141 + ], "id": { "type": "Identifier", - "name": "bar", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,16 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ], + "name": "bar" }, "params": [ { "type": "Identifier", - "name": "foo", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -38,21 +61,49 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ], + "name": "foo" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 18, + 141 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 24, + 139 + ], "discriminant": { "type": "Identifier", - "name": "foo", - "range": [ - 31, - 34 - ], "loc": { "start": { "line": 2, @@ -62,19 +113,33 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 31, + 34 + ], + "name": "foo" }, "cases": [ { "type": "SwitchCase", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 61, + 68 + ], + "consequent": [], "test": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 66, - 67 - ], "loc": { "start": { "line": 4, @@ -84,22 +149,13 @@ module.exports = { "line": 4, "column": 14 } - } - }, - "consequent": [], - "range": [ - 61, - 68 - ], - "loc": { - "start": { - "line": 4, - "column": 8 }, - "end": { - "line": 4, - "column": 15 - } + "range": [ + 66, + 67 + ], + "value": 1, + "raw": "1" }, "leadingComments": [ { @@ -144,37 +200,55 @@ module.exports = { }, { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": 2, - "raw": "2", - "range": [ - 111, - 112 - ], - "loc": { - "start": { - "line": 6, - "column": 13 - }, - "end": { - "line": 6, - "column": 14 - } + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 7, + "column": 19 } }, + "range": [ + 106, + 133 + ], "consequent": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "range": [ + 126, + 133 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 18 + } + }, + "range": [ + 126, + 132 + ], "callee": { "type": "Identifier", - "name": "doIt", - "range": [ - 126, - 130 - ], "loc": { "start": { "line": 7, @@ -184,53 +258,35 @@ module.exports = { "line": 7, "column": 16 } - } - }, - "arguments": [], - "range": [ - 126, - 132 - ], - "loc": { - "start": { - "line": 7, - "column": 12 }, - "end": { - "line": 7, - "column": 18 - } - } - }, - "range": [ - 126, - 133 - ], - "loc": { - "start": { - "line": 7, - "column": 12 + "range": [ + 126, + 130 + ], + "name": "doIt" }, - "end": { - "line": 7, - "column": 19 - } + "arguments": [] } } ], - "range": [ - 106, - 133 - ], - "loc": { - "start": { - "line": 6, - "column": 8 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } }, - "end": { - "line": 7, - "column": 19 - } + "range": [ + 111, + 112 + ], + "value": 2, + "raw": "2" }, "leadingComments": [ { @@ -253,71 +309,15 @@ module.exports = { } ] } - ], - "range": [ - 24, - 139 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 8, - "column": 5 - } - } - } - ], - "range": [ - 18, - 141 - ], - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 9, - "column": 1 + ] } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 141 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 141 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 1 - } - }, "comments": [ { "type": "Line", @@ -360,10 +360,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -373,15 +369,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -391,15 +387,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -409,15 +405,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -427,15 +423,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -445,15 +441,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -463,15 +459,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Keyword", "value": "switch", - "range": [ - 24, - 30 - ], "loc": { "start": { "line": 2, @@ -481,15 +477,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 24, + 30 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 2, @@ -499,15 +495,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 31, - 34 - ], "loc": { "start": { "line": 2, @@ -517,15 +513,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 31, + 34 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 2, @@ -535,15 +531,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 2, @@ -553,15 +549,15 @@ module.exports = { "line": 2, "column": 17 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 61, - 65 - ], "loc": { "start": { "line": 4, @@ -571,15 +567,15 @@ module.exports = { "line": 4, "column": 12 } - } + }, + "range": [ + 61, + 65 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 66, - 67 - ], "loc": { "start": { "line": 4, @@ -589,15 +585,15 @@ module.exports = { "line": 4, "column": 14 } - } + }, + "range": [ + 66, + 67 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 67, - 68 - ], "loc": { "start": { "line": 4, @@ -607,15 +603,15 @@ module.exports = { "line": 4, "column": 15 } - } + }, + "range": [ + 67, + 68 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 106, - 110 - ], "loc": { "start": { "line": 6, @@ -625,15 +621,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 106, + 110 + ] }, { "type": "Numeric", "value": "2", - "range": [ - 111, - 112 - ], "loc": { "start": { "line": 6, @@ -643,15 +639,15 @@ module.exports = { "line": 6, "column": 14 } - } + }, + "range": [ + 111, + 112 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 112, - 113 - ], "loc": { "start": { "line": 6, @@ -661,15 +657,15 @@ module.exports = { "line": 6, "column": 15 } - } + }, + "range": [ + 112, + 113 + ] }, { "type": "Identifier", "value": "doIt", - "range": [ - 126, - 130 - ], "loc": { "start": { "line": 7, @@ -679,15 +675,15 @@ module.exports = { "line": 7, "column": 16 } - } + }, + "range": [ + 126, + 130 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 130, - 131 - ], "loc": { "start": { "line": 7, @@ -697,15 +693,15 @@ module.exports = { "line": 7, "column": 17 } - } + }, + "range": [ + 130, + 131 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 131, - 132 - ], "loc": { "start": { "line": 7, @@ -715,15 +711,15 @@ module.exports = { "line": 7, "column": 18 } - } + }, + "range": [ + 131, + 132 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 132, - 133 - ], "loc": { "start": { "line": 7, @@ -733,15 +729,15 @@ module.exports = { "line": 7, "column": 19 } - } + }, + "range": [ + 132, + 133 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 138, - 139 - ], "loc": { "start": { "line": 8, @@ -751,15 +747,15 @@ module.exports = { "line": 8, "column": 5 } - } + }, + "range": [ + 138, + 139 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 140, - 141 - ], "loc": { "start": { "line": 9, @@ -769,7 +765,11 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 140, + 141 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/switch-fallthrough-comment.result.js b/tests/fixtures/attach-comments/switch-fallthrough-comment.result.js index 508e23c3..4d6414fd 100644 --- a/tests/fixtures/attach-comments/switch-fallthrough-comment.result.js +++ b/tests/fixtures/attach-comments/switch-fallthrough-comment.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 0, + 89 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 91 + ], "discriminant": { "type": "Identifier", - "name": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -19,19 +42,33 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ], + "name": "foo" }, "cases": [ { "type": "SwitchCase", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 29, + 36 + ], + "consequent": [], "test": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 3, @@ -41,22 +78,13 @@ module.exports = { "line": 3, "column": 10 } - } - }, - "consequent": [], - "range": [ - 29, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 11 - } + "range": [ + 34, + 35 + ], + "value": 1, + "raw": "1" }, "leadingComments": [ { @@ -101,37 +129,55 @@ module.exports = { }, { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": 2, - "raw": "2", - "range": [ - 71, - 72 - ], - "loc": { - "start": { - "line": 5, - "column": 9 - }, - "end": { - "line": 5, - "column": 10 - } + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 6, + "column": 15 } }, + "range": [ + 66, + 89 + ], "consequent": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 82, + 89 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 82, + 88 + ], "callee": { "type": "Identifier", - "name": "doIt", - "range": [ - 82, - 86 - ], "loc": { "start": { "line": 6, @@ -141,53 +187,35 @@ module.exports = { "line": 6, "column": 12 } - } - }, - "arguments": [], - "range": [ - 82, - 88 - ], - "loc": { - "start": { - "line": 6, - "column": 8 }, - "end": { - "line": 6, - "column": 14 - } - } - }, - "range": [ - 82, - 89 - ], - "loc": { - "start": { - "line": 6, - "column": 8 + "range": [ + 82, + 86 + ], + "name": "doIt" }, - "end": { - "line": 6, - "column": 15 - } + "arguments": [] } } ], - "range": [ - 66, - 89 - ], - "loc": { - "start": { - "line": 5, - "column": 4 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } }, - "end": { - "line": 6, - "column": 15 - } + "range": [ + 71, + 72 + ], + "value": 2, + "raw": "2" }, "leadingComments": [ { @@ -210,38 +238,10 @@ module.exports = { } ] } - ], - "range": [ - 0, - 91 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - } + ] } ], "sourceType": "script", - "range": [ - 0, - 91 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, "comments": [ { "type": "Line", @@ -284,10 +284,6 @@ module.exports = { { "type": "Keyword", "value": "switch", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -297,15 +293,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -315,15 +311,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -333,15 +329,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -351,15 +347,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -369,15 +365,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 29, - 33 - ], "loc": { "start": { "line": 3, @@ -387,15 +383,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 29, + 33 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 3, @@ -405,15 +401,15 @@ module.exports = { "line": 3, "column": 10 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 3, @@ -423,15 +419,15 @@ module.exports = { "line": 3, "column": 11 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 66, - 70 - ], "loc": { "start": { "line": 5, @@ -441,15 +437,15 @@ module.exports = { "line": 5, "column": 8 } - } + }, + "range": [ + 66, + 70 + ] }, { "type": "Numeric", "value": "2", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 5, @@ -459,15 +455,15 @@ module.exports = { "line": 5, "column": 10 } - } + }, + "range": [ + 71, + 72 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 72, - 73 - ], "loc": { "start": { "line": 5, @@ -477,15 +473,15 @@ module.exports = { "line": 5, "column": 11 } - } + }, + "range": [ + 72, + 73 + ] }, { "type": "Identifier", "value": "doIt", - "range": [ - 82, - 86 - ], "loc": { "start": { "line": 6, @@ -495,15 +491,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 82, + 86 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 86, - 87 - ], "loc": { "start": { "line": 6, @@ -513,15 +509,15 @@ module.exports = { "line": 6, "column": 13 } - } + }, + "range": [ + 86, + 87 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 87, - 88 - ], "loc": { "start": { "line": 6, @@ -531,15 +527,15 @@ module.exports = { "line": 6, "column": 14 } - } + }, + "range": [ + 87, + 88 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 88, - 89 - ], "loc": { "start": { "line": 6, @@ -549,15 +545,15 @@ module.exports = { "line": 6, "column": 15 } - } + }, + "range": [ + 88, + 89 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 90, - 91 - ], "loc": { "start": { "line": 7, @@ -567,7 +563,11 @@ module.exports = { "line": 7, "column": 1 } - } + }, + "range": [ + 90, + 91 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/switch-no-default-comment-in-function.result.js b/tests/fixtures/attach-comments/switch-no-default-comment-in-function.result.js index ea4c8746..53536bc0 100644 --- a/tests/fixtures/attach-comments/switch-no-default-comment-in-function.result.js +++ b/tests/fixtures/attach-comments/switch-no-default-comment-in-function.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "range": [ + 0, + 104 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 0, + 133 + ], "id": { "type": "Identifier", - "name": "bar", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,16 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ], + "name": "bar" }, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -38,21 +61,49 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "a" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 16, + 133 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 22, + 131 + ], "discriminant": { "type": "Identifier", - "name": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 2, @@ -62,38 +113,33 @@ module.exports = { "line": 2, "column": 13 } - } + }, + "range": [ + 30, + 31 + ], + "name": "a" }, "cases": [ { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": 2, - "raw": "2", - "range": [ - 48, - 49 - ], - "loc": { - "start": { - "line": 3, - "column": 13 - }, - "end": { - "line": 3, - "column": 14 - } + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 4, + "column": 18 } }, + "range": [ + 43, + 69 + ], "consequent": [ { "type": "BreakStatement", - "label": null, - "range": [ - 63, - 69 - ], "loc": { "start": { "line": 4, @@ -103,53 +149,53 @@ module.exports = { "line": 4, "column": 18 } - } + }, + "range": [ + 63, + 69 + ], + "label": null } ], - "range": [ - 43, - 69 - ], - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 4, - "column": 18 - } - } - }, - { - "type": "SwitchCase", "test": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 83, - 84 - ], "loc": { "start": { - "line": 5, + "line": 3, "column": 13 }, "end": { - "line": 5, + "line": 3, "column": 14 } + }, + "range": [ + 48, + 49 + ], + "value": 2, + "raw": "2" + } + }, + { + "type": "SwitchCase", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 6, + "column": 18 } }, + "range": [ + 78, + 104 + ], "consequent": [ { "type": "BreakStatement", - "label": null, - "range": [ - 98, - 104 - ], "loc": { "start": { "line": 6, @@ -159,22 +205,32 @@ module.exports = { "line": 6, "column": 18 } - } + }, + "range": [ + 98, + 104 + ], + "label": null } ], - "range": [ - 78, - 104 - ], - "loc": { - "start": { - "line": 5, - "column": 8 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } }, - "end": { - "line": 6, - "column": 18 - } + "range": [ + 83, + 84 + ], + "value": 1, + "raw": "1" }, "trailingComments": [ { @@ -197,71 +253,15 @@ module.exports = { } ] } - ], - "range": [ - 22, - 131 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 8, - "column": 5 - } - } + ] } - ], - "range": [ - 16, - 133 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 9, - "column": 1 - } - } + ] }, - "generator": false, "expression": false, - "range": [ - 0, - 133 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 1 - } - } + "generator": false } ], "sourceType": "script", - "range": [ - 0, - 133 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 1 - } - }, "comments": [ { "type": "Line", @@ -286,10 +286,6 @@ module.exports = { { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -299,15 +295,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -317,15 +313,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -335,15 +331,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -353,15 +349,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -371,15 +367,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -389,15 +385,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Keyword", "value": "switch", - "range": [ - 22, - 28 - ], "loc": { "start": { "line": 2, @@ -407,15 +403,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 22, + 28 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 2, @@ -425,15 +421,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 2, @@ -443,15 +439,15 @@ module.exports = { "line": 2, "column": 13 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 2, @@ -461,15 +457,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 2, @@ -479,15 +475,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 43, - 47 - ], "loc": { "start": { "line": 3, @@ -497,15 +493,15 @@ module.exports = { "line": 3, "column": 12 } - } + }, + "range": [ + 43, + 47 + ] }, { "type": "Numeric", "value": "2", - "range": [ - 48, - 49 - ], "loc": { "start": { "line": 3, @@ -515,15 +511,15 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 48, + 49 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 49, - 50 - ], "loc": { "start": { "line": 3, @@ -533,15 +529,15 @@ module.exports = { "line": 3, "column": 15 } - } + }, + "range": [ + 49, + 50 + ] }, { "type": "Keyword", "value": "break", - "range": [ - 63, - 68 - ], "loc": { "start": { "line": 4, @@ -551,15 +547,15 @@ module.exports = { "line": 4, "column": 17 } - } + }, + "range": [ + 63, + 68 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 68, - 69 - ], "loc": { "start": { "line": 4, @@ -569,15 +565,15 @@ module.exports = { "line": 4, "column": 18 } - } + }, + "range": [ + 68, + 69 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 78, - 82 - ], "loc": { "start": { "line": 5, @@ -587,15 +583,15 @@ module.exports = { "line": 5, "column": 12 } - } + }, + "range": [ + 78, + 82 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 83, - 84 - ], "loc": { "start": { "line": 5, @@ -605,15 +601,15 @@ module.exports = { "line": 5, "column": 14 } - } + }, + "range": [ + 83, + 84 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 84, - 85 - ], "loc": { "start": { "line": 5, @@ -623,15 +619,15 @@ module.exports = { "line": 5, "column": 15 } - } + }, + "range": [ + 84, + 85 + ] }, { "type": "Keyword", "value": "break", - "range": [ - 98, - 103 - ], "loc": { "start": { "line": 6, @@ -641,15 +637,15 @@ module.exports = { "line": 6, "column": 17 } - } + }, + "range": [ + 98, + 103 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 103, - 104 - ], "loc": { "start": { "line": 6, @@ -659,15 +655,15 @@ module.exports = { "line": 6, "column": 18 } - } + }, + "range": [ + 103, + 104 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 130, - 131 - ], "loc": { "start": { "line": 8, @@ -677,15 +673,15 @@ module.exports = { "line": 8, "column": 5 } - } + }, + "range": [ + 130, + 131 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 132, - 133 - ], "loc": { "start": { "line": 9, @@ -695,7 +691,11 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 132, + 133 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/switch-no-default-comment-in-nested-functions.result.js b/tests/fixtures/attach-comments/switch-no-default-comment-in-nested-functions.result.js index 376e980f..53ce0a5f 100644 --- a/tests/fixtures/attach-comments/switch-no-default-comment-in-nested-functions.result.js +++ b/tests/fixtures/attach-comments/switch-no-default-comment-in-nested-functions.result.js @@ -1,21 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 2 + } + }, + "range": [ + 0, + 287 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 2 + } + }, + "range": [ + 0, + 287 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 1 + } + }, + "range": [ + 0, + 286 + ], "operator": "=", "left": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "object": { "type": "Identifier", - "name": "module", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -25,15 +75,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ], + "name": "module" }, "property": { "type": "Identifier", - "name": "exports", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -43,34 +93,35 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ], + "name": "exports" }, - "range": [ - 0, - 14 - ], + "computed": false + }, + "right": { + "type": "FunctionExpression", "loc": { "start": { "line": 1, - "column": 0 + "column": 17 }, "end": { - "line": 1, - "column": 14 + "line": 12, + "column": 1 } - } - }, - "right": { - "type": "FunctionExpression", + }, + "range": [ + 17, + 286 + ], "id": null, "params": [ { "type": "Identifier", - "name": "context", - "range": [ - 26, - 33 - ], "loc": { "start": { "line": 1, @@ -80,21 +131,49 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 26, + 33 + ], + "name": "context" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 12, + "column": 1 + } + }, + "range": [ + 35, + 286 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "range": [ + 42, + 283 + ], "id": { "type": "Identifier", - "name": "isConstant", - "range": [ - 51, - 61 - ], "loc": { "start": { "line": 3, @@ -104,16 +183,16 @@ module.exports = { "line": 3, "column": 23 } - } + }, + "range": [ + 51, + 61 + ], + "name": "isConstant" }, "params": [ { "type": "Identifier", - "name": "node", - "range": [ - 62, - 66 - ], "loc": { "start": { "line": 3, @@ -123,24 +202,65 @@ module.exports = { "line": 3, "column": 28 } - } + }, + "range": [ + 62, + 66 + ], + "name": "node" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "range": [ + 68, + 283 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 78, + 255 + ], "discriminant": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "range": [ + 86, + 95 + ], "object": { "type": "Identifier", - "name": "node", - "range": [ - 86, - 90 - ], "loc": { "start": { "line": 4, @@ -150,15 +270,15 @@ module.exports = { "line": 4, "column": 20 } - } + }, + "range": [ + 86, + 90 + ], + "name": "node" }, "property": { "type": "Identifier", - "name": "type", - "range": [ - 91, - 95 - ], "loc": { "start": { "line": 4, @@ -168,57 +288,67 @@ module.exports = { "line": 4, "column": 25 } - } - }, - "range": [ - 86, - 95 - ], - "loc": { - "start": { - "line": 4, - "column": 16 }, - "end": { - "line": 4, - "column": 25 - } - } + "range": [ + 91, + 95 + ], + "name": "type" + }, + "computed": false }, "cases": [ { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": "SequenceExpression", - "raw": "\"SequenceExpression\"", - "range": [ - 116, - 136 - ], - "loc": { - "start": { - "line": 5, - "column": 17 - }, - "end": { - "line": 5, - "column": 37 - } + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 6, + "column": 81 } }, + "range": [ + 111, + 219 + ], "consequent": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 81 + } + }, + "range": [ + 154, + 219 + ], "argument": { "type": "CallExpression", + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 80 + } + }, + "range": [ + 161, + 218 + ], "callee": { "type": "Identifier", - "name": "isConstant", - "range": [ - 161, - 171 - ], "loc": { "start": { "line": 6, @@ -228,22 +358,48 @@ module.exports = { "line": 6, "column": 33 } - } + }, + "range": [ + 161, + 171 + ], + "name": "isConstant" }, "arguments": [ { "type": "MemberExpression", - "computed": true, + "loc": { + "start": { + "line": 6, + "column": 34 + }, + "end": { + "line": 6, + "column": 79 + } + }, + "range": [ + 172, + 217 + ], "object": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 6, + "column": 34 + }, + "end": { + "line": 6, + "column": 50 + } + }, + "range": [ + 172, + 188 + ], "object": { "type": "Identifier", - "name": "node", - "range": [ - 172, - 176 - ], "loc": { "start": { "line": 6, @@ -253,15 +409,15 @@ module.exports = { "line": 6, "column": 38 } - } + }, + "range": [ + 172, + 176 + ], + "name": "node" }, "property": { "type": "Identifier", - "name": "expressions", - "range": [ - 177, - 188 - ], "loc": { "start": { "line": 6, @@ -271,39 +427,65 @@ module.exports = { "line": 6, "column": 50 } - } + }, + "range": [ + 177, + 188 + ], + "name": "expressions" }, - "range": [ - 172, - 188 - ], + "computed": false + }, + "property": { + "type": "BinaryExpression", "loc": { "start": { "line": 6, - "column": 34 + "column": 51 }, "end": { "line": 6, - "column": 50 + "column": 78 } - } - }, - "property": { - "type": "BinaryExpression", - "operator": "-", + }, + "range": [ + 189, + 216 + ], "left": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 6, + "column": 51 + }, + "end": { + "line": 6, + "column": 74 + } + }, + "range": [ + 189, + 212 + ], "object": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 6, + "column": 51 + }, + "end": { + "line": 6, + "column": 67 + } + }, + "range": [ + 189, + 205 + ], "object": { "type": "Identifier", - "name": "node", - "range": [ - 189, - 193 - ], "loc": { "start": { "line": 6, @@ -313,15 +495,15 @@ module.exports = { "line": 6, "column": 55 } - } + }, + "range": [ + 189, + 193 + ], + "name": "node" }, "property": { "type": "Identifier", - "name": "expressions", - "range": [ - 194, - 205 - ], "loc": { "start": { "line": 6, @@ -331,30 +513,17 @@ module.exports = { "line": 6, "column": 67 } - } - }, - "range": [ - 189, - 205 - ], - "loc": { - "start": { - "line": 6, - "column": 51 }, - "end": { - "line": 6, - "column": 67 - } - } + "range": [ + 194, + 205 + ], + "name": "expressions" + }, + "computed": false }, "property": { "type": "Identifier", - "name": "length", - "range": [ - 206, - 212 - ], "loc": { "start": { "line": 6, @@ -364,31 +533,18 @@ module.exports = { "line": 6, "column": 74 } - } - }, - "range": [ - 189, - 212 - ], - "loc": { - "start": { - "line": 6, - "column": 51 }, - "end": { - "line": 6, - "column": 74 - } - } + "range": [ + 206, + 212 + ], + "name": "length" + }, + "computed": false }, + "operator": "-", "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 215, - 216 - ], "loc": { "start": { "line": 6, @@ -398,83 +554,39 @@ module.exports = { "line": 6, "column": 78 } - } - }, - "range": [ - 189, - 216 - ], - "loc": { - "start": { - "line": 6, - "column": 51 }, - "end": { - "line": 6, - "column": 78 - } + "range": [ + 215, + 216 + ], + "value": 1, + "raw": "1" } }, - "range": [ - 172, - 217 - ], - "loc": { - "start": { - "line": 6, - "column": 34 - }, - "end": { - "line": 6, - "column": 79 - } - } - } - ], - "range": [ - 161, - 218 - ], - "loc": { - "start": { - "line": 6, - "column": 23 - }, - "end": { - "line": 6, - "column": 80 + "computed": true } - } - }, - "range": [ - 154, - 219 - ], - "loc": { - "start": { - "line": 6, - "column": 16 - }, - "end": { - "line": 6, - "column": 81 - } + ] } } ], - "range": [ - 111, - 219 - ], - "loc": { - "start": { - "line": 5, - "column": 12 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 37 + } }, - "end": { - "line": 6, - "column": 81 - } + "range": [ + 116, + 136 + ], + "value": "SequenceExpression", + "raw": "\"SequenceExpression\"" }, "trailingComments": [ { @@ -497,32 +609,26 @@ module.exports = { } ] } - ], - "range": [ - 78, - 255 - ], + ] + }, + { + "type": "ReturnStatement", "loc": { "start": { - "line": 4, + "line": 9, "column": 8 }, "end": { - "line": 8, - "column": 9 + "line": 9, + "column": 21 } - } - }, - { - "type": "ReturnStatement", + }, + "range": [ + 264, + 277 + ], "argument": { "type": "Literal", - "value": false, - "raw": "false", - "range": [ - 271, - 276 - ], "loc": { "start": { "line": 9, @@ -532,21 +638,13 @@ module.exports = { "line": 9, "column": 20 } - } - }, - "range": [ - 264, - 277 - ], - "loc": { - "start": { - "line": 9, - "column": 8 }, - "end": { - "line": 9, - "column": 21 - } + "range": [ + 271, + 276 + ], + "value": false, + "raw": "false" }, "leadingComments": [ { @@ -557,130 +655,32 @@ module.exports = { 245 ], "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 25 - } - } - } - ] - } - ], - "range": [ - 68, - 283 - ], - "loc": { - "start": { - "line": 3, - "column": 30 - }, - "end": { - "line": 10, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 42, - 283 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 10, - "column": 5 - } - } - } - ], - "range": [ - 35, - 286 - ], - "loc": { - "start": { - "line": 1, - "column": 35 - }, - "end": { - "line": 12, - "column": 1 + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 25 + } + } + } + ] + } + ] + }, + "expression": false, + "generator": false } - } + ] }, - "generator": false, "expression": false, - "range": [ - 17, - 286 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 12, - "column": 1 - } - } - }, - "range": [ - 0, - 286 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 12, - "column": 1 - } - } - }, - "range": [ - 0, - 287 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 12, - "column": 2 + "generator": false } } } ], "sourceType": "script", - "range": [ - 0, - 287 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 12, - "column": 2 - } - }, "comments": [ { "type": "Line", @@ -705,10 +705,6 @@ module.exports = { { "type": "Identifier", "value": "module", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -718,15 +714,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -736,15 +732,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "exports", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -754,15 +750,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -772,15 +768,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 17, - 25 - ], "loc": { "start": { "line": 1, @@ -790,15 +786,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 17, + 25 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -808,15 +804,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Identifier", "value": "context", - "range": [ - 26, - 33 - ], "loc": { "start": { "line": 1, @@ -826,15 +822,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 26, + 33 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -844,15 +840,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -862,15 +858,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 42, - 50 - ], "loc": { "start": { "line": 3, @@ -880,15 +876,15 @@ module.exports = { "line": 3, "column": 12 } - } + }, + "range": [ + 42, + 50 + ] }, { "type": "Identifier", "value": "isConstant", - "range": [ - 51, - 61 - ], "loc": { "start": { "line": 3, @@ -898,15 +894,15 @@ module.exports = { "line": 3, "column": 23 } - } + }, + "range": [ + 51, + 61 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 3, @@ -916,15 +912,15 @@ module.exports = { "line": 3, "column": 24 } - } + }, + "range": [ + 61, + 62 + ] }, { "type": "Identifier", "value": "node", - "range": [ - 62, - 66 - ], "loc": { "start": { "line": 3, @@ -934,15 +930,15 @@ module.exports = { "line": 3, "column": 28 } - } + }, + "range": [ + 62, + 66 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 66, - 67 - ], "loc": { "start": { "line": 3, @@ -952,15 +948,15 @@ module.exports = { "line": 3, "column": 29 } - } + }, + "range": [ + 66, + 67 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 68, - 69 - ], "loc": { "start": { "line": 3, @@ -970,15 +966,15 @@ module.exports = { "line": 3, "column": 31 } - } + }, + "range": [ + 68, + 69 + ] }, { "type": "Keyword", "value": "switch", - "range": [ - 78, - 84 - ], "loc": { "start": { "line": 4, @@ -988,15 +984,15 @@ module.exports = { "line": 4, "column": 14 } - } + }, + "range": [ + 78, + 84 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 85, - 86 - ], "loc": { "start": { "line": 4, @@ -1006,15 +1002,15 @@ module.exports = { "line": 4, "column": 16 } - } + }, + "range": [ + 85, + 86 + ] }, { "type": "Identifier", "value": "node", - "range": [ - 86, - 90 - ], "loc": { "start": { "line": 4, @@ -1024,15 +1020,15 @@ module.exports = { "line": 4, "column": 20 } - } + }, + "range": [ + 86, + 90 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 90, - 91 - ], "loc": { "start": { "line": 4, @@ -1042,15 +1038,15 @@ module.exports = { "line": 4, "column": 21 } - } + }, + "range": [ + 90, + 91 + ] }, { "type": "Identifier", "value": "type", - "range": [ - 91, - 95 - ], "loc": { "start": { "line": 4, @@ -1060,15 +1056,15 @@ module.exports = { "line": 4, "column": 25 } - } + }, + "range": [ + 91, + 95 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 95, - 96 - ], "loc": { "start": { "line": 4, @@ -1078,15 +1074,15 @@ module.exports = { "line": 4, "column": 26 } - } + }, + "range": [ + 95, + 96 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 97, - 98 - ], "loc": { "start": { "line": 4, @@ -1096,15 +1092,15 @@ module.exports = { "line": 4, "column": 28 } - } + }, + "range": [ + 97, + 98 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 111, - 115 - ], "loc": { "start": { "line": 5, @@ -1114,15 +1110,15 @@ module.exports = { "line": 5, "column": 16 } - } + }, + "range": [ + 111, + 115 + ] }, { "type": "String", "value": "\"SequenceExpression\"", - "range": [ - 116, - 136 - ], "loc": { "start": { "line": 5, @@ -1132,15 +1128,15 @@ module.exports = { "line": 5, "column": 37 } - } + }, + "range": [ + 116, + 136 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 136, - 137 - ], "loc": { "start": { "line": 5, @@ -1150,15 +1146,15 @@ module.exports = { "line": 5, "column": 38 } - } + }, + "range": [ + 136, + 137 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 154, - 160 - ], "loc": { "start": { "line": 6, @@ -1168,15 +1164,15 @@ module.exports = { "line": 6, "column": 22 } - } + }, + "range": [ + 154, + 160 + ] }, { "type": "Identifier", "value": "isConstant", - "range": [ - 161, - 171 - ], "loc": { "start": { "line": 6, @@ -1186,15 +1182,15 @@ module.exports = { "line": 6, "column": 33 } - } + }, + "range": [ + 161, + 171 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 171, - 172 - ], "loc": { "start": { "line": 6, @@ -1204,15 +1200,15 @@ module.exports = { "line": 6, "column": 34 } - } + }, + "range": [ + 171, + 172 + ] }, { "type": "Identifier", "value": "node", - "range": [ - 172, - 176 - ], "loc": { "start": { "line": 6, @@ -1222,15 +1218,15 @@ module.exports = { "line": 6, "column": 38 } - } + }, + "range": [ + 172, + 176 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 176, - 177 - ], "loc": { "start": { "line": 6, @@ -1240,15 +1236,15 @@ module.exports = { "line": 6, "column": 39 } - } + }, + "range": [ + 176, + 177 + ] }, { "type": "Identifier", "value": "expressions", - "range": [ - 177, - 188 - ], "loc": { "start": { "line": 6, @@ -1258,15 +1254,15 @@ module.exports = { "line": 6, "column": 50 } - } + }, + "range": [ + 177, + 188 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 188, - 189 - ], "loc": { "start": { "line": 6, @@ -1276,15 +1272,15 @@ module.exports = { "line": 6, "column": 51 } - } + }, + "range": [ + 188, + 189 + ] }, { "type": "Identifier", "value": "node", - "range": [ - 189, - 193 - ], "loc": { "start": { "line": 6, @@ -1294,15 +1290,15 @@ module.exports = { "line": 6, "column": 55 } - } + }, + "range": [ + 189, + 193 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 193, - 194 - ], "loc": { "start": { "line": 6, @@ -1312,15 +1308,15 @@ module.exports = { "line": 6, "column": 56 } - } + }, + "range": [ + 193, + 194 + ] }, { "type": "Identifier", "value": "expressions", - "range": [ - 194, - 205 - ], "loc": { "start": { "line": 6, @@ -1330,15 +1326,15 @@ module.exports = { "line": 6, "column": 67 } - } + }, + "range": [ + 194, + 205 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 205, - 206 - ], "loc": { "start": { "line": 6, @@ -1348,15 +1344,15 @@ module.exports = { "line": 6, "column": 68 } - } + }, + "range": [ + 205, + 206 + ] }, { "type": "Identifier", "value": "length", - "range": [ - 206, - 212 - ], "loc": { "start": { "line": 6, @@ -1366,15 +1362,15 @@ module.exports = { "line": 6, "column": 74 } - } + }, + "range": [ + 206, + 212 + ] }, { "type": "Punctuator", "value": "-", - "range": [ - 213, - 214 - ], "loc": { "start": { "line": 6, @@ -1384,15 +1380,15 @@ module.exports = { "line": 6, "column": 76 } - } + }, + "range": [ + 213, + 214 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 215, - 216 - ], "loc": { "start": { "line": 6, @@ -1402,15 +1398,15 @@ module.exports = { "line": 6, "column": 78 } - } + }, + "range": [ + 215, + 216 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 216, - 217 - ], "loc": { "start": { "line": 6, @@ -1420,15 +1416,15 @@ module.exports = { "line": 6, "column": 79 } - } + }, + "range": [ + 216, + 217 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 217, - 218 - ], "loc": { "start": { "line": 6, @@ -1438,15 +1434,15 @@ module.exports = { "line": 6, "column": 80 } - } + }, + "range": [ + 217, + 218 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 218, - 219 - ], "loc": { "start": { "line": 6, @@ -1456,15 +1452,15 @@ module.exports = { "line": 6, "column": 81 } - } + }, + "range": [ + 218, + 219 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 254, - 255 - ], "loc": { "start": { "line": 8, @@ -1474,15 +1470,15 @@ module.exports = { "line": 8, "column": 9 } - } + }, + "range": [ + 254, + 255 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 264, - 270 - ], "loc": { "start": { "line": 9, @@ -1492,15 +1488,15 @@ module.exports = { "line": 9, "column": 14 } - } + }, + "range": [ + 264, + 270 + ] }, { "type": "Boolean", "value": "false", - "range": [ - 271, - 276 - ], "loc": { "start": { "line": 9, @@ -1510,15 +1506,15 @@ module.exports = { "line": 9, "column": 20 } - } + }, + "range": [ + 271, + 276 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 276, - 277 - ], "loc": { "start": { "line": 9, @@ -1528,15 +1524,15 @@ module.exports = { "line": 9, "column": 21 } - } + }, + "range": [ + 276, + 277 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 282, - 283 - ], "loc": { "start": { "line": 10, @@ -1546,15 +1542,15 @@ module.exports = { "line": 10, "column": 5 } - } + }, + "range": [ + 282, + 283 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 285, - 286 - ], "loc": { "start": { "line": 12, @@ -1564,15 +1560,15 @@ module.exports = { "line": 12, "column": 1 } - } + }, + "range": [ + 285, + 286 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 286, - 287 - ], "loc": { "start": { "line": 12, @@ -1582,7 +1578,11 @@ module.exports = { "line": 12, "column": 2 } - } + }, + "range": [ + 286, + 287 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/attach-comments/switch-no-default-comment.result.js b/tests/fixtures/attach-comments/switch-no-default-comment.result.js index fba879b1..3ab984db 100644 --- a/tests/fixtures/attach-comments/switch-no-default-comment.result.js +++ b/tests/fixtures/attach-comments/switch-no-default-comment.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 0, + 39 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 58 + ], "discriminant": { "type": "Identifier", - "name": "a", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -19,38 +42,33 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "a" }, "cases": [ { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 22, - 23 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 14 } }, + "range": [ + 17, + 39 + ], "consequent": [ { "type": "BreakStatement", - "label": null, - "range": [ - 33, - 39 - ], "loc": { "start": { "line": 3, @@ -60,22 +78,32 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 33, + 39 + ], + "label": null } ], - "range": [ - 17, - 39 - ], - "loc": { - "start": { - "line": 2, - "column": 4 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } }, - "end": { - "line": 3, - "column": 14 - } + "range": [ + 22, + 23 + ], + "value": 1, + "raw": "1" }, "trailingComments": [ { @@ -98,38 +126,10 @@ module.exports = { } ] } - ], - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } + ] } ], "sourceType": "script", - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, "comments": [ { "type": "Line", @@ -154,10 +154,6 @@ module.exports = { { "type": "Keyword", "value": "switch", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -167,15 +163,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -185,15 +181,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -203,15 +199,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -221,15 +217,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -239,15 +235,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 2, @@ -257,15 +253,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 17, + 21 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 2, @@ -275,15 +271,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 2, @@ -293,15 +289,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Keyword", "value": "break", - "range": [ - 33, - 38 - ], "loc": { "start": { "line": 3, @@ -311,15 +307,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 33, + 38 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 3, @@ -329,15 +325,15 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 57, - 58 - ], "loc": { "start": { "line": 5, @@ -347,7 +343,11 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 57, + 58 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js index 36812d46..561edb15 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js @@ -121,7 +121,7 @@ module.exports = { } }, "kind": "method", - "computed": false, + "computed": true, "range": [ 13, 38 @@ -439,4 +439,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/error-generator.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/error-generator.result.js index 37accdbf..4b195c07 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/error-generator.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/error-generator.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 16, "lineNumber": 2, "column": 5, - "description": "Unexpected token *" -}; \ No newline at end of file + "message": "Unexpected token *" +}; diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/error-no-class.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/error-no-class.result.js index 65f17042..28e10338 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/error-no-class.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/error-no-class.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 0, "lineNumber": 1, "column": 1, - "description": "Unexpected reserved word" -}; \ No newline at end of file + "message": "Unexpected reserved word" +}; diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/error-static-no-generators.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/error-static-no-generators.result.js index 8136c680..8e587ffd 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/error-static-no-generators.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/error-static-no-generators.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 20, "lineNumber": 2, "column": 9, - "description": "Unexpected token *" -}; \ No newline at end of file + "message": "Unexpected token *" +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-array.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-array.result.js index 419655d1..f82d2685 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-array.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-array.result.js @@ -12,7 +12,6 @@ module.exports = { "elements": [ { "type": "AssignmentPattern", - "operator": "=", "left": { "type": "Identifier", "name": "x", @@ -312,4 +311,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object-nested.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object-nested.result.js index 6caa33ba..90dec70c 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object-nested.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object-nested.result.js @@ -32,7 +32,6 @@ module.exports = { }, "value": { "type": "AssignmentPattern", - "operator": "=", "left": { "type": "Identifier", "name": "x", @@ -149,7 +148,6 @@ module.exports = { }, "value": { "type": "AssignmentPattern", - "operator": "=", "left": { "type": "Identifier", "name": "z", @@ -756,4 +754,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object.result.js index 9cefec41..4115ffae 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-arrowFunctions/param-defaults-object.result.js @@ -32,7 +32,6 @@ module.exports = { }, "value": { "type": "AssignmentPattern", - "operator": "=", "left": { "type": "Identifier", "name": "x", @@ -351,4 +350,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-experimentalObjectRestSpread/invalid-rest.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-experimentalObjectRestSpread/invalid-rest.result.js index 8af0d6b7..96d82563 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-experimentalObjectRestSpread/invalid-rest.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-experimentalObjectRestSpread/invalid-rest.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 24, + "index": 18, "lineNumber": 1, - "column": 25, - "description": "Invalid object rest." -}; \ No newline at end of file + "column": 19, + "message": "Unexpected token ." +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.result.js deleted file mode 100644 index 9de7e013..00000000 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.result.js +++ /dev/null @@ -1,496 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "ArrayPattern", - "elements": [ - { - "type": "SpreadElement", - "argument": { - "type": "Identifier", - "name": "c", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "range": [ - 1, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - } - }, - "value": { - "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - } - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "b", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "value": { - "type": "Identifier", - "name": "b", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - } - ], - "range": [ - 7, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 15 - } - } - } - ], - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - } - }, - "right": { - "type": "Identifier", - "name": "d", - "range": [ - 19, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "tokens": [ - { - "type": "Punctuator", - "value": "[", - "range": [ - 0, - 1 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": "...", - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 4 - } - } - }, - { - "type": "Identifier", - "value": "c", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": ",", - "range": [ - 5, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 7, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - { - "type": "Identifier", - "value": "a", - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - } - }, - { - "type": "Punctuator", - "value": ",", - "range": [ - 10, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 11 - } - } - }, - { - "type": "Identifier", - "value": "b", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 14, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 15 - } - } - }, - { - "type": "Punctuator", - "value": "]", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 16 - } - } - }, - { - "type": "Punctuator", - "value": "=", - "range": [ - 17, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 18 - } - } - }, - { - "type": "Identifier", - "value": "d", - "range": [ - 19, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 20 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 20, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 21 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured.result.js index d0133311..dc67f75b 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured.result.js @@ -143,7 +143,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "c", @@ -493,4 +493,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructured-array-literal.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructured-array-literal.result.js index 4b668f23..15e5387f 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructured-array-literal.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructured-array-literal.result.js @@ -28,7 +28,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "ArrayPattern", "elements": [ @@ -415,4 +415,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.config.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.config.js similarity index 100% rename from tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.config.js rename to tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.config.js diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.result.js new file mode 100644 index 00000000..25c29996 --- /dev/null +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.result.js @@ -0,0 +1,511 @@ +module.exports = { + "type": "Program", + "body": [ + { + "type": "FunctionDeclaration", + "id": { + "type": "Identifier", + "name": "a", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + "params": [ + { + "type": "ArrayPattern", + "elements": [ + { + "type": "Identifier", + "name": "a", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "b", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + { + "type": "RestElement", + "argument": { + "type": "ArrayPattern", + "elements": [ + { + "type": "Identifier", + "name": "ok", + "range": [ + 22, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + ], + "range": [ + 21, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "range": [ + 18, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ], + "range": [ + 11, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 0, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "EmptyStatement", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + } + } + ], + "sourceType": "script", + "range": [ + 0, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "tokens": [ + { + "type": "Keyword", + "value": "function", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "a", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 10, + 11 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 11, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "a", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + { + "type": "Identifier", + "value": "b", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "...", + "range": [ + 18, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Identifier", + "value": "ok", + "range": [ + 22, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.src.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.src.js similarity index 100% rename from tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.src.js rename to tests/fixtures/ecma-features-mix/destructuring-and-spread/destructuring-param.src.js diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.config.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.config.js similarity index 100% rename from tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.config.js rename to tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.config.js diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.result.js new file mode 100644 index 00000000..b833630a --- /dev/null +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.result.js @@ -0,0 +1,6 @@ +module.exports = { + index: 1, + column: 2, + lineNumber: 1, + message: "Assigning to rvalue" +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.src.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.src.js similarity index 100% rename from tests/fixtures/ecma-features-mix/destructuring-and-spread/complex-destructured-spread-first.src.js rename to tests/fixtures/ecma-features-mix/destructuring-and-spread/error-complex-destructured-spread-first.src.js diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.result.js deleted file mode 100644 index 4505ad5f..00000000 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/error-destructuring-param.result.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - "index": 26, - "lineNumber": 1, - "column": 27, - "description": "Invalid left-hand side in formals list" -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/multi-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/multi-destructured.result.js index c4acf883..d639c804 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/multi-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/multi-destructured.result.js @@ -28,7 +28,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "b", @@ -306,4 +306,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array-empty.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array-empty.result.js index 3ce9eb82..c54ecee9 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array-empty.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array-empty.result.js @@ -10,7 +10,7 @@ module.exports = { "type": "ArrayPattern", "elements": [ { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "a", @@ -270,4 +270,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array.result.js index bbaa4cac..b833630a 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/not-final-array.result.js @@ -1,309 +1,6 @@ module.exports = { - "type": "Program", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "ArrayPattern", - "elements": [ - { - "type": "SpreadElement", - "argument": { - "type": "Identifier", - "name": "a", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "range": [ - 1, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Identifier", - "name": "b", - "range": [ - 7, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 8 - } - } - } - ], - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - "right": { - "type": "Identifier", - "name": "c", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, - "tokens": [ - { - "type": "Punctuator", - "value": "[", - "range": [ - 0, - 1 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": "...", - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 4 - } - } - }, - { - "type": "Identifier", - "value": "a", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": ",", - "range": [ - 5, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - } - } - }, - { - "type": "Identifier", - "value": "b", - "range": [ - 7, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - { - "type": "Punctuator", - "value": "]", - "range": [ - 8, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - { - "type": "Punctuator", - "value": "=", - "range": [ - 10, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 11 - } - } - }, - { - "type": "Identifier", - "value": "c", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 13, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 14 - } - } - } - ] -}; \ No newline at end of file + index: 1, + column: 2, + lineNumber: 1, + message: "Assigning to rvalue" +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/single-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/single-destructured.result.js index 9595de1b..5e6629e7 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/single-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/single-destructured.result.js @@ -10,7 +10,7 @@ module.exports = { "type": "ArrayPattern", "elements": [ { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "a", @@ -252,4 +252,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-complex-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-complex-destructured.result.js index 80b5ec6d..bb7d46b4 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-complex-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-complex-destructured.result.js @@ -143,7 +143,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "c", @@ -513,4 +513,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-destructured-array-literal.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-destructured-array-literal.result.js index 94e6905e..b75cd2d5 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-destructured-array-literal.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-destructured-array-literal.result.js @@ -28,7 +28,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "ArrayPattern", "elements": [ @@ -435,4 +435,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-multi-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-multi-destructured.result.js index 05876a2c..ec1b7c67 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-multi-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-multi-destructured.result.js @@ -28,7 +28,7 @@ module.exports = { } }, { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "b", @@ -326,4 +326,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-single-destructured.result.js b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-single-destructured.result.js index de7384e5..7498e1cb 100644 --- a/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-single-destructured.result.js +++ b/tests/fixtures/ecma-features-mix/destructuring-and-spread/var-single-destructured.result.js @@ -10,7 +10,7 @@ module.exports = { "type": "ArrayPattern", "elements": [ { - "type": "SpreadElement", + "type": "RestElement", "argument": { "type": "Identifier", "name": "a", @@ -272,4 +272,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.config.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.config.js deleted file mode 100644 index 1b19fb64..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - forOf: true -}; diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.result.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.result.js deleted file mode 100644 index 41107d21..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.result.js +++ /dev/null @@ -1,420 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "ForInStatement", - "left": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "k", - "range": [ - 17, - 18 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } - } - }, - "init": null, - "range": [ - 17, - 18 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } - } - } - ], - "kind": "var", - "range": [ - 13, - 18 - ], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 10 - } - } - }, - "right": { - "type": "Identifier", - "name": "console", - "range": [ - 22, - 29 - ], - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 2, - "column": 21 - } - } - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "doSomething", - "range": [ - 37, - 48 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - "arguments": [], - "range": [ - 37, - 50 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - "range": [ - 37, - 51 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 18 - } - } - } - ], - "range": [ - 31, - 53 - ], - "loc": { - "start": { - "line": 2, - "column": 23 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "each": false, - "range": [ - 8, - 53 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - } - ], - "sourceType": "script", - "range": [ - 8, - 53 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "for", - "range": [ - 8, - 11 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, - { - "type": "Keyword", - "value": "var", - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 8 - } - } - }, - { - "type": "Identifier", - "value": "k", - "range": [ - 17, - 18 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } - } - }, - { - "type": "Keyword", - "value": "in", - "range": [ - 19, - 21 - ], - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - { - "type": "Identifier", - "value": "console", - "range": [ - 22, - 29 - ], - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 2, - "column": 21 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 29, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 2, - "column": 23 - }, - "end": { - "line": 2, - "column": 24 - } - } - }, - { - "type": "Identifier", - "value": "doSomething", - "range": [ - 37, - 48 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 48, - 49 - ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 49, - 50 - ], - "loc": { - "start": { - "line": 3, - "column": 16 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 50, - 51 - ], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 52, - 53 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.src.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.src.js deleted file mode 100644 index 027cc150..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring-inline.src.js +++ /dev/null @@ -1,4 +0,0 @@ -//var k -for (var k in console) { - doSomething(); -} diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.config.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.config.js deleted file mode 100644 index 1b19fb64..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - forOf: true -}; diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.result.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.result.js deleted file mode 100644 index 59b9a9b7..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.result.js +++ /dev/null @@ -1,474 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "k", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "init": null, - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - } - ], - "kind": "var", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - } - }, - { - "type": "ForInStatement", - "left": { - "type": "Identifier", - "name": "k", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "right": { - "type": "Identifier", - "name": "console", - "range": [ - 17, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 17 - } - } - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "doSomething", - "range": [ - 32, - 43 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - "arguments": [], - "range": [ - 32, - 45 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - "range": [ - 32, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 18 - } - } - } - ], - "range": [ - 26, - 48 - ], - "loc": { - "start": { - "line": 2, - "column": 19 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "each": false, - "range": [ - 7, - 48 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 48 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "var", - "range": [ - 0, - 3 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 3 - } - } - }, - { - "type": "Identifier", - "value": "k", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 5, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - } - } - }, - { - "type": "Keyword", - "value": "for", - "range": [ - 7, - 10 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 11, - 12 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, - { - "type": "Identifier", - "value": "k", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - { - "type": "Keyword", - "value": "in", - "range": [ - 14, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 9 - } - } - }, - { - "type": "Identifier", - "value": "console", - "range": [ - 17, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 24, - 25 - ], - "loc": { - "start": { - "line": 2, - "column": 17 - }, - "end": { - "line": 2, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 26, - 27 - ], - "loc": { - "start": { - "line": 2, - "column": 19 - }, - "end": { - "line": 2, - "column": 20 - } - } - }, - { - "type": "Identifier", - "value": "doSomething", - "range": [ - 32, - 43 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 43, - 44 - ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 44, - 45 - ], - "loc": { - "start": { - "line": 3, - "column": 16 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 45, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 47, - 48 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.src.js b/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.src.js deleted file mode 100644 index 4dc6ebed..00000000 --- a/tests/fixtures/ecma-features-mix/forOf-operator/for-of-declaring.src.js +++ /dev/null @@ -1,4 +0,0 @@ -var k; -for (k in console) { - doSomething(); -} diff --git a/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-const-object.result.js b/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-const-object.result.js index 4446cb2c..a302a904 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-const-object.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-const-object.result.js @@ -63,7 +63,7 @@ module.exports = { "kind": "const", "range": [ 7, - 22 + 21 ], "loc": { "start": { @@ -71,8 +71,8 @@ module.exports = { "column": 7 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 21 } } }, @@ -80,7 +80,7 @@ module.exports = { "source": null, "range": [ 0, - 22 + 21 ], "loc": { "start": { @@ -88,8 +88,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 21 } } } @@ -97,7 +97,7 @@ module.exports = { "sourceType": "module", "range": [ 0, - 22 + 21 ], "loc": { "start": { @@ -105,8 +105,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 21 } }, "tokens": [ @@ -219,4 +219,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-let-object.result.js b/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-let-object.result.js index d6bfd302..c4f1c05c 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-let-object.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-blockBindings/export-let-object.result.js @@ -63,7 +63,7 @@ module.exports = { "kind": "let", "range": [ 7, - 20 + 19 ], "loc": { "start": { @@ -71,8 +71,8 @@ module.exports = { "column": 7 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 19 } } }, @@ -80,7 +80,7 @@ module.exports = { "source": null, "range": [ 0, - 20 + 19 ], "loc": { "start": { @@ -88,8 +88,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 19 } } } @@ -97,7 +97,7 @@ module.exports = { "sourceType": "module", "range": [ 0, - 20 + 19 ], "loc": { "start": { @@ -105,8 +105,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 19 } }, "tokens": [ @@ -219,4 +219,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/error-no-shorthand.result.js b/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/error-no-shorthand.result.js index b488b174..bf0222cc 100644 --- a/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/error-no-shorthand.result.js +++ b/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/error-no-shorthand.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 10, "lineNumber": 1, "column": 11, - "description": "Unexpected token *" -}; \ No newline at end of file + "message": "Unexpected token *" +}; diff --git a/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/generator-object-literal-method.result.js b/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/generator-object-literal-method.result.js index 47ba7033..a2685d85 100644 --- a/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/generator-object-literal-method.result.js +++ b/tests/fixtures/ecma-features-mix/objectLiteralShorthandMethods-and-generators/generator-object-literal-method.result.js @@ -94,7 +94,7 @@ module.exports = { }, "range": [ 21, - 30 + 29 ], "loc": { "start": { @@ -103,7 +103,7 @@ module.exports = { }, "end": { "line": 1, - "column": 30 + "column": 29 } } } @@ -495,4 +495,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/spread-and-arrowFunctions/invalid-arrow-rest-params.result.js b/tests/fixtures/ecma-features-mix/spread-and-arrowFunctions/invalid-arrow-rest-params.result.js index b084cd64..376a1438 100644 --- a/tests/fixtures/ecma-features-mix/spread-and-arrowFunctions/invalid-arrow-rest-params.result.js +++ b/tests/fixtures/ecma-features-mix/spread-and-arrowFunctions/invalid-arrow-rest-params.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 17, + "index": 12, "lineNumber": 1, - "column": 18, - "description": "Unexpected token ." -}; \ No newline at end of file + "column": 13, + "message": "Unexpected token ..." +}; diff --git a/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx-multi.result.js b/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx-multi.result.js index d8a73737..26dbb21e 100644 --- a/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx-multi.result.js +++ b/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx-multi.result.js @@ -256,7 +256,7 @@ module.exports = { }, "range": [ 0, - 20 + 19 ], "loc": { "start": { @@ -264,8 +264,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 19 } } } @@ -273,7 +273,7 @@ module.exports = { "sourceType": "script", "range": [ 0, - 20 + 19 ], "loc": { "start": { @@ -281,8 +281,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 19 } }, "tokens": [ @@ -557,4 +557,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx.result.js b/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx.result.js index a7c45bec..7293ee25 100644 --- a/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx.result.js +++ b/tests/fixtures/ecma-features-mix/templateStrings-and-jsx/template-strings-in-jsx.result.js @@ -197,7 +197,7 @@ module.exports = { }, "range": [ 0, - 23 + 22 ], "loc": { "start": { @@ -205,8 +205,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 22 } } } @@ -214,7 +214,7 @@ module.exports = { "sourceType": "script", "range": [ 0, - 23 + 22 ], "loc": { "start": { @@ -222,8 +222,8 @@ module.exports = { "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 22 } }, "tokens": [ @@ -426,4 +426,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/arrowFunctions/as-param-with-params.result.js b/tests/fixtures/ecma-features/arrowFunctions/as-param-with-params.result.js index c86d6966..84bb1306 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/as-param-with-params.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/as-param-with-params.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "callee": { "type": "Identifier", - "name": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,20 +58,36 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "foo" }, "arguments": [ { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 4, + 16 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -44,15 +97,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, { "type": "Identifier", - "name": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -62,16 +115,16 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "y" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -81,80 +134,23 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "generator": false, - "expression": false, - "range": [ - 4, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 14, + 16 + ], + "body": [] } } - ], - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - } - }, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - }, "tokens": [ { "type": "Identifier", "value": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 11, - 13 - ], "loc": { "start": { "line": 1, @@ -290,15 +286,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 11, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -344,15 +340,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -362,7 +358,11 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/as-param.result.js b/tests/fixtures/ecma-features/arrowFunctions/as-param.result.js index 0f193c85..2221e208 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/as-param.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/as-param.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "callee": { "type": "Identifier", - "name": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,20 +58,36 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "foo" }, "arguments": [ { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -44,80 +97,23 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "generator": false, - "expression": false, - "range": [ - 4, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 10, + 12 + ], + "body": [] } } - ], - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, "tokens": [ { "type": "Identifier", "value": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -271,7 +267,11 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/basic.result.js b/tests/fixtures/ecma-features/arrowFunctions/basic.result.js index 1df9f95b..2ccbb764 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/basic.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/basic.result.js @@ -1,20 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "id": null, + "generator": false, + "expression": true, "params": [], "body": { "type": "Literal", - "value": "test", - "raw": "\"test\"", - "range": [ - 6, - 12 - ], "loc": { "start": { "line": 1, @@ -24,64 +62,22 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 + "range": [ + 6, + 12 + ], + "value": "test", + "raw": "\"test\"" } } } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -91,15 +87,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -109,15 +105,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 3, - 5 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 3, + 5 + ] }, { "type": "String", "value": "\"test\"", - "range": [ - 6, - 12 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 6, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -163,7 +159,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/block-body-not-object.result.js b/tests/fixtures/ecma-features/arrowFunctions/block-body-not-object.result.js index 206d4cb4..cdb18288 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/block-body-not-object.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/block-body-not-object.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -23,42 +62,65 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "e" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 5, + 18 + ], "body": [ { "type": "LabeledStatement", - "label": { - "type": "Identifier", - "name": "label", - "range": [ - 7, - 12 - ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 7, + 16 + ], + "body": { + "type": "ExpressionStatement", "loc": { "start": { "line": 1, - "column": 7 + "column": 14 }, "end": { "line": 1, - "column": 12 + "column": 16 } - } - }, - "body": { - "type": "ExpressionStatement", + }, + "range": [ + 14, + 16 + ], "expression": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -68,110 +130,44 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 14, - 17 - ], + }, + "range": [ + 14, + 16 + ], + "value": 42, + "raw": "42" + } + }, + "label": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 14 + "column": 7 }, "end": { "line": 1, - "column": 17 + "column": 12 } - } - }, - "range": [ - 7, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 17 - } + "range": [ + 7, + 12 + ], + "name": "label" } } - ], - "range": [ - 5, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Identifier", "value": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 2, - 4 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 2, + 4 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Identifier", "value": "label", - "range": [ - 7, - 12 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 7, + 12 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 14, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -307,7 +303,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/block-body.result.js b/tests/fixtures/ecma-features/arrowFunctions/block-body.result.js index 638f482e..ccbffc2b 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/block-body.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/block-body.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -23,22 +62,49 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "e" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 5, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], "expression": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -48,95 +114,25 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "range": [ - 7, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 10 - } + "range": [ + 7, + 9 + ], + "value": 42, + "raw": "42" } } - ], - "range": [ - 5, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Identifier", "value": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 2, - 4 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 2, + 4 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -254,7 +250,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-dup-params.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-dup-params.result.js index 0aa59b06..5d4b9d85 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-dup-params.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-dup-params.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 6, + "index": 4, "lineNumber": 1, - "column": 7, - "description": "Strict mode function may not have duplicate parameter names" + "column": 5, + "message": "Argument name clash" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-missing-paren.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-missing-paren.result.js index 552ef095..310984a6 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-missing-paren.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-missing-paren.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 9, + "index": 4, "lineNumber": 1, - "column": 10, - "description": "Unexpected token =>" + "column": 5, + "message": "Unexpected token (" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-not-arrow.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-not-arrow.result.js index 90842aa9..9b47c568 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-not-arrow.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-not-arrow.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 26, "lineNumber": 1, "column": 27, - "description": "Unexpected token )" + "message": "Unexpected token )" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.result.js index 552ef095..fc835158 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 9, + "index": 1, "lineNumber": 1, - "column": 10, - "description": "Unexpected token =>" + "column": 2, + "message": "Assigning to rvalue" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.src.js b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.src.js index eded1920..e4b6d390 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.src.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param-multi.src.js @@ -1 +1 @@ -(10, 20) => 00; \ No newline at end of file +(10, 20) => 0; diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.result.js index 80006117..fc835158 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 5, + "index": 1, "lineNumber": 1, - "column": 6, - "description": "Unexpected token =>" + "column": 2, + "message": "Assigning to rvalue" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.src.js b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.src.js index 614fffcc..0ce82a50 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.src.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-numeric-param.src.js @@ -1 +1 @@ -(10) => 00; \ No newline at end of file +(10) => 0; diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-reverse-arrow.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-reverse-arrow.result.js index bea239aa..90dd78ab 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-reverse-arrow.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-reverse-arrow.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 3, + "index": 1, "lineNumber": 1, - "column": 4, - "description": "Unexpected token <=" + "column": 2, + "message": "Unexpected token )" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-default-param-eval.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-default-param-eval.result.js index 844301cf..431716c6 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-default-param-eval.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-default-param-eval.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 15, "lineNumber": 1, "column": 16, - "description": "Assignment to eval or arguments is not allowed in strict mode" + "message": "Assigning to eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-dup-params.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-dup-params.result.js index c5223fc5..c3f08bb3 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-dup-params.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-dup-params.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 20, + "index": 18, "lineNumber": 1, - "column": 21, - "description": "Strict mode function may not have duplicate parameter names" + "column": 19, + "message": "Argument name clash" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval-return.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval-return.result.js index 1e3721b1..d7e7dda5 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval-return.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval-return.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 26, + "index": 15, "lineNumber": 1, - "column": 27, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 16, + "message": "Binding eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval.result.js index de5fb84e..f542ae32 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-eval.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 30, + "index": 1, "lineNumber": 1, - "column": 31, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 2, + "message": "Binding eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-octal.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-octal.result.js index ccbebd75..6eedac5c 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-octal.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-octal.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 21, "lineNumber": 1, "column": 22, - "description": "Octal literals are not allowed in strict mode." + "message": "Invalid number" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-arguments.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-arguments.result.js index 69ee0d84..875b7471 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-arguments.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-arguments.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 34, + "index": 15, "lineNumber": 1, - "column": 35, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 16, + "message": "Binding arguments in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-eval.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-eval.result.js index 906d608e..d7e7dda5 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-eval.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-eval.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 29, + "index": 15, "lineNumber": 1, - "column": 30, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 16, + "message": "Binding eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-names.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-names.result.js index 906d608e..d7e7dda5 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-names.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-names.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 29, + "index": 15, "lineNumber": 1, - "column": 30, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 16, + "message": "Binding eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-arguments.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-arguments.result.js index 906d608e..bbdeb9a4 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-arguments.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-arguments.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 29, + "index": 14, "lineNumber": 1, - "column": 30, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 15, + "message": "Binding arguments in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-eval.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-eval.result.js index 3a16b5b9..1d1998fa 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-eval.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-strict-param-no-paren-eval.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 24, + "index": 14, "lineNumber": 1, - "column": 25, - "description": "Parameter name eval or arguments is not allowed in strict mode" + "column": 15, + "message": "Binding eval in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-two-lines.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-two-lines.result.js index cf55ca1d..a74418b6 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-two-lines.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-two-lines.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 14, - "lineNumber": 2, - "column": 4, - "description": "Unexpected token =>" + "index": 9, + "lineNumber": 1, + "column": 10, + "message": "Unexpected token )" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/error-wrapped-param.result.js b/tests/fixtures/ecma-features/arrowFunctions/error-wrapped-param.result.js index 02a8e4c3..dce37a90 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/error-wrapped-param.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/error-wrapped-param.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 6, + "index": 1, "lineNumber": 1, - "column": 7, - "description": "Unexpected token =>" + "column": 2, + "message": "Unexpected token (" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/expression.result.js b/tests/fixtures/ecma-features/arrowFunctions/expression.result.js index 9937e9df..51eeaeaf 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/expression.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/expression.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 1, + 7 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,16 +62,16 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "x" } ], "body": { "type": "Identifier", - "name": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -42,64 +81,21 @@ module.exports = { "line": 1, "column": 7 } - } - }, - "generator": false, - "expression": true, - "range": [ - 1, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 7 - } - } - }, - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 + "range": [ + 6, + 7 + ], + "name": "x" } } } ], "sourceType": "script", - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -109,15 +105,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 3, - 5 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 3, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -199,7 +195,11 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/iife.result.js b/tests/fixtures/ecma-features/arrowFunctions/iife.result.js index 66ece4c5..4f81cb16 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/iife.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/iife.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -23,21 +62,52 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "e" } ], "body": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 6, + 22 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 8, + 20 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "property", - "range": [ - 8, - 16 - ], "loc": { "start": { "line": 1, @@ -47,16 +117,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 8, + 16 + ], + "name": "property" }, "value": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -66,99 +135,26 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 8, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 20 - } - } - } - ], - "range": [ - 6, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 22 + "range": [ + 18, + 20 + ], + "value": 42, + "raw": "42" + }, + "kind": "init" } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Identifier", "value": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -168,15 +164,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 2, - 4 - ], "loc": { "start": { "line": 1, @@ -186,15 +182,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 2, + 4 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -204,15 +200,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "property", - "range": [ - 8, - 16 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 8, + 16 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -276,15 +272,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 18, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -294,15 +290,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -312,15 +308,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -330,7 +326,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/multiple-params.result.js b/tests/fixtures/ecma-features/arrowFunctions/multiple-params.result.js index cf330e6f..936fcec2 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/multiple-params.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/multiple-params.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,15 +62,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, { "type": "Identifier", - "name": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -41,17 +80,16 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "b" } ], "body": { "type": "Literal", - "value": "test", - "raw": "\"test\"", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 1, @@ -61,64 +99,22 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 16 - } - } - }, - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 + "range": [ + 10, + 16 + ], + "value": "test", + "raw": "\"test\"" } } } ], "sourceType": "script", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "String", "value": "\"test\"", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 10, + 16 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -254,7 +250,11 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/no-auto-return.result.js b/tests/fixtures/ecma-features/arrowFunctions/no-auto-return.result.js index 44db2085..c0effed7 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/no-auto-return.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/no-auto-return.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,15 +62,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, { "type": "Identifier", - "name": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -41,22 +80,49 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "b" } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 10, + 17 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 12, + 15 + ], "expression": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -66,95 +132,25 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 12, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 12, + 14 + ], + "value": 42, + "raw": "42" } } - ], - "range": [ - 10, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 17 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - } - }, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -290,15 +286,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -344,7 +340,11 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/not-strict-arguments.result.js b/tests/fixtures/ecma-features/arrowFunctions/not-strict-arguments.result.js index 25fb6698..56728311 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/not-strict-arguments.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/not-strict-arguments.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "arguments", - "range": [ - 0, - 9 - ], "loc": { "start": { "line": 1, @@ -23,17 +62,16 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 0, + 9 + ], + "name": "arguments" } ], "body": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -43,64 +81,22 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 15 - } - } - }, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 + "range": [ + 13, + 15 + ], + "value": 42, + "raw": "42" } } } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Identifier", "value": "arguments", - "range": [ - 0, - 9 - ], "loc": { "start": { "line": 1, @@ -110,15 +106,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 0, + 9 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 10, + 12 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 13, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -164,7 +160,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval-params.result.js b/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval-params.result.js index 50cfc95d..b0945590 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval-params.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval-params.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "eval", - "range": [ - 1, - 5 - ], "loc": { "start": { "line": 1, @@ -23,15 +62,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 1, + 5 + ], + "name": "eval" }, { "type": "Identifier", - "name": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -41,17 +80,16 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ], + "name": "a" } ], "body": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -61,64 +99,22 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 15 - } - } - }, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 + "range": [ + 13, + 15 + ], + "value": 42, + "raw": "42" } } } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "eval", - "range": [ - 1, - 5 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 1, + 5 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 10, + 12 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 13, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -254,7 +250,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval.result.js b/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval.result.js index 6211d13d..9c396d94 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/not-strict-eval.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "eval", - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -23,17 +62,16 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 0, + 4 + ], + "name": "eval" } ], "body": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 8, - 10 - ], "loc": { "start": { "line": 1, @@ -43,64 +81,22 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 10 - } - } - }, - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 + "range": [ + 8, + 10 + ], + "value": 42, + "raw": "42" } } } ], "sourceType": "script", - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, "tokens": [ { "type": "Identifier", "value": "eval", - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -110,15 +106,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 0, + 4 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 5, - 7 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 5, + 7 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 8, - 10 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 8, + 10 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -164,7 +160,11 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/not-strict-octal.result.js b/tests/fixtures/ecma-features/arrowFunctions/not-strict-octal.result.js index 72df289b..335364d0 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/not-strict-octal.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/not-strict-octal.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,17 +62,16 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" } ], "body": { "type": "Literal", - "value": 0, - "raw": "00", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -43,64 +81,22 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 9 - } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 + "range": [ + 7, + 9 + ], + "value": 0, + "raw": "00" } } } ], "sourceType": "script", - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -110,15 +106,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ] }, { "type": "Numeric", "value": "00", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -200,7 +196,11 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/return-arrow-function.result.js b/tests/fixtures/ecma-features/arrowFunctions/return-arrow-function.result.js index 2aab69bb..fc4798d0 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/return-arrow-function.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/return-arrow-function.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -23,20 +62,36 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" } ], "body": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 5, + 12 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "y", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -46,17 +101,16 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "y" } ], "body": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -66,81 +120,23 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "generator": false, - "expression": true, - "range": [ - 5, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 + "range": [ + 10, + 12 + ], + "value": 42, + "raw": "42" } } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } } } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -150,15 +146,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 2, - 4 - ], "loc": { "start": { "line": 1, @@ -168,15 +164,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 2, + 4 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -186,15 +182,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -204,15 +200,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 10, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -240,7 +236,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/return-sequence.result.js b/tests/fixtures/ecma-features/arrowFunctions/return-sequence.result.js index 3ffe7f01..48a3212f 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/return-sequence.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/return-sequence.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,20 +62,36 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "x" } ], "body": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 8, + 27 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "y", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -46,15 +101,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "y" }, { "type": "Identifier", - "name": "z", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -64,19 +119,33 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "z" } ], "body": { "type": "SequenceExpression", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 19, + 26 + ], "expressions": [ { "type": "Identifier", - "name": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -86,15 +155,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ], + "name": "x" }, { "type": "Identifier", - "name": "y", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -104,15 +173,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ], + "name": "y" }, { "type": "Identifier", - "name": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -122,97 +191,24 @@ module.exports = { "line": 1, "column": 26 } - } - } - ], - "range": [ - 19, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 26 + }, + "range": [ + 25, + 26 + ], + "name": "z" } - } - }, - "generator": false, - "expression": true, - "range": [ - 8, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 27 - } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 + ] } } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } } } ], "sourceType": "script", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -276,15 +272,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -294,15 +290,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -312,15 +308,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -330,15 +326,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -348,15 +344,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -366,15 +362,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -384,15 +380,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -402,15 +398,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 15, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -420,15 +416,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -438,15 +434,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -456,15 +452,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -474,15 +470,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -492,15 +488,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -510,15 +506,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -528,15 +524,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -546,15 +542,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -564,7 +560,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/single-param-parens.result.js b/tests/fixtures/ecma-features/arrowFunctions/single-param-parens.result.js index 001b5187..888b7f32 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/single-param-parens.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/single-param-parens.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "e", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,17 +62,16 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "e" } ], "body": { "type": "Literal", - "value": "test", - "raw": "\"test\"", - "range": [ - 7, - 13 - ], "loc": { "start": { "line": 1, @@ -43,64 +81,22 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 + "range": [ + 7, + 13 + ], + "value": "test", + "raw": "\"test\"" } } } ], "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -110,15 +106,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "e", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ] }, { "type": "String", "value": "\"test\"", - "range": [ - 7, - 13 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 7, + 13 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -200,7 +196,11 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/single-param-return-identifier.result.js b/tests/fixtures/ecma-features/arrowFunctions/single-param-return-identifier.result.js index 46bda0e8..e8811ef0 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/single-param-return-identifier.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/single-param-return-identifier.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "sun", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -23,16 +62,16 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ], + "name": "sun" } ], "body": { "type": "Identifier", - "name": "earth", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -42,64 +81,21 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 14 - } - } - }, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 + "range": [ + 9, + 14 + ], + "name": "earth" } } } ], "sourceType": "script", - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -109,15 +105,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "sun", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 6, - 8 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 6, + 8 + ] }, { "type": "Identifier", "value": "earth", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 9, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -199,7 +195,11 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/arrowFunctions/single-param.result.js b/tests/fixtures/ecma-features/arrowFunctions/single-param.result.js index 39a5b95d..a6964f0f 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/single-param.result.js +++ b/tests/fixtures/ecma-features/arrowFunctions/single-param.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "id": null, + "generator": false, + "expression": true, "params": [ { "type": "Identifier", - "name": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -23,17 +62,16 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "e" } ], "body": { "type": "Literal", - "value": "test", - "raw": "\"test\"", - "range": [ - 5, - 11 - ], "loc": { "start": { "line": 1, @@ -43,64 +81,22 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "generator": false, - "expression": true, - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 + "range": [ + 5, + 11 + ], + "value": "test", + "raw": "\"test\"" } } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Identifier", "value": "e", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -110,15 +106,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=>", - "range": [ - 2, - 4 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 2, + 4 + ] }, { "type": "String", "value": "\"test\"", - "range": [ - 5, - 11 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 5, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -164,7 +160,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/binaryLiterals/invalid.result.js b/tests/fixtures/ecma-features/binaryLiterals/invalid.result.js index 6081eafe..7790809d 100644 --- a/tests/fixtures/ecma-features/binaryLiterals/invalid.result.js +++ b/tests/fixtures/ecma-features/binaryLiterals/invalid.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 4, "lineNumber": 1, "column": 5, - "description": "Unexpected token ILLEGAL" + "message": "Unexpected token 2" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/binaryLiterals/lowercase.result.js b/tests/fixtures/ecma-features/binaryLiterals/lowercase.result.js index 44561b02..88fde0b2 100644 --- a/tests/fixtures/ecma-features/binaryLiterals/lowercase.result.js +++ b/tests/fixtures/ecma-features/binaryLiterals/lowercase.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "expression": { "type": "Literal", - "value": 5, - "raw": "0b101", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 0, + 5 + ], + "value": 5, + "raw": "0b101" } } ], "sourceType": "script", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, "tokens": [ { "type": "Numeric", "value": "0b101", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/binaryLiterals/uppercase.result.js b/tests/fixtures/ecma-features/binaryLiterals/uppercase.result.js index 309889f4..257a1d01 100644 --- a/tests/fixtures/ecma-features/binaryLiterals/uppercase.result.js +++ b/tests/fixtures/ecma-features/binaryLiterals/uppercase.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "expression": { "type": "Literal", - "value": 5, - "raw": "0B101", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 0, + 5 + ], + "value": 5, + "raw": "0B101" } } ], "sourceType": "script", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, "tokens": [ { "type": "Numeric", "value": "0B101", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/blockBindings/const.result.js b/tests/fixtures/ecma-features/blockBindings/const.result.js index f6e1e6ed..b32ab6c2 100644 --- a/tests/fixtures/ecma-features/blockBindings/const.result.js +++ b/tests/fixtures/ecma-features/blockBindings/const.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 6, + 15 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -22,15 +59,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 6, + 9 + ], + "name": "foo" }, "init": { "type": "Identifier", - "name": "bar", - "range": [ - 12, - 15 - ], "loc": { "start": { "line": 1, @@ -40,64 +77,23 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "range": [ - 6, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 6 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 12, + 15 + ], + "name": "bar" } } ], - "kind": "const", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - } + "kind": "const" } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Keyword", "value": "const", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 6, + 9 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 12, - 15 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 12, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -179,7 +175,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/blockBindings/let-in-switchcase.result.js b/tests/fixtures/ecma-features/blockBindings/let-in-switchcase.result.js index 143b0d69..cf999082 100644 --- a/tests/fixtures/ecma-features/blockBindings/let-in-switchcase.result.js +++ b/tests/fixtures/ecma-features/blockBindings/let-in-switchcase.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], "body": [ { "type": "SwitchStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], "discriminant": { "type": "Identifier", - "name": "answer", - "range": [ - 8, - 14 - ], "loc": { "start": { "line": 1, @@ -19,43 +42,66 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 8, + 14 + ], + "name": "answer" }, "cases": [ { "type": "SwitchCase", - "test": { - "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 23, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 25 - } + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 45 } }, + "range": [ + 18, + 45 + ], "consequent": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 27, + 38 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 31, + 37 + ], "id": { "type": "Identifier", - "name": "t", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -65,16 +111,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ], + "name": "t" }, "init": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 35, - 37 - ], "loc": { "start": { "line": 1, @@ -84,47 +129,20 @@ module.exports = { "line": 1, "column": 37 } - } - }, - "range": [ - 31, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 31 }, - "end": { - "line": 1, - "column": 37 - } + "range": [ + 35, + 37 + ], + "value": 42, + "raw": "42" } } ], - "kind": "let", - "range": [ - 27, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 38 - } - } + "kind": "let" }, { "type": "BreakStatement", - "label": null, - "range": [ - 39, - 45 - ], "loc": { "start": { "line": 1, @@ -134,64 +152,42 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 39, + 45 + ], + "label": null } ], - "range": [ - 18, - 45 - ], - "loc": { - "start": { - "line": 1, - "column": 18 + "test": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } }, - "end": { - "line": 1, - "column": 45 - } + "range": [ + 23, + 25 + ], + "value": 42, + "raw": "42" } } - ], - "range": [ - 0, - 47 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 47 - } - } + ] } ], "sourceType": "script", - "range": [ - 0, - 47 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 47 - } - }, "tokens": [ { "type": "Keyword", "value": "switch", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "answer", - "range": [ - 8, - 14 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 8, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Keyword", "value": "case", - "range": [ - 18, - 22 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 18, + 22 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 23, - 25 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 23, + 25 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "let", - "range": [ - 27, - 30 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 27, + 30 + ] }, { "type": "Identifier", "value": "t", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -381,15 +377,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 35, - 37 - ], "loc": { "start": { "line": 1, @@ -399,15 +395,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 35, + 37 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -417,15 +413,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Keyword", "value": "break", - "range": [ - 39, - 44 - ], "loc": { "start": { "line": 1, @@ -435,15 +431,15 @@ module.exports = { "line": 1, "column": 44 } - } + }, + "range": [ + 39, + 44 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 1, @@ -453,15 +449,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 46, - 47 - ], "loc": { "start": { "line": 1, @@ -471,7 +467,11 @@ module.exports = { "line": 1, "column": 47 } - } + }, + "range": [ + 46, + 47 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/blockBindings/let.result.js b/tests/fixtures/ecma-features/blockBindings/let.result.js index 33255aa3..1f25b12c 100644 --- a/tests/fixtures/ecma-features/blockBindings/let.result.js +++ b/tests/fixtures/ecma-features/blockBindings/let.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 4, + 13 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,15 +59,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, "init": { "type": "Identifier", - "name": "bar", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 1, @@ -40,64 +77,23 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "range": [ - 4, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 13 - } + "range": [ + 10, + 13 + ], + "name": "bar" } } ], - "kind": "let", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - } + "kind": "let" } ], "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, "tokens": [ { "type": "Keyword", "value": "let", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 10, + 13 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -179,7 +175,11 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js b/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js index 59d60feb..3898fc42 100644 --- a/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js +++ b/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 8, + 31 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 9, + 18 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "a" }, + "static": false, + "kind": "get", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 14, + 18 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "generator": false, - "expression": false, - "range": [ - 14, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 14 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 16, + 18 + ], + "body": [] } - }, - "kind": "get", - "computed": false, - "range": [ - 9, - 18 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 19 }, "end": { "line": 1, - "column": 18 + "column": 29 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 19, + 29 + ], + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ], + "name": "b" }, + "static": false, + "kind": "set", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 24, + 29 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "c", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -142,16 +212,16 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ], + "name": "c" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 27, - 29 - ], "loc": { "start": { "line": 1, @@ -161,80 +231,20 @@ module.exports = { "line": 1, "column": 29 } - } - }, - "generator": false, - "expression": false, - "range": [ - 24, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 24 }, - "end": { - "line": 1, - "column": 29 - } - } - }, - "kind": "set", - "computed": false, - "range": [ - 19, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 29 + "range": [ + 27, + 29 + ], + "body": [] } - }, - "static": false + } } - ], - "range": [ - 8, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 31 - } - } - }, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -244,32 +254,18 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ], "sourceType": "script", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -279,15 +275,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -297,15 +293,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -315,15 +311,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -333,15 +329,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -351,15 +347,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -369,15 +365,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -387,15 +383,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -405,15 +401,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -423,15 +419,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 19, - 22 - ], "loc": { "start": { "line": 1, @@ -441,15 +437,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 19, + 22 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -459,15 +455,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -477,15 +473,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Identifier", "value": "c", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -495,15 +491,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -513,15 +509,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -531,15 +527,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -549,15 +545,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -567,15 +563,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -585,15 +581,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -603,7 +599,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js b/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js index 4f7a088e..c5bef576 100644 --- a/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 8, + 25 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 9, + 23 + ], + "computed": true, "key": { "type": "Identifier", - "name": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ], + "name": "a" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 19, + 23 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 23 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "generator": false, - "expression": false, - "range": [ - 19, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 19 }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "kind": "method", - "computed": true, - "range": [ - 9, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 23 + "range": [ + 21, + 23 + ], + "body": [] } - }, - "static": true + } } - ], - "range": [ - 8, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 25 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ], "sourceType": "script", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -381,15 +377,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -399,15 +395,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -417,7 +413,11 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-expression.result.js b/tests/fixtures/ecma-features/classes/class-expression.result.js index aa520b9a..cd76eedc 100644 --- a/tests/fixtures/ecma-features/classes/class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/class-expression.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "expression": { "type": "ClassExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 1, + 9 + ], "id": null, "superClass": null, "body": { "type": "ClassBody", - "body": [], - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -23,62 +60,21 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "range": [ - 1, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 9 - } - } - }, - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 + "range": [ + 7, + 9 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -88,15 +84,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "class", - "range": [ - 1, - 6 - ], "loc": { "start": { "line": 1, @@ -106,15 +102,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 1, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -124,15 +120,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -142,15 +138,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -160,15 +156,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -178,7 +174,11 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js b/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js index 290beb35..b2c670a2 100644 --- a/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js +++ b/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 8, + 23 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 9, + 22 + ], + "computed": false, "key": { "type": "Identifier", - "name": "prototype", - "range": [ - 9, - 18 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 9, + 18 + ], + "name": "prototype" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 18, + 22 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 18, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 22 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 22 + "range": [ + 20, + 22 + ], + "body": [] } - }, - "static": false + } } - ], - "range": [ - 8, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "prototype", - "range": [ - 9, - 18 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 9, + 18 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -345,7 +341,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-method-named-static.result.js b/tests/fixtures/ecma-features/classes/class-method-named-static.result.js index 8ca67951..44dae390 100644 --- a/tests/fixtures/ecma-features/classes/class-method-named-static.result.js +++ b/tests/fixtures/ecma-features/classes/class-method-named-static.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 8, + 21 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 9, + 19 + ], + "computed": false, "key": { "type": "Identifier", - "name": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ], + "name": "static" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 15, + 19 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 17, - 19 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 15 }, - "end": { - "line": 1, - "column": 19 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 19 + "range": [ + 17, + 19 + ], + "body": [] } - }, - "static": false - } - ], - "range": [ - 8, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 21 + } } - } - }, - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -363,7 +359,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-one-method-super.result.js b/tests/fixtures/ecma-features/classes/class-one-method-super.result.js index d6590117..cedacd90 100644 --- a/tests/fixtures/ecma-features/classes/class-one-method-super.result.js +++ b/tests/fixtures/ecma-features/classes/class-one-method-super.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 44 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 43 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 43 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 14, + 41 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -43,25 +95,86 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 15, + 41 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 17, + 41 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 27, + 35 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 27, + 34 + ], "callee": { "type": "Super", - "range": [ - 27, - 32 - ], "loc": { "start": { "line": 3, @@ -71,127 +184,24 @@ module.exports = { "line": 3, "column": 13 } - } - }, - "arguments": [], - "range": [ - 27, - 34 - ], - "loc": { - "start": { - "line": 3, - "column": 8 }, - "end": { - "line": 3, - "column": 15 - } - } - }, - "range": [ - 27, - 35 - ], - "loc": { - "start": { - "line": 3, - "column": 8 + "range": [ + 27, + 32 + ] }, - "end": { - "line": 3, - "column": 16 - } + "arguments": [] } } - ], - "range": [ - 17, - 41 - ], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 41 - ], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 4, - "column": 5 - } + ] } - }, - "kind": "method", - "computed": false, - "range": [ - 14, - 41 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "static": false - } - ], - "range": [ - 8, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 5, - "column": 1 + } } - } - }, - "range": [ - 0, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 43, - 44 - ], "loc": { "start": { "line": 5, @@ -201,32 +211,18 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 43, + 44 + ] } ], "sourceType": "script", - "range": [ - 0, - 44 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -290,15 +286,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -308,15 +304,15 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -326,15 +322,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -344,15 +340,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Keyword", "value": "super", - "range": [ - 27, - 32 - ], "loc": { "start": { "line": 3, @@ -362,15 +358,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 27, + 32 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 3, @@ -380,15 +376,15 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 3, @@ -398,15 +394,15 @@ module.exports = { "line": 3, "column": 15 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 3, @@ -416,15 +412,15 @@ module.exports = { "line": 3, "column": 16 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 4, @@ -434,15 +430,15 @@ module.exports = { "line": 4, "column": 5 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 5, @@ -452,15 +448,15 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 43, - 44 - ], "loc": { "start": { "line": 5, @@ -470,7 +466,11 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 43, + 44 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-one-method.result.js b/tests/fixtures/ecma-features/classes/class-one-method.result.js index f8289b37..8da67537 100644 --- a/tests/fixtures/ecma-features/classes/class-one-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-one-method.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 21 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 21 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 14, + 19 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -43,19 +95,37 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 15, + 19 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 17, - 19 - ], "loc": { "start": { "line": 2, @@ -65,80 +135,20 @@ module.exports = { "line": 2, "column": 9 } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 19 - ], - "loc": { - "start": { - "line": 2, - "column": 5 }, - "end": { - "line": 2, - "column": 9 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 14, - 19 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 9 + "range": [ + 17, + 19 + ], + "body": [] } - }, - "static": false + } } - ], - "range": [ - 8, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 3, @@ -148,32 +158,18 @@ module.exports = { "line": 3, "column": 2 } - } + }, + "range": [ + 21, + 22 + ] } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -237,15 +233,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -255,15 +251,15 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -273,15 +269,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -291,15 +287,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 2, @@ -309,15 +305,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 3, @@ -327,15 +323,15 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 3, @@ -345,7 +341,11 @@ module.exports = { "line": 3, "column": 2 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js b/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js index 0c93d058..4d12287e 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 0, + 34 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,22 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 8, + 34 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 9, + 33 + ], + "computed": true, "key": { "type": "Literal", - "value": "prototype", - "raw": "\"prototype\"", - "range": [ - 17, - 28 - ], "loc": { "start": { "line": 1, @@ -44,19 +95,38 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 17, + 28 + ], + "value": "prototype", + "raw": "\"prototype\"" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 29, + 33 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 31, - 33 - ], "loc": { "start": { "line": 1, @@ -66,80 +136,20 @@ module.exports = { "line": 1, "column": 33 } - } - }, - "generator": false, - "expression": false, - "range": [ - 29, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 29 }, - "end": { - "line": 1, - "column": 33 - } - } - }, - "kind": "method", - "computed": true, - "range": [ - 9, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 33 + "range": [ + 31, + 33 + ], + "body": [] } - }, - "static": true + } } - ], - "range": [ - 8, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 34 - } - } - }, - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -149,32 +159,18 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] } ], "sourceType": "script", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 35 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -184,15 +180,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "String", "value": "\"prototype\"", - "range": [ - 17, - 28 - ], "loc": { "start": { "line": 1, @@ -274,15 +270,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 17, + 28 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -292,15 +288,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -310,15 +306,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -328,15 +324,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -346,15 +342,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -364,15 +360,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -382,15 +378,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -400,7 +396,11 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js b/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js index 0cc35dc5..a3a091f9 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 8, + 28 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 9, + 26 + ], + "computed": false, "key": { "type": "Identifier", - "name": "static", - "range": [ - 16, - 22 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 16, + 22 + ], + "name": "static" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 22, + 26 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 24, - 26 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "generator": false, - "expression": false, - "range": [ - 22, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 22 }, - "end": { - "line": 1, - "column": 26 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 26 + "range": [ + 24, + 26 + ], + "body": [] } - }, - "static": true + } } - ], - "range": [ - 8, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 28 - } - } - }, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ], "sourceType": "script", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 16, - 22 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 16, + 22 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -381,7 +377,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-static-method.result.js b/tests/fixtures/ecma-features/classes/class-static-method.result.js index 7a988ed6..b632292b 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 8, + 23 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 9, + 21 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "a" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 17, + 21 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 19, - 21 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "generator": false, - "expression": false, - "range": [ - 17, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 21 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 21 + "range": [ + 19, + 21 + ], + "body": [] } - }, - "static": true + } } - ], - "range": [ - 8, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -381,7 +377,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js b/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js index 5e4cbf21..695061fd 100644 --- a/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "range": [ + 0, + 59 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "range": [ + 0, + 58 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "range": [ + 8, + 58 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 9, + 21 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "a" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 17, + 21 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 19, - 21 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "generator": false, - "expression": false, - "range": [ - 17, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 21 - } + "range": [ + 19, + 21 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 21 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 22 }, "end": { "line": 1, - "column": 21 + "column": 38 } }, - "static": true - }, - { - "type": "MethodDefinition", + "range": [ + 22, + 38 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ], + "name": "a" }, + "static": true, + "kind": "get", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 34, + 38 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 36, - 38 - ], "loc": { "start": { "line": 1, @@ -142,52 +212,34 @@ module.exports = { "line": 1, "column": 38 } - } - }, - "generator": false, - "expression": false, - "range": [ - 34, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 34 }, - "end": { - "line": 1, - "column": 38 - } + "range": [ + 36, + 38 + ], + "body": [] } - }, - "kind": "get", - "computed": false, - "range": [ - 22, - 38 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 22 + "column": 39 }, "end": { "line": 1, - "column": 38 + "column": 56 } }, - "static": true - }, - { - "type": "MethodDefinition", + "range": [ + 39, + 56 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 1, @@ -197,19 +249,37 @@ module.exports = { "line": 1, "column": 51 } - } + }, + "range": [ + 50, + 51 + ], + "name": "a" }, + "static": true, + "kind": "set", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 51 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "range": [ + 51, + 56 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "b", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -219,16 +289,16 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ], + "name": "b" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 54, - 56 - ], "loc": { "start": { "line": 1, @@ -238,80 +308,20 @@ module.exports = { "line": 1, "column": 56 } - } - }, - "generator": false, - "expression": false, - "range": [ - 51, - 56 - ], - "loc": { - "start": { - "line": 1, - "column": 51 }, - "end": { - "line": 1, - "column": 56 - } - } - }, - "kind": "set", - "computed": false, - "range": [ - 39, - 56 - ], - "loc": { - "start": { - "line": 1, - "column": 39 - }, - "end": { - "line": 1, - "column": 56 + "range": [ + 54, + 56 + ], + "body": [] } - }, - "static": true - } - ], - "range": [ - 8, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 58 + } } - } - }, - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 58 - } + ] } - }, - { - "type": "EmptyStatement", - "range": [ - 58, - 59 - ], + }, + { + "type": "EmptyStatement", "loc": { "start": { "line": 1, @@ -321,32 +331,18 @@ module.exports = { "line": 1, "column": 59 } - } + }, + "range": [ + 58, + 59 + ] } ], "sourceType": "script", - "range": [ - 0, - 59 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 59 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -356,15 +352,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -374,15 +370,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -392,15 +388,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -410,15 +406,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -428,15 +424,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -446,15 +442,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -464,15 +460,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -482,15 +478,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -500,15 +496,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 22, - 28 - ], "loc": { "start": { "line": 1, @@ -518,15 +514,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 22, + 28 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 29, - 32 - ], "loc": { "start": { "line": 1, @@ -536,15 +532,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 29, + 32 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -554,15 +550,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -572,15 +568,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -590,15 +586,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -608,15 +604,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -626,15 +622,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 39, - 45 - ], "loc": { "start": { "line": 1, @@ -644,15 +640,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 39, + 45 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 46, - 49 - ], "loc": { "start": { "line": 1, @@ -662,15 +658,15 @@ module.exports = { "line": 1, "column": 49 } - } + }, + "range": [ + 46, + 49 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 1, @@ -680,15 +676,15 @@ module.exports = { "line": 1, "column": 51 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 1, @@ -698,15 +694,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -716,15 +712,15 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 53, - 54 - ], "loc": { "start": { "line": 1, @@ -734,15 +730,15 @@ module.exports = { "line": 1, "column": 54 } - } + }, + "range": [ + 53, + 54 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 54, - 55 - ], "loc": { "start": { "line": 1, @@ -752,15 +748,15 @@ module.exports = { "line": 1, "column": 55 } - } + }, + "range": [ + 54, + 55 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 1, @@ -770,15 +766,15 @@ module.exports = { "line": 1, "column": 56 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 57, - 58 - ], "loc": { "start": { "line": 1, @@ -788,15 +784,15 @@ module.exports = { "line": 1, "column": 58 } - } + }, + "range": [ + 57, + 58 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 58, - 59 - ], "loc": { "start": { "line": 1, @@ -806,7 +802,11 @@ module.exports = { "line": 1, "column": 59 } - } + }, + "range": [ + 58, + 59 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js b/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js index 4a61eae7..a211ad00 100644 --- a/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 0, + 38 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 8, + 38 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 9, + 22 + ], + "computed": true, "key": { "type": "Identifier", - "name": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "a" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 18, + 22 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 18, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 20, + 22 + ], + "body": [] } - }, - "kind": "method", - "computed": true, - "range": [ - 9, - 22 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 24 }, "end": { "line": 1, - "column": 22 + "column": 37 } }, - "static": true - }, - { - "type": "MethodDefinition", + "range": [ + 24, + 37 + ], + "computed": true, "key": { "type": "Identifier", - "name": "b", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ], + "name": "b" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 33, + 37 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 35, - 37 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 37 } - } - }, - "generator": false, - "expression": false, - "range": [ - 33, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 33 }, - "end": { - "line": 1, - "column": 37 - } - } - }, - "kind": "method", - "computed": true, - "range": [ - 24, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 37 + "range": [ + 35, + 37 + ], + "body": [] } - }, - "static": true - } - ], - "range": [ - 8, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 38 + } } - } - }, - "range": [ - 0, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] } ], "sourceType": "script", - "range": [ - 0, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 39 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 24, - 30 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 24, + 30 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -512,15 +508,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -530,15 +526,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -548,15 +544,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -566,15 +562,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -584,15 +580,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -602,15 +598,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -620,15 +616,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -638,7 +634,11 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js index a4eda54e..23254af7 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "range": [ + 0, + 48 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,22 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 8, + 47 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 9, + 26 + ], + "computed": false, "key": { "type": "Literal", - "value": "constructor", - "raw": "\"constructor\"", - "range": [ - 9, - 22 - ], "loc": { "start": { "line": 1, @@ -44,19 +95,38 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 9, + 22 + ], + "value": "constructor", + "raw": "\"constructor\"" }, + "static": false, + "kind": "constructor", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 22, + 26 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 24, - 26 - ], "loc": { "start": { "line": 1, @@ -66,53 +136,34 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "generator": false, - "expression": false, - "range": [ - 22, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 22 }, - "end": { - "line": 1, - "column": 26 - } + "range": [ + 24, + 26 + ], + "body": [] } - }, - "kind": "constructor", - "computed": false, - "range": [ - 9, - 26 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 27 }, "end": { "line": 1, - "column": 26 + "column": 46 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 27, + 46 + ], + "computed": true, "key": { "type": "Literal", - "value": "constructor", - "raw": "\"constructor\"", - "range": [ - 28, - 41 - ], "loc": { "start": { "line": 1, @@ -122,19 +173,38 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 28, + 41 + ], + "value": "constructor", + "raw": "\"constructor\"" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 42, + 46 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 44, - 46 - ], "loc": { "start": { "line": 1, @@ -144,80 +214,20 @@ module.exports = { "line": 1, "column": 46 } - } - }, - "generator": false, - "expression": false, - "range": [ - 42, - 46 - ], - "loc": { - "start": { - "line": 1, - "column": 42 }, - "end": { - "line": 1, - "column": 46 - } - } - }, - "kind": "method", - "computed": true, - "range": [ - 27, - 46 - ], - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 46 + "range": [ + 44, + 46 + ], + "body": [] } - }, - "static": false - } - ], - "range": [ - 8, - 47 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 47 + } } - } - }, - "range": [ - 0, - 47 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 47 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 47, - 48 - ], "loc": { "start": { "line": 1, @@ -227,32 +237,18 @@ module.exports = { "line": 1, "column": 48 } - } + }, + "range": [ + 47, + 48 + ] } ], "sourceType": "script", - "range": [ - 0, - 48 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 48 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -262,15 +258,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -280,15 +276,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -298,15 +294,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "String", "value": "\"constructor\"", - "range": [ - 9, - 22 - ], "loc": { "start": { "line": 1, @@ -316,15 +312,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 9, + 22 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -334,15 +330,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -352,15 +348,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -370,15 +366,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -388,15 +384,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -406,15 +402,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "String", "value": "\"constructor\"", - "range": [ - 28, - 41 - ], "loc": { "start": { "line": 1, @@ -424,15 +420,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 28, + 41 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 1, @@ -442,15 +438,15 @@ module.exports = { "line": 1, "column": 42 } - } + }, + "range": [ + 41, + 42 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 1, @@ -460,15 +456,15 @@ module.exports = { "line": 1, "column": 43 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 43, - 44 - ], "loc": { "start": { "line": 1, @@ -478,15 +474,15 @@ module.exports = { "line": 1, "column": 44 } - } + }, + "range": [ + 43, + 44 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 1, @@ -496,15 +492,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 1, @@ -514,15 +510,15 @@ module.exports = { "line": 1, "column": 46 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 46, - 47 - ], "loc": { "start": { "line": 1, @@ -532,15 +528,15 @@ module.exports = { "line": 1, "column": 47 } - } + }, + "range": [ + 46, + 47 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 47, - 48 - ], "loc": { "start": { "line": 1, @@ -550,7 +546,11 @@ module.exports = { "line": 1, "column": 48 } - } + }, + "range": [ + 47, + 48 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js index dfa7e64d..0760b4db 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 8, + 21 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 10, + 14 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "generator": false, - "expression": false, - "range": [ - 10, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 10 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 14 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 15 }, "end": { "line": 1, - "column": 14 + "column": 20 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 15, + 20 + ], + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "name": "b" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 16, + 20 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "generator": false, - "expression": false, - "range": [ - 16, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 15, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 20 + "range": [ + 18, + 20 + ], + "body": [] } - }, - "static": false - } - ], - "range": [ - 8, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 21 + } } - } - }, - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -512,15 +508,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -530,7 +526,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js index a7f05fb5..1015e28f 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 8, + 23 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 11, + 15 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "generator": false, - "expression": false, - "range": [ - 11, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 13, + 15 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 10, - 15 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 10 + "column": 16 }, "end": { "line": 1, - "column": 15 + "column": 21 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 16, + 21 + ], + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "b" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 17, + 21 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 19, - 21 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "generator": false, - "expression": false, - "range": [ - 17, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 21 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 16, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 21 + "range": [ + 19, + 21 + ], + "body": [] } - }, - "static": false - } - ], - "range": [ - 8, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 23 + } } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -512,15 +508,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -530,15 +526,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -548,15 +544,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -566,7 +562,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js index 96543f61..e41ba857 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 10, + 14 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "generator": false, - "expression": false, - "range": [ - 10, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 10 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 14 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 15 }, "end": { "line": 1, - "column": 14 + "column": 20 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 15, + 20 + ], + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "name": "b" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 16, + 20 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "generator": false, - "expression": false, - "range": [ - 16, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 15, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 20 + "range": [ + 18, + 20 + ], + "body": [] } - }, - "static": false - } - ], - "range": [ - 8, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 22 + } } - } - }, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -512,15 +508,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -530,15 +526,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -548,7 +544,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-methods.result.js b/tests/fixtures/ecma-features/classes/class-two-methods.result.js index 377f0aaf..d9779423 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 8, + 20 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 10, + 14 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "generator": false, - "expression": false, - "range": [ - 10, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 10 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 14 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 14 }, "end": { "line": 1, - "column": 14 + "column": 19 } }, - "static": false - }, - { - "type": "MethodDefinition", + "range": [ + 14, + 19 + ], + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ], + "name": "b" }, + "static": false, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 15, + 19 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 17, - 19 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 15 }, - "end": { - "line": 1, - "column": 19 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 14, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 19 + "range": [ + 17, + 19 + ], + "body": [] } - }, - "static": false + } } - ], - "range": [ - 8, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] } ], "sourceType": "script", - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -512,7 +508,11 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js b/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js index 46479dd0..3c6cd806 100644 --- a/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "range": [ + 0, + 56 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "range": [ + 0, + 55 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "range": [ + 8, + 55 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 9, + 31 + ], + "computed": false, "key": { "type": "Identifier", - "name": "constructor", - "range": [ - 16, - 27 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 16, + 27 + ], + "name": "constructor" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 27, + 31 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 29, - 31 - ], "loc": { "start": { "line": 1, @@ -65,52 +135,34 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "generator": false, - "expression": false, - "range": [ - 27, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 27 }, - "end": { - "line": 1, - "column": 31 - } + "range": [ + 29, + 31 + ], + "body": [] } - }, - "kind": "method", - "computed": false, - "range": [ - 9, - 31 - ], + } + }, + { + "type": "MethodDefinition", "loc": { "start": { "line": 1, - "column": 9 + "column": 32 }, "end": { "line": 1, - "column": 31 + "column": 54 } }, - "static": true - }, - { - "type": "MethodDefinition", + "range": [ + 32, + 54 + ], + "computed": false, "key": { "type": "Identifier", - "name": "constructor", - "range": [ - 39, - 50 - ], "loc": { "start": { "line": 1, @@ -120,19 +172,37 @@ module.exports = { "line": 1, "column": 50 } - } + }, + "range": [ + 39, + 50 + ], + "name": "constructor" }, + "static": true, + "kind": "method", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "range": [ + 50, + 54 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 52, - 54 - ], "loc": { "start": { "line": 1, @@ -142,80 +212,20 @@ module.exports = { "line": 1, "column": 54 } - } - }, - "generator": false, - "expression": false, - "range": [ - 50, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 50 }, - "end": { - "line": 1, - "column": 54 - } - } - }, - "kind": "method", - "computed": false, - "range": [ - 32, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 32 - }, - "end": { - "line": 1, - "column": 54 + "range": [ + 52, + 54 + ], + "body": [] } - }, - "static": true - } - ], - "range": [ - 8, - 55 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 55 + } } - } - }, - "range": [ - 0, - 55 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 55 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 1, @@ -225,32 +235,18 @@ module.exports = { "line": 1, "column": 56 } - } + }, + "range": [ + 55, + 56 + ] } ], "sourceType": "script", - "range": [ - 0, - 56 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 56 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -296,15 +292,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 9, - 15 - ], "loc": { "start": { "line": 1, @@ -314,15 +310,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 9, + 15 + ] }, { "type": "Identifier", "value": "constructor", - "range": [ - 16, - 27 - ], "loc": { "start": { "line": 1, @@ -332,15 +328,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 16, + 27 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -350,15 +346,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -368,15 +364,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -386,15 +382,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -404,15 +400,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Keyword", "value": "static", - "range": [ - 32, - 38 - ], "loc": { "start": { "line": 1, @@ -422,15 +418,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 32, + 38 + ] }, { "type": "Identifier", "value": "constructor", - "range": [ - 39, - 50 - ], "loc": { "start": { "line": 1, @@ -440,15 +436,15 @@ module.exports = { "line": 1, "column": 50 } - } + }, + "range": [ + 39, + 50 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 1, @@ -458,15 +454,15 @@ module.exports = { "line": 1, "column": 51 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 1, @@ -476,15 +472,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -494,15 +490,15 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 53, - 54 - ], "loc": { "start": { "line": 1, @@ -512,15 +508,15 @@ module.exports = { "line": 1, "column": 54 } - } + }, + "range": [ + 53, + 54 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 54, - 55 - ], "loc": { "start": { "line": 1, @@ -530,15 +526,15 @@ module.exports = { "line": 1, "column": 55 } - } + }, + "range": [ + 54, + 55 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 1, @@ -548,7 +544,11 @@ module.exports = { "line": 1, "column": 56 } - } + }, + "range": [ + 55, + 56 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/class-with-constructor.result.js b/tests/fixtures/ecma-features/classes/class-with-constructor.result.js index a8471d81..d07c9738 100644 --- a/tests/fixtures/ecma-features/classes/class-with-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-with-constructor.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,50 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 8, + 25 + ], "body": [ { "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 9, + 24 + ], + "computed": false, "key": { "type": "Identifier", - "name": "constructor", - "range": [ - 9, - 20 - ], "loc": { "start": { "line": 1, @@ -43,19 +95,37 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 9, + 20 + ], + "name": "constructor" }, + "static": false, + "kind": "constructor", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 20, + 24 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 22, - 24 - ], "loc": { "start": { "line": 1, @@ -65,80 +135,20 @@ module.exports = { "line": 1, "column": 24 } - } - }, - "generator": false, - "expression": false, - "range": [ - 20, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "kind": "constructor", - "computed": false, - "range": [ - 9, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 24 + "range": [ + 22, + 24 + ], + "body": [] } - }, - "static": false + } } - ], - "range": [ - 8, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 25 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -148,32 +158,18 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ], "sourceType": "script", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "constructor", - "range": [ - 9, - 20 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 9, + 20 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -345,7 +341,11 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js b/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js index 3b475450..1d470268 100644 --- a/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js +++ b/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 4, + 27 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,17 +59,31 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ClassExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 8, + 27 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -42,16 +93,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ], + "name": "A" }, "superClass": { "type": "Literal", - "value": 0, - "raw": "0", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -61,15 +111,16 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ], + "value": 0, + "raw": "0" }, "body": { "type": "ClassBody", - "body": [], - "range": [ - 25, - 27 - ], "loc": { "start": { "line": 1, @@ -79,79 +130,24 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 8, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 27 - } - } - }, - "range": [ - 4, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 27 + "range": [ + 25, + 27 + ], + "body": [] } } } ], - "kind": "var", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Keyword", "value": "class", - "range": [ - 8, - 13 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 8, + 13 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Keyword", "value": "extends", - "range": [ - 16, - 23 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 16, + 23 + ] }, { "type": "Numeric", "value": "0", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -323,7 +319,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/derived-class-expression.result.js b/tests/fixtures/ecma-features/classes/derived-class-expression.result.js index 3b547b3a..1a3068b6 100644 --- a/tests/fixtures/ecma-features/classes/derived-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/derived-class-expression.result.js @@ -1,19 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "expression": { "type": "ClassExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 1, + 18 + ], "id": null, "superClass": { "type": "Literal", - "value": 0, - "raw": "0", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -23,15 +59,16 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "value": 0, + "raw": "0" }, "body": { "type": "ClassBody", - "body": [], - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -41,62 +78,21 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 1, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 + "range": [ + 16, + 18 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -106,15 +102,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "class", - "range": [ - 1, - 6 - ], "loc": { "start": { "line": 1, @@ -124,15 +120,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 1, + 6 + ] }, { "type": "Keyword", "value": "extends", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -142,15 +138,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Numeric", "value": "0", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -160,15 +156,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -232,7 +228,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js b/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js index 13e485fe..f0bc32e9 100644 --- a/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,16 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", - "body": [], - "range": [ - 8, - 10 - ], "loc": { "start": { "line": 1, @@ -38,29 +61,16 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 10 - } + "range": [ + 8, + 10 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -70,32 +80,18 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ], "sourceType": "script", - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -177,7 +173,11 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/empty-class-semi.result.js b/tests/fixtures/ecma-features/classes/empty-class-semi.result.js index 5b86eb22..319c6f97 100644 --- a/tests/fixtures/ecma-features/classes/empty-class-semi.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class-semi.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,16 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", - "body": [], - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -38,29 +61,16 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 8, + 11 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -70,32 +80,18 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -195,7 +191,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/empty-class.result.js b/tests/fixtures/ecma-features/classes/empty-class.result.js index 13e485fe..f0bc32e9 100644 --- a/tests/fixtures/ecma-features/classes/empty-class.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,16 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", - "body": [], - "range": [ - 8, - 10 - ], "loc": { "start": { "line": 1, @@ -38,29 +61,16 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 10 - } + "range": [ + 8, + 10 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -70,32 +80,18 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ], "sourceType": "script", - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -177,7 +173,11 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js b/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js index a44e4850..53facc1e 100644 --- a/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js +++ b/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "body": [ { "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "A" }, "superClass": { "type": "Literal", - "value": 0, - "raw": "0", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -38,15 +60,16 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "value": 0, + "raw": "0" }, "body": { "type": "ClassBody", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -56,29 +79,16 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 18, + 20 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -88,32 +98,18 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] } ], "sourceType": "script", - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } - }, "tokens": [ { "type": "Keyword", "value": "class", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Keyword", "value": "extends", - "range": [ - 8, - 15 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 8, + 15 + ] }, { "type": "Numeric", "value": "0", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -213,15 +209,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -231,7 +227,11 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/invalid-class-declaration.result.js b/tests/fixtures/ecma-features/classes/invalid-class-declaration.result.js index 10e59e57..f29098ce 100644 --- a/tests/fixtures/ecma-features/classes/invalid-class-declaration.result.js +++ b/tests/fixtures/ecma-features/classes/invalid-class-declaration.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 6, "lineNumber": 1, "column": 7, - "description": "Unexpected token {" + "message": "Unexpected token {" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/invalid-class-setter-declaration.result.js b/tests/fixtures/ecma-features/classes/invalid-class-setter-declaration.result.js index 1887cc17..89b2125e 100644 --- a/tests/fixtures/ecma-features/classes/invalid-class-setter-declaration.result.js +++ b/tests/fixtures/ecma-features/classes/invalid-class-setter-declaration.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 18, + "index": 17, "lineNumber": 1, - "column": 19, - "description": "Unexpected token )" + "column": 18, + "message": "setter should have exactly one param" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/named-class-expression.result.js b/tests/fixtures/ecma-features/classes/named-class-expression.result.js index 3c732f41..e12b248a 100644 --- a/tests/fixtures/ecma-features/classes/named-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/named-class-expression.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "ClassExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -21,16 +58,16 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ], + "name": "A" }, "superClass": null, "body": { "type": "ClassBody", - "body": [], - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -40,62 +77,21 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 1, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 + "range": [ + 9, + 11 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "class", - "range": [ - 1, - 6 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 1, + 6 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -213,7 +209,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js b/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js index f8086f43..5d1d55a0 100644 --- a/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "expression": { "type": "ClassExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 1, + 20 + ], "id": { "type": "Identifier", - "name": "A", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -21,16 +58,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ], + "name": "A" }, "superClass": { "type": "Literal", - "value": 0, - "raw": "0", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -40,15 +76,16 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ], + "value": 0, + "raw": "0" }, "body": { "type": "ClassBody", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -58,62 +95,21 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 1, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 20 - } - } - }, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 + "range": [ + 18, + 20 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "class", - "range": [ - 1, - 6 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 1, + 6 + ] }, { "type": "Identifier", "value": "A", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Keyword", "value": "extends", - "range": [ - 9, - 16 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 9, + 16 + ] }, { "type": "Numeric", "value": "0", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -213,15 +209,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -231,15 +227,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -249,15 +245,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -267,7 +263,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/defaultParams/declaration.result.js b/tests/fixtures/ecma-features/defaultParams/declaration.result.js index bcfeee4e..12c025f7 100644 --- a/tests/fixtures/ecma-features/defaultParams/declaration.result.js +++ b/tests/fixtures/ecma-features/defaultParams/declaration.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "id": { "type": "Identifier", - "name": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,18 +42,34 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "f" }, + "generator": false, + "expression": false, "params": [ { "type": "AssignmentPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 11, + 16 + ], "left": { "type": "Identifier", - "name": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -40,16 +79,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "a" }, "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -59,31 +97,18 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 11, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 15, + 16 + ], + "value": 1, + "raw": "1" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -93,49 +118,20 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 18, + 20 + ], + "body": [] } } ], "sourceType": "script", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -289,7 +285,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/defaultParams/expression.result.js b/tests/fixtures/ecma-features/defaultParams/expression.result.js index fcb1236f..9ca8637f 100644 --- a/tests/fixtures/ecma-features/defaultParams/expression.result.js +++ b/tests/fixtures/ecma-features/defaultParams/expression.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,21 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 4, + 22 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "AssignmentPattern", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 13, + 18 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -46,16 +113,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -65,31 +131,18 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 13, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 17, + 18 + ], + "value": 1, + "raw": "1" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -99,79 +152,22 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 4, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 22 - } - } - }, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 + "range": [ + 20, + 22 + ], + "body": [] } } - }, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } } } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 4, - 12 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 4, + 12 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -343,7 +339,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/defaultParams/method.result.js b/tests/fixtures/ecma-features/defaultParams/method.result.js index e995a7da..91261a8c 100644 --- a/tests/fixtures/ecma-features/defaultParams/method.result.js +++ b/tests/fixtures/ecma-features/defaultParams/method.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 4, + 27 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 6, + 25 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "f", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -45,21 +113,51 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "f" }, "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 9, + 25 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "AssignmentPattern", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 18, + 21 + ], "left": { "type": "Identifier", - "name": "a", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -69,16 +167,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ], + "name": "a" }, "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -88,31 +185,18 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 18, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 21 - } + "range": [ + 20, + 21 + ], + "value": 1, + "raw": "1" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 23, - 25 - ], "loc": { "start": { "line": 1, @@ -122,114 +206,26 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "generator": false, - "expression": false, - "range": [ - 9, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 25 - } + "range": [ + 23, + 25 + ], + "body": [] } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 6, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 25 - } - } - } - ], - "range": [ - 4, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 27 + "kind": "init" } - } - }, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - } - }, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -239,15 +235,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -257,15 +253,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -275,15 +271,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -293,15 +289,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -311,15 +307,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 9, - 17 - ], "loc": { "start": { "line": 1, @@ -329,15 +325,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 9, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -347,15 +343,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -365,15 +361,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -383,15 +379,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -401,15 +397,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -419,15 +415,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -437,15 +433,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -455,15 +451,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -473,7 +469,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/defaultParams/not-all-params.result.js b/tests/fixtures/ecma-features/defaultParams/not-all-params.result.js index 9555397b..0c15e557 100644 --- a/tests/fixtures/ecma-features/defaultParams/not-all-params.result.js +++ b/tests/fixtures/ecma-features/defaultParams/not-all-params.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 4, + 35 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,19 +59,35 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, "init": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 10, + 35 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -44,17 +97,31 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ], + "name": "a" }, { "type": "AssignmentPattern", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 22, + 28 + ], "left": { "type": "Identifier", - "name": "b", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -64,16 +131,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ], + "name": "b" }, "right": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 26, - 28 - ], "loc": { "start": { "line": 1, @@ -83,30 +149,17 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "range": [ - 22, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 22 }, - "end": { - "line": 1, - "column": 28 - } + "range": [ + 26, + 28 + ], + "value": 42, + "raw": "42" } }, { "type": "Identifier", - "name": "c", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -116,16 +169,16 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ], + "name": "c" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 33, - 35 - ], "loc": { "start": { "line": 1, @@ -135,81 +188,24 @@ module.exports = { "line": 1, "column": 35 } - } - }, - "generator": false, - "expression": false, - "range": [ - 10, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 10 }, - "end": { - "line": 1, - "column": 35 - } - } - }, - "range": [ - 4, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 35 + "range": [ + 33, + 35 + ], + "body": [] } } } ], - "kind": "var", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 36 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 36 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 10, - 18 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 10, + 18 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -327,15 +323,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -345,15 +341,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 26, - 28 - ], "loc": { "start": { "line": 1, @@ -381,15 +377,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 26, + 28 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -399,15 +395,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Identifier", "value": "c", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -417,15 +413,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -435,15 +431,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -453,15 +449,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -471,15 +467,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -489,7 +485,11 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/array-member.result.js b/tests/fixtures/ecma-features/destructuring/array-member.result.js index 179d2d5f..52d6ad89 100644 --- a/tests/fixtures/ecma-features/destructuring/array-member.result.js +++ b/tests/fixtures/ecma-features/destructuring/array-member.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "operator": "=", "left": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "elements": [ { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 1, + 5 + ], "object": { "type": "Identifier", - "name": "ok", - "range": [ - 1, - 3 - ], "loc": { "start": { "line": 1, @@ -28,15 +92,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 1, + 3 + ], + "name": "ok" }, "property": { "type": "Identifier", - "name": "v", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -46,47 +110,19 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 1, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 5 - } - } - } - ], - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 + "range": [ + 4, + 5 + ], + "name": "v" + }, + "computed": false } - } + ] }, "right": { "type": "Literal", - "value": 20, - "raw": "20", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -96,62 +132,22 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 + "range": [ + 9, + 11 + ], + "value": 20, + "raw": "20" } } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "[", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "ok", - "range": [ - 1, - 3 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 1, + 3 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Identifier", "value": "v", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "20", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/array-to-array.result.js b/tests/fixtures/ecma-features/destructuring/array-to-array.result.js index a8c5079d..38d81c2f 100644 --- a/tests/fixtures/ecma-features/destructuring/array-to-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/array-to-array.result.js @@ -1,21 +1,72 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "operator": "=", "left": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "elements": [ { "type": "Identifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -25,15 +76,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, { "type": "Identifier", - "name": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -43,34 +94,34 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "b" } - ], - "range": [ - 0, - 6 - ], + ] + }, + "right": { + "type": "ArrayExpression", "loc": { "start": { "line": 1, - "column": 0 + "column": 9 }, "end": { "line": 1, - "column": 6 + "column": 15 } - } - }, - "right": { - "type": "ArrayExpression", + }, + "range": [ + 9, + 15 + ], "elements": [ { "type": "Identifier", - "name": "b", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -80,15 +131,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ], + "name": "b" }, { "type": "Identifier", - "name": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -98,78 +149,23 @@ module.exports = { "line": 1, "column": 14 } - } - } - ], - "range": [ - 9, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 15 + }, + "range": [ + 13, + 14 + ], + "name": "a" } - } - }, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - } - }, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", "value": "[", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -341,15 +337,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -359,15 +355,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -377,7 +373,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/array-var-undefined.result.js b/tests/fixtures/ecma-features/destructuring/array-var-undefined.result.js index bef67f52..a5a9465d 100644 --- a/tests/fixtures/ecma-features/destructuring/array-var-undefined.result.js +++ b/tests/fixtures/ecma-features/destructuring/array-var-undefined.result.js @@ -1,21 +1,72 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "elements": [ { "type": "Identifier", - "name": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -25,31 +76,17 @@ module.exports = { "line": 1, "column": 6 } - } - } - ], - "range": [ - 4, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 7 + }, + "range": [ + 5, + 6 + ], + "name": "a" } - } + ] }, "init": { "type": "ArrayExpression", - "elements": [], - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -59,64 +96,23 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 4, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 10, + 12 + ], + "elements": [] } } ], - "kind": "var", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -252,7 +248,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array-all.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array-all.result.js index 0b784032..ebcef30c 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array-all.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array-all.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 4, + 30 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 4, + 26 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -28,16 +92,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -47,33 +110,33 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], + }, + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" + } + }, + { + "type": "AssignmentPattern", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - { - "type": "AssignmentPattern", - "operator": "=", + }, + "range": [ + 13, + 18 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -83,16 +146,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -102,33 +164,33 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 13, - 18 - ], + }, + "range": [ + 17, + 18 + ], + "value": 5, + "raw": "5" + } + }, + { + "type": "AssignmentPattern", "loc": { "start": { "line": 1, - "column": 13 + "column": 20 }, "end": { "line": 1, - "column": 18 + "column": 25 } - } - }, - { - "type": "AssignmentPattern", - "operator": "=", + }, + "range": [ + 20, + 25 + ], "left": { "type": "Identifier", - "name": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -138,16 +200,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ], + "name": "z" }, "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -157,46 +218,19 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "range": [ - 20, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 25 - } + "range": [ + 24, + 25 + ], + "value": 1, + "raw": "1" } } - ], - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 26 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -206,64 +240,23 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 4, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 30 - } + "range": [ + 29, + 30 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -273,15 +266,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -291,15 +284,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -309,15 +302,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -327,15 +320,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -345,15 +338,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -363,15 +356,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -381,15 +374,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -399,15 +392,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -417,15 +410,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -435,15 +428,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -453,15 +446,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -471,15 +464,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -489,15 +482,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -507,15 +500,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -525,15 +518,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -543,15 +536,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -561,7 +554,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array-longform-nested-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array-longform-nested-multi.result.js index fdc3ba3a..02a44ef8 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array-longform-nested-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array-longform-nested-multi.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 4, + 38 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 4, + 34 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "value": { "type": "Identifier", - "name": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -45,36 +113,36 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "x" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 5, - 9 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 11 }, "end": { "line": 1, - "column": 9 + "column": 15 } - } - }, - { - "type": "Property", + }, + "range": [ + 11, + 15 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -84,15 +152,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "y" }, "value": { "type": "Identifier", - "name": "y", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -102,36 +170,36 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ], + "name": "y" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 11, - 15 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 11 + "column": 17 }, "end": { "line": 1, - "column": 15 + "column": 32 } - } - }, - { - "type": "Property", + }, + "range": [ + 17, + 32 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -141,20 +209,51 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ], + "name": "z" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 20, + 32 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 22, + 31 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -164,18 +263,31 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ], + "name": "a" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 25, + 31 + ], "left": { "type": "Identifier", - "name": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -185,119 +297,43 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ], + "name": "a" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 29, - 31 - ], "loc": { "start": { "line": 1, - "column": 29 - }, - "end": { - "line": 1, - "column": 31 - } - } - }, - "range": [ - 25, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 25 - }, - "end": { - "line": 1, - "column": 31 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 22, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 22 - }, - "end": { - "line": 1, - "column": 31 - } - } - } - ], - "range": [ - 20, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 32 + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 29, + 31 + ], + "value": 10, + "raw": "10" + } + }, + "kind": "init" } - } + ] }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 17, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 32 - } - } - } - ], - "range": [ - 4, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 34 + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "b", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -307,64 +343,23 @@ module.exports = { "line": 1, "column": 38 } - } - }, - "range": [ - 4, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 38 - } + "range": [ + 37, + 38 + ], + "name": "b" } } ], - "kind": "var", - "range": [ - 0, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 39 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 39 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -374,15 +369,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -392,15 +387,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -410,15 +405,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -428,15 +423,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -446,15 +441,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -464,15 +459,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -482,15 +477,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -500,15 +495,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -518,15 +513,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -536,15 +531,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -554,15 +549,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -572,15 +567,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -590,15 +585,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -608,15 +603,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -626,15 +621,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -644,15 +639,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -662,15 +657,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 29, - 31 - ], "loc": { "start": { "line": 1, @@ -680,15 +675,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 29, + 31 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -698,15 +693,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -716,15 +711,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -734,15 +729,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -752,15 +747,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -770,7 +765,11 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array-multi.result.js index 8a1fa7d4..4b82bbda 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array-multi.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 4, + 22 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 4, + 18 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -28,16 +92,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -47,30 +110,17 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } }, { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -80,15 +130,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, { "type": "Identifier", - "name": "z", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -98,31 +148,17 @@ module.exports = { "line": 1, "column": 17 } - } - } - ], - "range": [ - 4, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 18 + }, + "range": [ + 16, + 17 + ], + "name": "z" } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -132,64 +168,23 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "range": [ - 4, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 21, + 22 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -199,15 +194,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -217,15 +212,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -235,15 +230,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -253,15 +248,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -271,15 +266,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -289,15 +284,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -307,15 +302,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -325,15 +320,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -343,15 +338,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -361,15 +356,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -379,15 +374,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -397,15 +392,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -415,7 +410,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array-nested-all.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array-nested-all.result.js index 21871817..6623c704 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array-nested-all.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array-nested-all.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 4, + 27 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 4, + 23 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -28,16 +92,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -47,36 +110,50 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], + }, + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" + } + }, + { + "type": "ArrayPattern", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 22 } - } - }, - { - "type": "ArrayPattern", + }, + "range": [ + 13, + 22 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 15, + 21 + ], "left": { "type": "Identifier", - "name": "z", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -86,16 +163,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "name": "z" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 19, - 21 - ], "loc": { "start": { "line": 1, @@ -105,62 +181,21 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 15, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 15 }, - "end": { - "line": 1, - "column": 21 - } + "range": [ + 19, + 21 + ], + "value": 10, + "raw": "10" } } - ], - "range": [ - 13, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - ], - "range": [ - 4, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 23 + ] } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -170,64 +205,23 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 4, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 26, + 27 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -237,15 +231,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -255,15 +249,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -273,15 +267,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -291,15 +285,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -309,15 +303,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -327,15 +321,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -345,15 +339,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -363,15 +357,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -381,15 +375,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 19, - 21 - ], "loc": { "start": { "line": 1, @@ -399,15 +393,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 19, + 21 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -417,15 +411,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -435,15 +429,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -453,15 +447,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -471,15 +465,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -489,7 +483,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array-nested-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array-nested-multi.result.js index 0045ec1b..75b4a2e9 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array-nested-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array-nested-multi.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 4, + 23 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 4, + 19 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -28,16 +92,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -47,33 +110,34 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], + }, + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" + } + }, + { + "type": "ArrayPattern", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - { - "type": "ArrayPattern", + }, + "range": [ + 13, + 18 + ], "elements": [ { "type": "Identifier", - "name": "z", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -83,47 +147,19 @@ module.exports = { "line": 1, "column": 16 } - } - } - ], - "range": [ - 13, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 18 + }, + "range": [ + 15, + 16 + ], + "name": "z" } - } + ] } - ], - "range": [ - 4, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 19 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -133,64 +169,23 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "range": [ - 4, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 23 - } + "range": [ + 22, + 23 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -200,15 +195,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -218,15 +213,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -236,15 +231,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -254,15 +249,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -272,15 +267,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -290,15 +285,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -308,15 +303,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -326,15 +321,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -344,15 +339,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -362,15 +357,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -380,15 +375,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -398,15 +393,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -416,7 +411,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-array.result.js b/tests/fixtures/ecma-features/destructuring/defaults-array.result.js index 8e580450..f54cdab8 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-array.result.js @@ -1,24 +1,88 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "operator": "=", "left": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 1, + 5 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -28,16 +92,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 3, - 5 - ], "loc": { "start": { "line": 1, @@ -47,46 +110,19 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 1, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 5 - } + "range": [ + 3, + 5 + ], + "value": 10, + "raw": "10" } } - ], - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - } + ] }, "right": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -96,62 +132,21 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 10 - } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 + "range": [ + 9, + 10 + ], + "name": "x" } } } ], "sourceType": "script", - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, "tokens": [ { "type": "Punctuator", "value": "[", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -161,15 +156,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -179,15 +174,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -197,15 +192,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 3, - 5 - ], "loc": { "start": { "line": 1, @@ -215,15 +210,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 3, + 5 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -233,15 +228,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -251,15 +246,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -269,7 +264,11 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-all.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-all.result.js index 5ab040e7..bfc0d019 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-all.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-all.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 4, + 30 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 4, + 26 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,32 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -48,16 +130,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -67,51 +148,37 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 11 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - { - "type": "Property", + }, + "range": [ + 13, + 18 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -121,18 +188,32 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 13, + 18 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -142,16 +223,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -161,51 +241,37 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 13, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 17, + 18 + ], + "value": 5, + "raw": "5" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 13, - 18 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 13 + "column": 20 }, "end": { "line": 1, - "column": 18 + "column": 25 } - } - }, - { - "type": "Property", + }, + "range": [ + 20, + 25 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -215,18 +281,32 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ], + "name": "z" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 20, + 25 + ], "left": { "type": "Identifier", - "name": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -236,16 +316,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ], + "name": "z" }, "right": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -255,65 +334,20 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "range": [ - 20, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 25 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 20, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 25 + "range": [ + 24, + 25 + ], + "value": 1, + "raw": "1" } } } - ], - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 26 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -323,64 +357,23 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 4, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 30 - } + "range": [ + 29, + 30 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -390,15 +383,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -408,15 +401,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -426,15 +419,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -444,15 +437,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -462,15 +455,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -480,15 +473,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -498,15 +491,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -516,15 +509,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -534,15 +527,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -552,15 +545,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -570,15 +563,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -588,15 +581,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -606,15 +599,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -624,15 +617,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -642,15 +635,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -660,15 +653,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -678,7 +671,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-longform-all.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-longform-all.result.js index e214a6ba..0759bf02 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-longform-all.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-longform-all.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 4, + 41 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 4, + 37 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 5, + 14 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,31 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 8, + 14 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -48,16 +129,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -67,51 +147,38 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 8, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 5, - 14 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 16 }, "end": { "line": 1, - "column": 14 + "column": 25 } - } - }, - { - "type": "Property", + }, + "range": [ + 16, + 25 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -121,18 +188,31 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "y" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 19, + 25 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -142,16 +222,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 23, - 25 - ], "loc": { "start": { "line": 1, @@ -161,51 +240,38 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "range": [ - 19, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 19 }, - "end": { - "line": 1, - "column": 25 - } + "range": [ + 23, + 25 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 16, - 25 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 16 + "column": 27 }, "end": { "line": 1, - "column": 25 + "column": 36 } - } - }, - { - "type": "Property", + }, + "range": [ + 27, + 36 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -215,18 +281,31 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ], + "name": "z" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 30, + 36 + ], "left": { "type": "Identifier", - "name": "z", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -236,84 +315,39 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ], + "name": "z" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 34, - 36 - ], "loc": { "start": { "line": 1, - "column": 34 - }, - "end": { - "line": 1, - "column": 36 - } - } - }, - "range": [ - 30, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 30 + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } }, - "end": { - "line": 1, - "column": 36 - } + "range": [ + 34, + 36 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 27, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 36 - } - } - } - ], - "range": [ - 4, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 37 + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -323,64 +357,23 @@ module.exports = { "line": 1, "column": 41 } - } - }, - "range": [ - 4, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 41 - } + "range": [ + 40, + 41 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 42 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 42 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 42 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 42 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -390,15 +383,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -408,15 +401,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -426,15 +419,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -444,15 +437,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -462,15 +455,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -480,15 +473,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -498,15 +491,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -516,15 +509,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -534,15 +527,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -552,15 +545,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -570,15 +563,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -588,15 +581,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 23, - 25 - ], "loc": { "start": { "line": 1, @@ -606,15 +599,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 23, + 25 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -624,15 +617,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -642,15 +635,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -660,15 +653,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -678,15 +671,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -696,15 +689,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 34, - 36 - ], "loc": { "start": { "line": 1, @@ -714,15 +707,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 34, + 36 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -732,15 +725,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -750,15 +743,15 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -768,15 +761,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 1, @@ -786,7 +779,11 @@ module.exports = { "line": 1, "column": 42 } - } + }, + "range": [ + 41, + 42 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-longform-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-longform-multi.result.js index 76edf35b..e718bf10 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-longform-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-longform-multi.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 4, + 31 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 4, + 27 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "value": { "type": "Identifier", - "name": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -45,36 +113,36 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "x" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 5, - 9 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 11 }, "end": { "line": 1, - "column": 9 + "column": 20 } - } - }, - { - "type": "Property", + }, + "range": [ + 11, + 20 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -84,18 +152,31 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "y" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 14, + 20 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -105,16 +186,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -124,51 +204,38 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 14, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 14 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 18, + 20 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 11, - 20 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 11 + "column": 22 }, "end": { "line": 1, - "column": 20 + "column": 26 } - } - }, - { - "type": "Property", + }, + "range": [ + 22, + 26 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -178,15 +245,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ], + "name": "z" }, "value": { "type": "Identifier", - "name": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -196,50 +263,19 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 22, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 22 }, - "end": { - "line": 1, - "column": 26 - } - } - } - ], - "range": [ - 4, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 27 + "range": [ + 25, + 26 + ], + "name": "z" + }, + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -249,64 +285,23 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "range": [ - 4, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 31 - } + "range": [ + 30, + 31 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -316,15 +311,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -334,15 +329,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -352,15 +347,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -370,15 +365,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -388,15 +383,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -406,15 +401,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -424,15 +419,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -442,15 +437,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -460,15 +455,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -478,15 +473,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -496,15 +491,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 18, + 20 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -514,15 +509,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -532,15 +527,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -550,15 +545,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -568,15 +563,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -586,15 +581,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -604,15 +599,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -622,15 +617,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -640,7 +635,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-longform.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-longform.result.js index 90d7aeae..84200af9 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-longform.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-longform.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 4, + 21 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 4, + 17 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 6, + 15 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,31 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "x" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 9, + 15 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -48,16 +129,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -67,65 +147,21 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "range": [ - 9, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 13, + 15 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 6, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 15 - } - } - } - ], - "range": [ - 4, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 17 + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "x", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -135,64 +171,23 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 4, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 21 - } + "range": [ + 20, + 21 + ], + "name": "x" } } ], - "kind": "var", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -202,15 +197,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -220,15 +215,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -238,15 +233,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -256,15 +251,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -274,15 +269,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -292,15 +287,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 13, - 15 - ], "loc": { "start": { "line": 1, @@ -310,15 +305,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 13, + 15 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -328,15 +323,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -346,15 +341,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -364,15 +359,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -382,7 +377,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-mixed-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-mixed-multi.result.js index ecbaec33..a3e20a52 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-mixed-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-mixed-multi.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 4, + 25 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 4, + 21 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,16 @@ module.exports = { "line": 1, "column": 6 } - } - }, - "value": { - "type": "Identifier", - "name": "x", + }, "range": [ 5, 6 ], + "name": "x" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -45,36 +114,35 @@ module.exports = { "line": 1, "column": 6 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 6 - ], + }, + "range": [ + 5, + 6 + ], + "name": "x" + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 8 }, "end": { "line": 1, - "column": 6 + "column": 17 } - } - }, - { - "type": "Property", + }, + "range": [ + 8, + 17 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -84,18 +152,31 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "y" }, "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 11, + 17 + ], "left": { "type": "Identifier", - "name": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -105,16 +186,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "y" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -124,51 +204,38 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "range": [ - 11, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 17 - } + "range": [ + 15, + 17 + ], + "value": 10, + "raw": "10" } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 8, - 17 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 8 + "column": 19 }, "end": { "line": 1, - "column": 17 + "column": 20 } - } - }, - { - "type": "Property", + }, + "range": [ + 19, + 20 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -178,15 +245,16 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "value": { - "type": "Identifier", - "name": "z", + }, "range": [ 19, 20 ], + "name": "z" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -196,50 +264,18 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 19, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 19 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 19, + 20 + ], + "name": "z" } } - ], - "range": [ - 4, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 21 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -249,64 +285,23 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "range": [ - 4, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 25 - } + "range": [ + 24, + 25 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -316,15 +311,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -334,15 +329,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -352,15 +347,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -370,15 +365,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -388,15 +383,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -406,15 +401,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -424,15 +419,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -442,15 +437,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -460,15 +455,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 15, + 17 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -478,15 +473,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -496,15 +491,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -514,15 +509,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -532,15 +527,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -550,15 +545,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -568,7 +563,11 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-multi.result.js index a76a9f59..f7540e0e 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-multi.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 4, + 22 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 4, + 18 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,32 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -48,16 +130,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -67,51 +148,37 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 11 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 14 } - } - }, - { - "type": "Property", + }, + "range": [ + 13, + 14 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -121,15 +188,16 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "value": { - "type": "Identifier", - "name": "y", + }, "range": [ 13, 14 ], + "name": "y" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -139,36 +207,35 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 13, - 14 - ], + }, + "range": [ + 13, + 14 + ], + "name": "y" + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 13 + "column": 16 }, "end": { "line": 1, - "column": 14 + "column": 17 } - } - }, - { - "type": "Property", + }, + "range": [ + 16, + 17 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -178,15 +245,16 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "value": { - "type": "Identifier", - "name": "z", + }, "range": [ 16, 17 ], + "name": "z" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -196,50 +264,18 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 16, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 17 - } + "range": [ + 16, + 17 + ], + "name": "z" } } - ], - "range": [ - 4, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 18 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -249,64 +285,23 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "range": [ - 4, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 21, + 22 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -316,15 +311,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -334,15 +329,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -352,15 +347,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -370,15 +365,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -388,15 +383,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -406,15 +401,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -424,15 +419,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -442,15 +437,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -460,15 +455,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -478,15 +473,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -496,15 +491,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -514,15 +509,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -532,7 +527,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-nested-all.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-nested-all.result.js index c9cbdb98..7b4322f4 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-nested-all.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-nested-all.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 4, + 30 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 4, + 26 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,32 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -48,16 +130,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -67,51 +148,37 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 11 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 25 } - } - }, - { - "type": "Property", + }, + "range": [ + 13, + 25 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -121,20 +188,51 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 16, + 25 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 18, + 24 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -144,18 +242,32 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ], + "name": "z" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 18, + 24 + ], "left": { "type": "Identifier", - "name": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -165,16 +277,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ], + "name": "z" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 22, - 24 - ], "loc": { "start": { "line": 1, @@ -184,100 +295,24 @@ module.exports = { "line": 1, "column": 24 } - } - }, - "range": [ - 18, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 18, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 24 + "range": [ + 22, + 24 + ], + "value": 10, + "raw": "10" } } } - ], - "range": [ - 16, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 25 - } - } + ] }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 13, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 25 - } - } - } - ], - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 26 + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -287,64 +322,23 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 4, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 30 - } + "range": [ + 29, + 30 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -354,15 +348,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -372,15 +366,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -390,15 +384,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -408,15 +402,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -426,15 +420,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -444,15 +438,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -462,15 +456,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -480,15 +474,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -498,15 +492,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -516,15 +510,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -534,15 +528,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 22, - 24 - ], "loc": { "start": { "line": 1, @@ -552,15 +546,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 22, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -570,15 +564,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -588,15 +582,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -606,15 +600,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -624,15 +618,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -642,7 +636,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object-nested-multi.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object-nested-multi.result.js index f2ca577f..f4fbd8d2 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object-nested-multi.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object-nested-multi.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 4, + 26 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 4, + 22 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,32 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -48,16 +130,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -67,51 +148,37 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 11 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 21 } - } - }, - { - "type": "Property", + }, + "range": [ + 13, + 21 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -121,20 +188,51 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "y" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 16, + 21 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -144,15 +242,16 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "value": { - "type": "Identifier", - "name": "z", + }, "range": [ 18, 19 ], + "name": "z" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -162,85 +261,22 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 18, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 19 - } + "range": [ + 18, + 19 + ], + "name": "z" } } - ], - "range": [ - 16, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 21 - } - } + ] }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 13, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 21 - } - } - } - ], - "range": [ - 4, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 22 + "kind": "init" } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -250,64 +286,23 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 26 - } + "range": [ + 25, + 26 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -317,15 +312,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -335,15 +330,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -353,15 +348,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -371,15 +366,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -389,15 +384,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -407,15 +402,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -425,15 +420,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -443,15 +438,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -461,15 +456,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -479,15 +474,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -497,15 +492,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -515,15 +510,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -533,15 +528,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -551,15 +546,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -569,7 +564,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/defaults-object.result.js b/tests/fixtures/ecma-features/destructuring/defaults-object.result.js index f85cb795..e3c0d880 100644 --- a/tests/fixtures/ecma-features/destructuring/defaults-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/defaults-object.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 4, + 16 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,18 +95,32 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -48,16 +130,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -67,65 +148,20 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 11 + "range": [ + 9, + 11 + ], + "value": 10, + "raw": "10" } } } - ], - "range": [ - 4, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 12 - } - } + ] }, "init": { "type": "Identifier", - "name": "x", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -135,64 +171,23 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 4, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 15, + 16 + ], + "name": "x" } } ], - "kind": "var", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -202,15 +197,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -220,15 +215,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -238,15 +233,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -256,15 +251,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -274,15 +269,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -292,15 +287,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -310,15 +305,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -328,7 +323,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/destructured-array-catch.result.js b/tests/fixtures/ecma-features/destructuring/destructured-array-catch.result.js index f7d0e100..d77c2cc0 100644 --- a/tests/fixtures/ecma-features/destructuring/destructured-array-catch.result.js +++ b/tests/fixtures/ecma-features/destructuring/destructured-array-catch.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "range": [ + 0, + 72 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 11, + 14 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -43,15 +99,16 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "value": { - "type": "Identifier", - "name": "a", + }, "range": [ 12, 13 ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -61,69 +118,138 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 13 - } + "range": [ + 12, + 13 + ], + "name": "a" } } - ], - "range": [ - 11, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 14 - } - } + ] } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 16, + 71 + ], "body": [ { "type": "TryStatement", + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "range": [ + 20, + 69 + ], "block": { "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 24, + 46 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 30, + 42 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 34, + 41 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 34, + 37 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 35, + 36 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 3, @@ -133,15 +259,16 @@ module.exports = { "line": 3, "column": 10 } - } - }, - "value": { - "type": "Identifier", - "name": "b", + }, "range": [ 35, 36 ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 3, @@ -151,50 +278,18 @@ module.exports = { "line": 3, "column": 10 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 35, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 9 }, - "end": { - "line": 3, - "column": 10 - } + "range": [ + 35, + 36 + ], + "name": "b" } } - ], - "range": [ - 34, - 37 - ], - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 11 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -204,68 +299,54 @@ module.exports = { "line": 3, "column": 15 } - } - }, - "range": [ - 34, - 41 - ], - "loc": { - "start": { - "line": 3, - "column": 8 }, - "end": { - "line": 3, - "column": 15 - } + "range": [ + 40, + 41 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 30, - 42 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 16 - } - } + "kind": "var" } - ], - "range": [ - 24, - 46 - ], + ] + }, + "handler": { + "type": "CatchClause", "loc": { "start": { - "line": 2, - "column": 6 + "line": 5, + "column": 2 }, "end": { - "line": 4, + "line": 6, "column": 3 } - } - }, - "handler": { - "type": "CatchClause", + }, + "range": [ + 49, + 69 + ], "param": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 55, + 62 + ], "elements": [ { "type": "Identifier", - "name": "stack", - "range": [ - 56, - 61 - ], "loc": { "start": { "line": 5, @@ -275,31 +356,17 @@ module.exports = { "line": 5, "column": 14 } - } - } - ], - "range": [ - 55, - 62 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 5, - "column": 15 + }, + "range": [ + 56, + 61 + ], + "name": "stack" } - } + ] }, "body": { "type": "BlockStatement", - "body": [], - "range": [ - 64, - 69 - ], "loc": { "start": { "line": 5, @@ -309,78 +376,21 @@ module.exports = { "line": 6, "column": 3 } - } - }, - "range": [ - 49, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 }, - "end": { - "line": 6, - "column": 3 - } + "range": [ + 64, + 69 + ], + "body": [] } }, - "finalizer": null, - "range": [ - 20, - 69 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 6, - "column": 3 - } - } + "finalizer": null } - ], - "range": [ - 16, - 71 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 7, - "column": 1 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 71 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 7, @@ -390,32 +400,18 @@ module.exports = { "line": 7, "column": 2 } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 72 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 2 + }, + "range": [ + 71, + 72 + ] } - }, + ], + "sourceType": "script", "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -461,15 +457,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -479,15 +475,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -497,15 +493,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -515,15 +511,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -533,15 +529,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -551,15 +547,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Keyword", "value": "try", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 2, @@ -569,15 +565,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 20, + 23 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 2, @@ -587,15 +583,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 30, - 33 - ], "loc": { "start": { "line": 3, @@ -605,15 +601,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 30, + 33 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 3, @@ -623,15 +619,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 3, @@ -641,15 +637,15 @@ module.exports = { "line": 3, "column": 10 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 3, @@ -659,15 +655,15 @@ module.exports = { "line": 3, "column": 11 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 3, @@ -677,15 +673,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -695,15 +691,15 @@ module.exports = { "line": 3, "column": 15 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 3, @@ -713,15 +709,15 @@ module.exports = { "line": 3, "column": 16 } - } + }, + "range": [ + 41, + 42 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 4, @@ -731,15 +727,15 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Keyword", "value": "catch", - "range": [ - 49, - 54 - ], "loc": { "start": { "line": 5, @@ -749,15 +745,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 49, + 54 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 54, - 55 - ], "loc": { "start": { "line": 5, @@ -767,15 +763,15 @@ module.exports = { "line": 5, "column": 8 } - } + }, + "range": [ + 54, + 55 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 5, @@ -785,15 +781,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Identifier", "value": "stack", - "range": [ - 56, - 61 - ], "loc": { "start": { "line": 5, @@ -803,15 +799,15 @@ module.exports = { "line": 5, "column": 14 } - } + }, + "range": [ + 56, + 61 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 5, @@ -821,15 +817,15 @@ module.exports = { "line": 5, "column": 15 } - } + }, + "range": [ + 61, + 62 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 5, @@ -839,15 +835,15 @@ module.exports = { "line": 5, "column": 16 } - } + }, + "range": [ + 62, + 63 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 64, - 65 - ], "loc": { "start": { "line": 5, @@ -857,15 +853,15 @@ module.exports = { "line": 5, "column": 18 } - } + }, + "range": [ + 64, + 65 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 68, - 69 - ], "loc": { "start": { "line": 6, @@ -875,15 +871,15 @@ module.exports = { "line": 6, "column": 3 } - } + }, + "range": [ + 68, + 69 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 70, - 71 - ], "loc": { "start": { "line": 7, @@ -893,15 +889,15 @@ module.exports = { "line": 7, "column": 1 } - } + }, + "range": [ + 70, + 71 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 7, @@ -911,7 +907,11 @@ module.exports = { "line": 7, "column": 2 } - } + }, + "range": [ + 71, + 72 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/destructured-object-catch.result.js b/tests/fixtures/ecma-features/destructuring/destructured-object-catch.result.js index 84691ebe..6d4aaa5e 100644 --- a/tests/fixtures/ecma-features/destructuring/destructured-object-catch.result.js +++ b/tests/fixtures/ecma-features/destructuring/destructured-object-catch.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "range": [ + 0, + 72 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 11, + 14 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -43,15 +99,16 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "value": { - "type": "Identifier", - "name": "a", + }, "range": [ 12, 13 ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -61,69 +118,138 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 13 - } + "range": [ + 12, + 13 + ], + "name": "a" } } - ], - "range": [ - 11, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 14 - } - } + ] } ], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 16, + 71 + ], "body": [ { "type": "TryStatement", + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "range": [ + 20, + 69 + ], "block": { "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 24, + 46 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 30, + 42 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 34, + 41 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 34, + 37 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 35, + 36 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 3, @@ -133,15 +259,16 @@ module.exports = { "line": 3, "column": 10 } - } - }, - "value": { - "type": "Identifier", - "name": "b", + }, "range": [ 35, 36 ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 3, @@ -151,50 +278,18 @@ module.exports = { "line": 3, "column": 10 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 35, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 9 }, - "end": { - "line": 3, - "column": 10 - } + "range": [ + 35, + 36 + ], + "name": "b" } } - ], - "range": [ - 34, - 37 - ], - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 11 - } - } + ] }, "init": { "type": "Identifier", - "name": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -204,70 +299,73 @@ module.exports = { "line": 3, "column": 15 } - } - }, - "range": [ - 34, - 41 - ], - "loc": { - "start": { - "line": 3, - "column": 8 }, - "end": { - "line": 3, - "column": 15 - } + "range": [ + 40, + 41 + ], + "name": "a" } } ], - "kind": "var", - "range": [ - 30, - 42 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 16 - } - } + "kind": "var" } - ], - "range": [ - 24, - 46 - ], + ] + }, + "handler": { + "type": "CatchClause", "loc": { "start": { - "line": 2, - "column": 6 + "line": 5, + "column": 2 }, "end": { - "line": 4, + "line": 6, "column": 3 } - } - }, - "handler": { - "type": "CatchClause", + }, + "range": [ + 49, + 69 + ], "param": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 55, + 62 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "range": [ + 56, + 61 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "stack", - "range": [ - 56, - 61 - ], "loc": { "start": { "line": 5, @@ -277,15 +375,16 @@ module.exports = { "line": 5, "column": 14 } - } - }, - "value": { - "type": "Identifier", - "name": "stack", + }, "range": [ 56, 61 ], + "name": "stack" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 5, @@ -295,50 +394,18 @@ module.exports = { "line": 5, "column": 14 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 56, - 61 - ], - "loc": { - "start": { - "line": 5, - "column": 9 }, - "end": { - "line": 5, - "column": 14 - } + "range": [ + 56, + 61 + ], + "name": "stack" } } - ], - "range": [ - 55, - 62 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 5, - "column": 15 - } - } + ] }, "body": { "type": "BlockStatement", - "body": [], - "range": [ - 64, - 69 - ], "loc": { "start": { "line": 5, @@ -348,78 +415,21 @@ module.exports = { "line": 6, "column": 3 } - } - }, - "range": [ - 49, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 }, - "end": { - "line": 6, - "column": 3 - } + "range": [ + 64, + 69 + ], + "body": [] } }, - "finalizer": null, - "range": [ - 20, - 69 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 6, - "column": 3 - } - } + "finalizer": null } - ], - "range": [ - 16, - 71 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 7, - "column": 1 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 71 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 7, @@ -429,32 +439,18 @@ module.exports = { "line": 7, "column": 2 } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 72 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 2 + }, + "range": [ + 71, + 72 + ] } - }, + ], + "sourceType": "script", "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -464,15 +460,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -482,15 +478,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -500,15 +496,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -518,15 +514,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -536,15 +532,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -554,15 +550,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -572,15 +568,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -590,15 +586,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Keyword", "value": "try", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 2, @@ -608,15 +604,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 20, + 23 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 2, @@ -626,15 +622,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 30, - 33 - ], "loc": { "start": { "line": 3, @@ -644,15 +640,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 30, + 33 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 3, @@ -662,15 +658,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 3, @@ -680,15 +676,15 @@ module.exports = { "line": 3, "column": 10 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 3, @@ -698,15 +694,15 @@ module.exports = { "line": 3, "column": 11 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 3, @@ -716,15 +712,15 @@ module.exports = { "line": 3, "column": 13 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -734,15 +730,15 @@ module.exports = { "line": 3, "column": 15 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 3, @@ -752,15 +748,15 @@ module.exports = { "line": 3, "column": 16 } - } + }, + "range": [ + 41, + 42 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 4, @@ -770,15 +766,15 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Keyword", "value": "catch", - "range": [ - 49, - 54 - ], "loc": { "start": { "line": 5, @@ -788,15 +784,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 49, + 54 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 54, - 55 - ], "loc": { "start": { "line": 5, @@ -806,15 +802,15 @@ module.exports = { "line": 5, "column": 8 } - } + }, + "range": [ + 54, + 55 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 5, @@ -824,15 +820,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Identifier", "value": "stack", - "range": [ - 56, - 61 - ], "loc": { "start": { "line": 5, @@ -842,15 +838,15 @@ module.exports = { "line": 5, "column": 14 } - } + }, + "range": [ + 56, + 61 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 5, @@ -860,15 +856,15 @@ module.exports = { "line": 5, "column": 15 } - } + }, + "range": [ + 61, + 62 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 5, @@ -878,15 +874,15 @@ module.exports = { "line": 5, "column": 16 } - } + }, + "range": [ + 62, + 63 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 64, - 65 - ], "loc": { "start": { "line": 5, @@ -896,15 +892,15 @@ module.exports = { "line": 5, "column": 18 } - } + }, + "range": [ + 64, + 65 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 68, - 69 - ], "loc": { "start": { "line": 6, @@ -914,15 +910,15 @@ module.exports = { "line": 6, "column": 3 } - } + }, + "range": [ + 68, + 69 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 70, - 71 - ], "loc": { "start": { "line": 7, @@ -932,15 +928,15 @@ module.exports = { "line": 7, "column": 1 } - } + }, + "range": [ + 70, + 71 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 7, @@ -950,7 +946,11 @@ module.exports = { "line": 7, "column": 2 } - } + }, + "range": [ + 71, + 72 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/named-param.result.js b/tests/fixtures/ecma-features/destructuring/named-param.result.js index 17859f65..ea977284 100644 --- a/tests/fixtures/ecma-features/destructuring/named-param.result.js +++ b/tests/fixtures/ecma-features/destructuring/named-param.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "operator": "=", "left": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 1, + 23 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 3, + 21 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "responseText", - "range": [ - 3, - 15 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 3, + 15 + ], + "name": "responseText" }, "value": { "type": "Identifier", - "name": "text", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 1, @@ -45,50 +113,19 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 3, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 21 - } - } - } - ], - "range": [ - 1, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 23 + "range": [ + 17, + 21 + ], + "name": "text" + }, + "kind": "init" } - } + ] }, "right": { "type": "Identifier", - "name": "res", - "range": [ - 27, - 30 - ], "loc": { "start": { "line": 1, @@ -98,62 +135,21 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 + "range": [ + 27, + 30 + ], + "name": "res" } } } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Identifier", "value": "responseText", - "range": [ - 3, - 15 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 3, + 15 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "text", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 17, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Identifier", "value": "res", - "range": [ - 27, - 30 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 27, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -325,7 +321,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/nested-array.result.js b/tests/fixtures/ecma-features/destructuring/nested-array.result.js index ac865704..f3fd16b8 100644 --- a/tests/fixtures/ecma-features/destructuring/nested-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/nested-array.result.js @@ -1,21 +1,72 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 4, + 30 + ], "id": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 4, + 16 + ], "elements": [ { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -25,20 +76,34 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, null, { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ], "elements": [ null, { "type": "Identifier", - "name": "z", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -48,51 +113,36 @@ module.exports = { "line": 1, "column": 14 } - } - } - ], - "range": [ - 10, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 15 + }, + "range": [ + 13, + 14 + ], + "name": "z" } - } + ] } - ], - "range": [ - 4, - 16 - ], + ] + }, + "init": { + "type": "ArrayExpression", "loc": { "start": { "line": 1, - "column": 4 + "column": 19 }, "end": { "line": 1, - "column": 16 + "column": 30 } - } - }, - "init": { - "type": "ArrayExpression", + }, + "range": [ + 19, + 30 + ], "elements": [ { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -102,16 +152,16 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ], + "value": 1, + "raw": "1" }, { "type": "Literal", - "value": 2, - "raw": "2", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -121,19 +171,33 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ], + "value": 2, + "raw": "2" }, { "type": "ArrayExpression", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 24, + 29 + ], "elements": [ { "type": "Literal", - "value": 3, - "raw": "3", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -143,16 +207,16 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ], + "value": 3, + "raw": "3" }, { "type": "Literal", - "value": 4, - "raw": "4", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -162,96 +226,28 @@ module.exports = { "line": 1, "column": 28 } - } - } - ], - "range": [ - 24, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 29 + }, + "range": [ + 27, + 28 + ], + "value": 4, + "raw": "4" } - } + ] } - ], - "range": [ - 19, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "range": [ - 4, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 30 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -261,15 +257,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -279,15 +275,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -297,15 +293,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -315,15 +311,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -333,15 +329,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -351,15 +347,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -369,15 +365,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -387,15 +383,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -405,15 +401,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -423,15 +419,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -441,15 +437,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -459,15 +455,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -477,15 +473,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -495,15 +491,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Numeric", "value": "2", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -513,15 +509,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -531,15 +527,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -549,15 +545,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Numeric", "value": "3", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -567,15 +563,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -585,15 +581,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Numeric", "value": "4", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -603,15 +599,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -621,15 +617,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -639,15 +635,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -657,7 +653,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/nested-object.result.js b/tests/fixtures/ecma-features/destructuring/nested-object.result.js index f0f32fb6..c9ee5d14 100644 --- a/tests/fixtures/ecma-features/destructuring/nested-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/nested-object.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "range": [ + 0, + 53 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "range": [ + 0, + 53 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "range": [ + 4, + 52 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 4, + 24 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "x" }, "value": { "type": "Identifier", - "name": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -45,36 +113,36 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ], + "name": "y" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 5, - 9 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 5 + "column": 11 }, "end": { "line": 1, - "column": 9 + "column": 22 } - } - }, - { - "type": "Property", + }, + "range": [ + 11, + 22 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -84,20 +152,51 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "z" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 14, + 22 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 16, + 20 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -107,15 +206,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "name": "a" }, "value": { "type": "Identifier", - "name": "b", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -125,90 +224,59 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 16, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 20 - } - } - } - ], - "range": [ - 14, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 22 + "range": [ + 19, + 20 + ], + "name": "b" + }, + "kind": "init" } - } + ] }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 11, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 22 - } - } + "kind": "init" } - ], - "range": [ - 4, - 24 - ], + ] + }, + "init": { + "type": "ObjectExpression", "loc": { "start": { "line": 1, - "column": 4 + "column": 27 }, "end": { "line": 1, - "column": 24 + "column": 52 } - } - }, - "init": { - "type": "ObjectExpression", + }, + "range": [ + 27, + 52 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 29, + 35 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -218,16 +286,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ], + "name": "x" }, "value": { "type": "Literal", - "value": "3", - "raw": "\"3\"", - "range": [ - 32, - 35 - ], "loc": { "start": { "line": 1, @@ -237,36 +304,37 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 32, + 35 + ], + "value": "3", + "raw": "\"3\"" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 29, - 35 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 29 + "column": 37 }, "end": { "line": 1, - "column": 35 + "column": 50 } - } - }, - { - "type": "Property", + }, + "range": [ + 37, + 50 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -276,20 +344,51 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ], + "name": "z" }, "value": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "range": [ + 40, + 50 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "range": [ + 42, + 48 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 1, @@ -299,16 +398,15 @@ module.exports = { "line": 1, "column": 43 } - } + }, + "range": [ + 42, + 43 + ], + "name": "a" }, "value": { "type": "Literal", - "value": "b", - "raw": "\"b\"", - "range": [ - 45, - 48 - ], "loc": { "start": { "line": 1, @@ -316,136 +414,34 @@ module.exports = { }, "end": { "line": 1, - "column": 48 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 42, - 48 - ], - "loc": { - "start": { - "line": 1, - "column": 42 - }, - "end": { - "line": 1, - "column": 48 - } - } - } - ], - "range": [ - 40, - 50 - ], - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 50 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 37, - 50 - ], - "loc": { - "start": { - "line": 1, - "column": 37 - }, - "end": { - "line": 1, - "column": 50 - } - } - } - ], - "range": [ - 27, - 52 - ], - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 52 + "column": 48 + } + }, + "range": [ + 45, + 48 + ], + "value": "b", + "raw": "\"b\"" + }, + "kind": "init" + } + ] + }, + "kind": "init" } - } - }, - "range": [ - 4, - 52 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 52 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 53 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 53 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 53 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 53 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -455,15 +451,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -473,15 +469,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -491,15 +487,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -509,15 +505,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -527,15 +523,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -545,15 +541,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -563,15 +559,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -581,15 +577,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -599,15 +595,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -617,15 +613,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -635,15 +631,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -653,15 +649,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -671,15 +667,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -689,15 +685,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -707,15 +703,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -725,15 +721,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -743,15 +739,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -761,15 +757,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "String", "value": "\"3\"", - "range": [ - 32, - 35 - ], "loc": { "start": { "line": 1, @@ -779,15 +775,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 32, + 35 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -797,15 +793,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -815,15 +811,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -833,15 +829,15 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -851,15 +847,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 1, @@ -869,15 +865,15 @@ module.exports = { "line": 1, "column": 43 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 43, - 44 - ], "loc": { "start": { "line": 1, @@ -887,15 +883,15 @@ module.exports = { "line": 1, "column": 44 } - } + }, + "range": [ + 43, + 44 + ] }, { "type": "String", "value": "\"b\"", - "range": [ - 45, - 48 - ], "loc": { "start": { "line": 1, @@ -905,15 +901,15 @@ module.exports = { "line": 1, "column": 48 } - } + }, + "range": [ + 45, + 48 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 49, - 50 - ], "loc": { "start": { "line": 1, @@ -923,15 +919,15 @@ module.exports = { "line": 1, "column": 50 } - } + }, + "range": [ + 49, + 50 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 1, @@ -941,15 +937,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -959,7 +955,11 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/object-var-named.result.js b/tests/fixtures/ecma-features/destructuring/object-var-named.result.js index 85d7033d..7eaa658d 100644 --- a/tests/fixtures/ecma-features/destructuring/object-var-named.result.js +++ b/tests/fixtures/ecma-features/destructuring/object-var-named.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 4, + 14 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 4, + 9 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "a" }, "value": { "type": "Identifier", - "name": "b", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -45,50 +113,19 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 5, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 8 - } - } - } - ], - "range": [ - 4, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 9 + "range": [ + 7, + 8 + ], + "name": "b" + }, + "kind": "init" } - } + ] }, "init": { "type": "ObjectExpression", - "properties": [], - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -98,64 +135,23 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 4, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "properties": [] } } ], - "kind": "var", - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -165,15 +161,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -309,15 +305,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -327,7 +323,11 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/object-var-undefined.result.js b/tests/fixtures/ecma-features/destructuring/object-var-undefined.result.js index 5a40feeb..8b791263 100644 --- a/tests/fixtures/ecma-features/destructuring/object-var-undefined.result.js +++ b/tests/fixtures/ecma-features/destructuring/object-var-undefined.result.js @@ -1,23 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], "id": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -27,15 +95,16 @@ module.exports = { "line": 1, "column": 6 } - } - }, - "value": { - "type": "Identifier", - "name": "a", + }, "range": [ 5, 6 ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -45,50 +114,18 @@ module.exports = { "line": 1, "column": 6 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 5, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 5, + 6 + ], + "name": "a" } } - ], - "range": [ - 4, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 7 - } - } + ] }, "init": { "type": "ObjectExpression", - "properties": [], - "range": [ - 10, - 12 - ], "loc": { "start": { "line": 1, @@ -98,64 +135,23 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 4, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 10, + 12 + ], + "properties": [] } } ], - "kind": "var", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -165,15 +161,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -291,7 +287,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/param-defaults-array.result.js b/tests/fixtures/ecma-features/destructuring/param-defaults-array.result.js index 05d82901..906c058a 100644 --- a/tests/fixtures/ecma-features/destructuring/param-defaults-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/param-defaults-array.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,22 +42,51 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "generator": false, + "expression": false, "params": [ { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 11, + 19 + ], "elements": [ { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -44,16 +96,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -63,47 +114,20 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 12, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 16, + 18 + ], + "value": 10, + "raw": "10" } } - ], - "range": [ - 11, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 19 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 23 - ], "loc": { "start": { "line": 1, @@ -113,49 +137,20 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 23 - } + "range": [ + 21, + 23 + ], + "body": [] } } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -165,15 +160,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -183,15 +178,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -201,15 +196,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -219,15 +214,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -237,15 +232,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -255,15 +250,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -273,15 +268,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -291,15 +286,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -309,15 +304,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -327,15 +322,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -345,7 +340,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/destructuring/param-defaults-object-nested.result.js b/tests/fixtures/ecma-features/destructuring/param-defaults-object-nested.result.js index 187db077..6e811298 100644 --- a/tests/fixtures/ecma-features/destructuring/param-defaults-object-nested.result.js +++ b/tests/fixtures/ecma-features/destructuring/param-defaults-object-nested.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 0, + 38 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 11, + 34 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -43,18 +99,32 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -64,16 +134,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -83,51 +152,37 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 12, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 16, + 18 + ], + "value": 10, + "raw": "10" } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 12, - 18 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 12 + "column": 20 }, "end": { "line": 1, - "column": 18 + "column": 33 } - } - }, - { - "type": "Property", + }, + "range": [ + 20, + 33 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -137,20 +192,51 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ], + "name": "y" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 23, + 33 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 25, + 31 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -160,52 +246,16 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "value": { - "type": "AssignmentPattern", - "operator": "=", - "left": { - "type": "Identifier", - "name": "z", - "range": [ - 25, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 25 - }, - "end": { - "line": 1, - "column": 26 - } - } - }, - "right": { - "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 29, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 29 - }, - "end": { - "line": 1, - "column": 31 - } - } }, "range": [ 25, - 31 + 26 ], + "name": "z" + }, + "kind": "init", + "value": { + "type": "AssignmentPattern", "loc": { "start": { "line": 1, @@ -215,86 +265,59 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 25, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 25 }, - "end": { - "line": 1, - "column": 31 - } - } - } - ], - "range": [ - 23, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 33 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 20, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 33 - } - } - } - ], - "range": [ - 11, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 34 + "range": [ + 25, + 31 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 25, + 26 + ], + "name": "z" + }, + "right": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 29, + 31 + ], + "value": 10, + "raw": "10" + } + } + } + ] + }, + "kind": "init" } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 36, - 38 - ], "loc": { "start": { "line": 1, @@ -304,31 +327,16 @@ module.exports = { "line": 1, "column": 38 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 38 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 38 - } + "range": [ + 36, + 38 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -338,32 +346,18 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] } ], "sourceType": "script", - "range": [ - 0, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 39 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -373,15 +367,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -391,15 +385,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -409,15 +403,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -427,15 +421,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -445,15 +439,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -463,15 +457,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -481,15 +475,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -499,15 +493,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -517,15 +511,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -535,15 +529,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -553,15 +547,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -571,15 +565,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -589,15 +583,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 29, - 31 - ], "loc": { "start": { "line": 1, @@ -607,15 +601,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 29, + 31 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -625,15 +619,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -643,15 +637,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -661,15 +655,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -679,15 +673,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -697,15 +691,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -715,7 +709,11 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/param-defaults-object.result.js b/tests/fixtures/ecma-features/destructuring/param-defaults-object.result.js index c57860f3..2b264457 100644 --- a/tests/fixtures/ecma-features/destructuring/param-defaults-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/param-defaults-object.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 11, + 19 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -43,18 +99,32 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, + "kind": "init", "value": { "type": "AssignmentPattern", - "operator": "=", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], "left": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -64,16 +134,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, "right": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -83,66 +152,21 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 12, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 12, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 18 + "range": [ + 16, + 18 + ], + "value": 10, + "raw": "10" } } } - ], - "range": [ - 11, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 19 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 23 - ], "loc": { "start": { "line": 1, @@ -152,49 +176,20 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 23 - } + "range": [ + 21, + 23 + ], + "body": [] } } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -204,15 +199,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -222,15 +217,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -240,15 +235,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -258,15 +253,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -276,15 +271,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -294,15 +289,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -312,15 +307,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -330,15 +325,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -348,15 +343,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -366,15 +361,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -384,7 +379,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/destructuring/params-array-wrapped.result.js b/tests/fixtures/ecma-features/destructuring/params-array-wrapped.result.js index 5a34fd34..c4fda76d 100644 --- a/tests/fixtures/ecma-features/destructuring/params-array-wrapped.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-array-wrapped.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 1, + 23 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -21,19 +58,35 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 12, + 20 + ], "elements": [ { "type": "Identifier", - "name": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -43,15 +96,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ], + "name": "a" }, { "type": "Identifier", - "name": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -61,32 +114,18 @@ module.exports = { "line": 1, "column": 18 } - } - } - ], - "range": [ - 12, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 20 + }, + "range": [ + 17, + 18 + ], + "name": "b" } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 23 - ], "loc": { "start": { "line": 1, @@ -96,64 +135,21 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "generator": false, - "expression": false, - "range": [ - 1, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 + "range": [ + 21, + 23 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -343,15 +339,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -361,15 +357,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -379,15 +375,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -397,7 +393,11 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-array.result.js b/tests/fixtures/ecma-features/destructuring/params-array.result.js index 754d447a..e8c90287 100644 --- a/tests/fixtures/ecma-features/destructuring/params-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-array.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,19 +42,35 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 11, + 19 + ], "elements": [ { "type": "Identifier", - "name": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -41,15 +80,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ], + "name": "a" }, { "type": "Identifier", - "name": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -59,32 +98,18 @@ module.exports = { "line": 1, "column": 17 } - } - } - ], - "range": [ - 11, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 19 + }, + "range": [ + 16, + 17 + ], + "name": "b" } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -94,31 +119,16 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 20, + 22 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -128,32 +138,18 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -343,15 +339,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -361,7 +357,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-multi-object.result.js b/tests/fixtures/ecma-features/destructuring/params-multi-object.result.js index cbbf1c78..b2a460de 100644 --- a/tests/fixtures/ecma-features/destructuring/params-multi-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-multi-object.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,18 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -38,20 +63,51 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "a" }, { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 14, + 19 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -61,15 +117,16 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "value": { - "type": "Identifier", - "name": "b", + }, "range": [ 16, 17 ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -79,51 +136,19 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 16, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 17 - } + "range": [ + 16, + 17 + ], + "name": "b" } } - ], - "range": [ - 14, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 19 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -133,31 +158,16 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 20, + 22 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -167,32 +177,18 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -274,15 +270,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -292,15 +288,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -310,15 +306,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -328,15 +324,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -346,15 +342,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -364,15 +360,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -382,15 +378,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -400,7 +396,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-nested-array.result.js b/tests/fixtures/ecma-features/destructuring/params-nested-array.result.js index ba879e60..980e0c19 100644 --- a/tests/fixtures/ecma-features/destructuring/params-nested-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-nested-array.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,19 +42,35 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "generator": false, + "expression": false, "params": [ { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 11, + 23 + ], "elements": [ { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -41,20 +80,34 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, null, { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 17, + 22 + ], "elements": [ null, { "type": "Identifier", - "name": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -64,48 +117,20 @@ module.exports = { "line": 1, "column": 21 } - } - } - ], - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 + }, + "range": [ + 20, + 21 + ], + "name": "z" } - } + ] } - ], - "range": [ - 11, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 23 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 25, - 27 - ], "loc": { "start": { "line": 1, @@ -115,31 +140,16 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 25, + 27 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -149,32 +159,18 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ], "sourceType": "script", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -184,15 +180,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -274,15 +270,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -292,15 +288,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -310,15 +306,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -328,15 +324,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -346,15 +342,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -364,15 +360,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -382,15 +378,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -400,15 +396,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -418,15 +414,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -436,15 +432,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -454,7 +450,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-nested-object.result.js b/tests/fixtures/ecma-features/destructuring/params-nested-object.result.js index a453b4f9..c6f7786a 100644 --- a/tests/fixtures/ecma-features/destructuring/params-nested-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-nested-object.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 11, + 31 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 12, + 16 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -43,15 +99,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ], + "name": "x" }, "value": { "type": "Identifier", - "name": "y", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -61,36 +117,36 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "name": "y" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 12, - 16 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 12 + "column": 18 }, "end": { "line": 1, - "column": 16 + "column": 29 } - } - }, - { - "type": "Property", + }, + "range": [ + 18, + 29 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -100,20 +156,51 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ], + "name": "z" }, "value": { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 21, + 29 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 23, + 27 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -123,15 +210,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ], + "name": "a" }, "value": { "type": "Identifier", - "name": "b", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -141,86 +228,24 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 23, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 23 }, - "end": { - "line": 1, - "column": 27 - } - } - } - ], - "range": [ - 21, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 29 + "range": [ + 26, + 27 + ], + "name": "b" + }, + "kind": "init" } - } + ] }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 18, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 29 - } - } - } - ], - "range": [ - 11, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 31 + "kind": "init" } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 33, - 35 - ], "loc": { "start": { "line": 1, @@ -230,31 +255,16 @@ module.exports = { "line": 1, "column": 35 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 35 - } + "range": [ + 33, + 35 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -264,32 +274,18 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] } ], "sourceType": "script", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 36 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -299,15 +295,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -317,15 +313,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -335,15 +331,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -353,15 +349,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -371,15 +367,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -389,15 +385,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -407,15 +403,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "z", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -461,15 +457,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -479,15 +475,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -497,15 +493,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -515,15 +511,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -533,15 +529,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -551,15 +547,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -569,15 +565,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -587,15 +583,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -605,15 +601,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -623,15 +619,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -641,7 +637,11 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-object-wrapped.result.js b/tests/fixtures/ecma-features/destructuring/params-object-wrapped.result.js index eeb12143..fac97e31 100644 --- a/tests/fixtures/ecma-features/destructuring/params-object-wrapped.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-object-wrapped.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 1, + 23 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -21,21 +58,54 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 12, + 20 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -45,15 +115,16 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "value": { - "type": "Identifier", - "name": "a", + }, "range": [ 14, 15 ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -63,36 +134,35 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 14, - 15 - ], + }, + "range": [ + 14, + 15 + ], + "name": "a" + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 14 + "column": 17 }, "end": { "line": 1, - "column": 15 + "column": 18 } - } - }, - { - "type": "Property", + }, + "range": [ + 17, + 18 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -102,15 +172,16 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "value": { - "type": "Identifier", - "name": "b", + }, "range": [ 17, 18 ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -120,51 +191,19 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 17, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 17, + 18 + ], + "name": "b" } } - ], - "range": [ - 12, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 20 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 23 - ], "loc": { "start": { "line": 1, @@ -174,64 +213,21 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "generator": false, - "expression": false, - "range": [ - 1, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 + "range": [ + 21, + 23 + ], + "body": [] } } } ], "sourceType": "script", - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -241,15 +237,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -259,15 +255,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -277,15 +273,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -295,15 +291,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -313,15 +309,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -331,15 +327,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -349,15 +345,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -367,15 +363,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -385,15 +381,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -403,15 +399,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -421,15 +417,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -439,15 +435,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -457,15 +453,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -475,7 +471,11 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/params-object.result.js b/tests/fixtures/ecma-features/destructuring/params-object.result.js index 89d8af70..0acce765 100644 --- a/tests/fixtures/ecma-features/destructuring/params-object.result.js +++ b/tests/fixtures/ecma-features/destructuring/params-object.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,21 +42,54 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "x" }, + "generator": false, + "expression": false, "params": [ { "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 11, + 19 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -43,15 +99,16 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "value": { - "type": "Identifier", - "name": "a", + }, "range": [ 13, 14 ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -61,36 +118,35 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 13, - 14 - ], + }, + "range": [ + 13, + 14 + ], + "name": "a" + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 13 + "column": 16 }, "end": { "line": 1, - "column": 14 + "column": 17 } - } - }, - { - "type": "Property", + }, + "range": [ + 16, + 17 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -100,15 +156,16 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "value": { - "type": "Identifier", - "name": "b", + }, "range": [ 16, 17 ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -118,51 +175,19 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 16, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 17 - } + "range": [ + 16, + 17 + ], + "name": "b" } } - ], - "range": [ - 11, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 19 - } - } + ] } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -172,31 +197,16 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 20, + 22 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -206,32 +216,18 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -241,15 +237,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -259,15 +255,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -277,15 +273,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -295,15 +291,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -313,15 +309,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -331,15 +327,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -349,15 +345,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -367,15 +363,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -385,15 +381,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -403,15 +399,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -421,15 +417,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -439,7 +435,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/destructuring/sparse-array.result.js b/tests/fixtures/ecma-features/destructuring/sparse-array.result.js index e2a7aa98..b694b800 100644 --- a/tests/fixtures/ecma-features/destructuring/sparse-array.result.js +++ b/tests/fixtures/ecma-features/destructuring/sparse-array.result.js @@ -1,21 +1,72 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "operator": "=", "left": { "type": "ArrayPattern", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "elements": [ { "type": "Identifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -25,16 +76,16 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, null, { "type": "Identifier", - "name": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -44,31 +95,17 @@ module.exports = { "line": 1, "column": 5 } - } - } - ], - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 + }, + "range": [ + 4, + 5 + ], + "name": "b" } - } + ] }, "right": { "type": "Identifier", - "name": "array", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -78,62 +115,21 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 14 - } - } - }, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 + "range": [ + 9, + 14 + ], + "name": "array" } } } ], "sourceType": "script", - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - }, "tokens": [ { "type": "Punctuator", "value": "[", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "array", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 9, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/experimentalObjectRestSpread/property-spread.result.js b/tests/fixtures/ecma-features/experimentalObjectRestSpread/property-spread.result.js index f46ed273..25637c84 100644 --- a/tests/fixtures/ecma-features/experimentalObjectRestSpread/property-spread.result.js +++ b/tests/fixtures/ecma-features/experimentalObjectRestSpread/property-spread.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "range": [ + 0, + 83 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 0, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,33 +59,33 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, - "init": null, - "range": [ - 4, - 7 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 1, + "line": 2, "column": 4 }, "end": { - "line": 1, + "line": 2, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 13, + 16 + ], "id": { "type": "Identifier", - "name": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -58,33 +95,33 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ], + "name": "get" }, - "init": null, - "range": [ - 13, - 16 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 2, + "line": 3, "column": 4 }, "end": { - "line": 2, + "line": 3, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 22, + 25 + ], "id": { "type": "Identifier", - "name": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -94,53 +131,53 @@ module.exports = { "line": 3, "column": 7 } - } - }, - "init": null, - "range": [ - 22, - 25 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 7 - } - } + "range": [ + 22, + 25 + ], + "name": "set" + }, + "init": null } ], - "kind": "var", - "range": [ - 0, - 26 - ], + "kind": "var" + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 5, "column": 0 }, "end": { - "line": 3, - "column": 8 + "line": 9, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 28, + 83 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 32, + 82 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -150,20 +187,51 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 36, + 82 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 42, + 50 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -173,15 +241,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ], + "name": "foo" }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -191,36 +259,36 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ], + "name": "foo" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 42, - 50 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { - "line": 6, + "line": 7, "column": 4 }, "end": { - "line": 6, + "line": 7, "column": 12 } - } - }, - { - "type": "Property", + }, + "range": [ + 56, + 64 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "get", - "range": [ - 56, - 59 - ], "loc": { "start": { "line": 7, @@ -230,15 +298,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 56, + 59 + ], + "name": "get" }, "value": { "type": "Identifier", - "name": "get", - "range": [ - 61, - 64 - ], "loc": { "start": { "line": 7, @@ -248,39 +316,49 @@ module.exports = { "line": 7, "column": 12 } - } + }, + "range": [ + 61, + 64 + ], + "name": "get" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 56, - 64 - ], + "kind": "init" + }, + { + "type": "ExperimentalSpreadProperty", "loc": { "start": { - "line": 7, + "line": 8, "column": 4 }, "end": { - "line": 7, - "column": 12 + "line": 8, + "column": 14 } - } - }, - { - "type": "ExperimentalSpreadProperty", + }, + "range": [ + 70, + 80 + ], "argument": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 73, + 80 + ], "object": { "type": "Identifier", - "name": "set", - "range": [ - 73, - 76 - ], "loc": { "start": { "line": 8, @@ -290,128 +368,46 @@ module.exports = { "line": 8, "column": 10 } - } + }, + "range": [ + 73, + 76 + ], + "name": "set" }, "property": { "type": "Identifier", - "name": "foo", - "range": [ - 77, - 80 - ], "loc": { "start": { "line": 8, "column": 11 }, "end": { - "line": 8, - "column": 14 - } - } - }, - "range": [ - 73, - 80 - ], - "loc": { - "start": { - "line": 8, - "column": 7 + "line": 8, + "column": 14 + } }, - "end": { - "line": 8, - "column": 14 - } - } - }, - "range": [ - 70, - 80 - ], - "loc": { - "start": { - "line": 8, - "column": 4 + "range": [ + 77, + 80 + ], + "name": "foo" }, - "end": { - "line": 8, - "column": 14 - } + "computed": false } } - ], - "range": [ - 36, - 82 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 9, - "column": 1 - } - } - }, - "range": [ - 32, - 82 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 9, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 28, - 83 - ], - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 83 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -421,15 +417,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -439,15 +435,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -457,15 +453,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -475,15 +471,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -493,15 +489,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -511,15 +507,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 22, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -529,15 +525,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 28, - 31 - ], "loc": { "start": { "line": 5, @@ -547,15 +543,15 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 28, + 31 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -565,15 +561,15 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -583,15 +579,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 5, @@ -601,15 +597,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -619,15 +615,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 6, @@ -637,15 +633,15 @@ module.exports = { "line": 6, "column": 8 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -655,15 +651,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 6, @@ -673,15 +669,15 @@ module.exports = { "line": 6, "column": 13 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 56, - 59 - ], "loc": { "start": { "line": 7, @@ -691,15 +687,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 56, + 59 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 59, - 60 - ], "loc": { "start": { "line": 7, @@ -709,15 +705,15 @@ module.exports = { "line": 7, "column": 8 } - } + }, + "range": [ + 59, + 60 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 61, - 64 - ], "loc": { "start": { "line": 7, @@ -727,15 +723,15 @@ module.exports = { "line": 7, "column": 12 } - } + }, + "range": [ + 61, + 64 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 64, - 65 - ], "loc": { "start": { "line": 7, @@ -745,15 +741,15 @@ module.exports = { "line": 7, "column": 13 } - } + }, + "range": [ + 64, + 65 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 70, - 73 - ], "loc": { "start": { "line": 8, @@ -763,15 +759,15 @@ module.exports = { "line": 8, "column": 7 } - } + }, + "range": [ + 70, + 73 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 73, - 76 - ], "loc": { "start": { "line": 8, @@ -781,15 +777,15 @@ module.exports = { "line": 8, "column": 10 } - } + }, + "range": [ + 73, + 76 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 76, - 77 - ], "loc": { "start": { "line": 8, @@ -799,15 +795,15 @@ module.exports = { "line": 8, "column": 11 } - } + }, + "range": [ + 76, + 77 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 77, - 80 - ], "loc": { "start": { "line": 8, @@ -817,15 +813,15 @@ module.exports = { "line": 8, "column": 14 } - } + }, + "range": [ + 77, + 80 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 81, - 82 - ], "loc": { "start": { "line": 9, @@ -835,15 +831,15 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 81, + 82 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 82, - 83 - ], "loc": { "start": { "line": 9, @@ -853,7 +849,11 @@ module.exports = { "line": 9, "column": 2 } - } + }, + "range": [ + 82, + 83 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/experimentalObjectRestSpread/single-spread.result.js b/tests/fixtures/ecma-features/experimentalObjectRestSpread/single-spread.result.js index 716ff7e4..f2afb48d 100644 --- a/tests/fixtures/ecma-features/experimentalObjectRestSpread/single-spread.result.js +++ b/tests/fixtures/ecma-features/experimentalObjectRestSpread/single-spread.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "range": [ + 0, + 79 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 0, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,33 +59,33 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, - "init": null, - "range": [ - 4, - 7 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 1, + "line": 2, "column": 4 }, "end": { - "line": 1, + "line": 2, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 13, + 16 + ], "id": { "type": "Identifier", - "name": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -58,33 +95,33 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ], + "name": "get" }, - "init": null, - "range": [ - 13, - 16 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 2, + "line": 3, "column": 4 }, "end": { - "line": 2, + "line": 3, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 22, + 25 + ], "id": { "type": "Identifier", - "name": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -94,53 +131,53 @@ module.exports = { "line": 3, "column": 7 } - } - }, - "init": null, - "range": [ - 22, - 25 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 7 - } - } + "range": [ + 22, + 25 + ], + "name": "set" + }, + "init": null } ], - "kind": "var", - "range": [ - 0, - 26 - ], + "kind": "var" + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 5, "column": 0 }, "end": { - "line": 3, - "column": 8 + "line": 9, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 28, + 79 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 32, + 78 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -150,20 +187,51 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 36, + 78 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 42, + 50 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -173,15 +241,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ], + "name": "foo" }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -191,36 +259,36 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ], + "name": "foo" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 42, - 50 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { - "line": 6, + "line": 7, "column": 4 }, "end": { - "line": 6, + "line": 7, "column": 12 } - } - }, - { - "type": "Property", + }, + "range": [ + 56, + 64 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "get", - "range": [ - 56, - 59 - ], "loc": { "start": { "line": 7, @@ -230,15 +298,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 56, + 59 + ], + "name": "get" }, "value": { "type": "Identifier", - "name": "get", - "range": [ - 61, - 64 - ], "loc": { "start": { "line": 7, @@ -248,36 +316,33 @@ module.exports = { "line": 7, "column": 12 } - } + }, + "range": [ + 61, + 64 + ], + "name": "get" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 56, - 64 - ], + "kind": "init" + }, + { + "type": "ExperimentalSpreadProperty", "loc": { "start": { - "line": 7, + "line": 8, "column": 4 }, "end": { - "line": 7, - "column": 12 + "line": 8, + "column": 10 } - } - }, - { - "type": "ExperimentalSpreadProperty", + }, + "range": [ + 70, + 76 + ], "argument": { "type": "Identifier", - "name": "set", - "range": [ - 73, - 76 - ], "loc": { "start": { "line": 8, @@ -287,95 +352,26 @@ module.exports = { "line": 8, "column": 10 } - } - }, - "range": [ - 70, - 76 - ], - "loc": { - "start": { - "line": 8, - "column": 4 }, - "end": { - "line": 8, - "column": 10 - } + "range": [ + 73, + 76 + ], + "name": "set" } } - ], - "range": [ - 36, - 78 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 9, - "column": 1 - } - } - }, - "range": [ - 32, - 78 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 9, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 28, - 79 - ], - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 79 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -385,15 +381,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -403,15 +399,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -421,15 +417,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -439,15 +435,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -457,15 +453,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -475,15 +471,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 22, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -493,15 +489,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 28, - 31 - ], "loc": { "start": { "line": 5, @@ -511,15 +507,15 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 28, + 31 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -529,15 +525,15 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -547,15 +543,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 5, @@ -565,15 +561,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -583,15 +579,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 6, @@ -601,15 +597,15 @@ module.exports = { "line": 6, "column": 8 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -619,15 +615,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 6, @@ -637,15 +633,15 @@ module.exports = { "line": 6, "column": 13 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 56, - 59 - ], "loc": { "start": { "line": 7, @@ -655,15 +651,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 56, + 59 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 59, - 60 - ], "loc": { "start": { "line": 7, @@ -673,15 +669,15 @@ module.exports = { "line": 7, "column": 8 } - } + }, + "range": [ + 59, + 60 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 61, - 64 - ], "loc": { "start": { "line": 7, @@ -691,15 +687,15 @@ module.exports = { "line": 7, "column": 12 } - } + }, + "range": [ + 61, + 64 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 64, - 65 - ], "loc": { "start": { "line": 7, @@ -709,15 +705,15 @@ module.exports = { "line": 7, "column": 13 } - } + }, + "range": [ + 64, + 65 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 70, - 73 - ], "loc": { "start": { "line": 8, @@ -727,15 +723,15 @@ module.exports = { "line": 8, "column": 7 } - } + }, + "range": [ + 70, + 73 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 73, - 76 - ], "loc": { "start": { "line": 8, @@ -745,15 +741,15 @@ module.exports = { "line": 8, "column": 10 } - } + }, + "range": [ + 73, + 76 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 77, - 78 - ], "loc": { "start": { "line": 9, @@ -763,15 +759,15 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 77, + 78 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 78, - 79 - ], "loc": { "start": { "line": 9, @@ -781,7 +777,11 @@ module.exports = { "line": 9, "column": 2 } - } + }, + "range": [ + 78, + 79 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/experimentalObjectRestSpread/two-spread.result.js b/tests/fixtures/ecma-features/experimentalObjectRestSpread/two-spread.result.js index b832aa28..15a02348 100644 --- a/tests/fixtures/ecma-features/experimentalObjectRestSpread/two-spread.result.js +++ b/tests/fixtures/ecma-features/experimentalObjectRestSpread/two-spread.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "range": [ + 0, + 77 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 0, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,33 +59,33 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, - "init": null, - "range": [ - 4, - 7 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 1, + "line": 2, "column": 4 }, "end": { - "line": 1, + "line": 2, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 13, + 16 + ], "id": { "type": "Identifier", - "name": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -58,33 +95,33 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ], + "name": "get" }, - "init": null, - "range": [ - 13, - 16 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 2, + "line": 3, "column": 4 }, "end": { - "line": 2, + "line": 3, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 22, + 25 + ], "id": { "type": "Identifier", - "name": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -94,53 +131,53 @@ module.exports = { "line": 3, "column": 7 } - } - }, - "init": null, - "range": [ - 22, - 25 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 7 - } - } + "range": [ + 22, + 25 + ], + "name": "set" + }, + "init": null } ], - "kind": "var", - "range": [ - 0, - 26 - ], + "kind": "var" + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 5, "column": 0 }, "end": { - "line": 3, - "column": 8 + "line": 9, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 28, + 77 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 32, + 76 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -150,20 +187,51 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 36, + 76 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 42, + 50 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -173,15 +241,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ], + "name": "foo" }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -191,36 +259,33 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ], + "name": "foo" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 42, - 50 - ], + "kind": "init" + }, + { + "type": "ExperimentalSpreadProperty", "loc": { "start": { - "line": 6, + "line": 7, "column": 4 }, "end": { - "line": 6, - "column": 12 + "line": 7, + "column": 10 } - } - }, - { - "type": "ExperimentalSpreadProperty", + }, + "range": [ + 56, + 62 + ], "argument": { "type": "Identifier", - "name": "get", - "range": [ - 59, - 62 - ], "loc": { "start": { "line": 7, @@ -230,32 +295,32 @@ module.exports = { "line": 7, "column": 10 } - } - }, - "range": [ - 56, - 62 - ], + }, + "range": [ + 59, + 62 + ], + "name": "get" + } + }, + { + "type": "ExperimentalSpreadProperty", "loc": { "start": { - "line": 7, + "line": 8, "column": 4 }, "end": { - "line": 7, + "line": 8, "column": 10 } - } - }, - { - "type": "ExperimentalSpreadProperty", + }, + "range": [ + 68, + 74 + ], "argument": { "type": "Identifier", - "name": "set", - "range": [ - 71, - 74 - ], "loc": { "start": { "line": 8, @@ -265,95 +330,26 @@ module.exports = { "line": 8, "column": 10 } - } - }, - "range": [ - 68, - 74 - ], - "loc": { - "start": { - "line": 8, - "column": 4 }, - "end": { - "line": 8, - "column": 10 - } + "range": [ + 71, + 74 + ], + "name": "set" } } - ], - "range": [ - 36, - 76 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 9, - "column": 1 - } - } - }, - "range": [ - 32, - 76 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 9, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 28, - 77 - ], - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 77 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -363,15 +359,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -381,15 +377,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -399,15 +395,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -417,15 +413,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -435,15 +431,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -453,15 +449,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 22, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -471,15 +467,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 28, - 31 - ], "loc": { "start": { "line": 5, @@ -489,15 +485,15 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 28, + 31 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -507,15 +503,15 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -525,15 +521,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 5, @@ -543,15 +539,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -561,15 +557,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 6, @@ -579,15 +575,15 @@ module.exports = { "line": 6, "column": 8 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 47, - 50 - ], "loc": { "start": { "line": 6, @@ -597,15 +593,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 47, + 50 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 6, @@ -615,15 +611,15 @@ module.exports = { "line": 6, "column": 13 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 56, - 59 - ], "loc": { "start": { "line": 7, @@ -633,15 +629,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 56, + 59 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 59, - 62 - ], "loc": { "start": { "line": 7, @@ -651,15 +647,15 @@ module.exports = { "line": 7, "column": 10 } - } + }, + "range": [ + 59, + 62 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 7, @@ -669,15 +665,15 @@ module.exports = { "line": 7, "column": 11 } - } + }, + "range": [ + 62, + 63 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 68, - 71 - ], "loc": { "start": { "line": 8, @@ -687,15 +683,15 @@ module.exports = { "line": 8, "column": 7 } - } + }, + "range": [ + 68, + 71 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 71, - 74 - ], "loc": { "start": { "line": 8, @@ -705,15 +701,15 @@ module.exports = { "line": 8, "column": 10 } - } + }, + "range": [ + 71, + 74 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 75, - 76 - ], "loc": { "start": { "line": 9, @@ -723,15 +719,15 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 75, + 76 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 76, - 77 - ], "loc": { "start": { "line": 9, @@ -741,7 +737,11 @@ module.exports = { "line": 9, "column": 2 } - } + }, + "range": [ + 76, + 77 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/forOf/for-of-with-function-initializer.result.js b/tests/fixtures/ecma-features/forOf/for-of-with-function-initializer.result.js index 9ec8e746..344e65bf 100644 --- a/tests/fixtures/ecma-features/forOf/for-of-with-function-initializer.result.js +++ b/tests/fixtures/ecma-features/forOf/for-of-with-function-initializer.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "range": [ + 0, + 64 + ], "body": [ { "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "range": [ + 0, + 64 + ], "left": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 5, + 43 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 9, + 43 + ], "id": { "type": "Identifier", - "name": "i", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -24,28 +75,84 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "i" }, "init": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 13, + 43 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 24, + 43 + ], "body": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 26, + 41 + ], "argument": { "type": "BinaryExpression", - "operator": "in", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 33, + 41 + ], "left": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 33, - 35 - ], "loc": { "start": { "line": 1, @@ -55,15 +162,17 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 33, + 35 + ], + "value": 10, + "raw": "10" }, + "operator": "in", "right": { "type": "ArrayExpression", - "elements": [], - "range": [ - 39, - 41 - ], "loc": { "start": { "line": 1, @@ -73,132 +182,74 @@ module.exports = { "line": 1, "column": 41 } - } - }, - "range": [ - 33, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 33 }, - "end": { - "line": 1, - "column": 41 - } - } - }, - "range": [ - 26, - 42 - ], - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 42 + "range": [ + 39, + 41 + ], + "elements": [] } } } - ], - "range": [ - 24, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 43 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 13, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 43 - } - } - }, - "range": [ - 9, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 43 + ] } } } ], - "kind": "var", - "range": [ - 5, - 43 - ], + "kind": "var" + }, + "right": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 5 + "column": 47 }, "end": { "line": 1, - "column": 43 + "column": 51 } - } - }, - "right": { - "type": "Identifier", - "name": "list", + }, "range": [ 47, 51 ], + "name": "list" + }, + "body": { + "type": "ExpressionStatement", "loc": { "start": { "line": 1, - "column": 47 + "column": 53 }, "end": { "line": 1, - "column": 51 + "column": 64 } - } - }, - "body": { - "type": "ExpressionStatement", + }, + "range": [ + 53, + 64 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "range": [ + 53, + 63 + ], "callee": { "type": "Identifier", - "name": "process", - "range": [ - 53, - 60 - ], "loc": { "start": { "line": 1, @@ -208,16 +259,16 @@ module.exports = { "line": 1, "column": 60 } - } + }, + "range": [ + 53, + 60 + ], + "name": "process" }, "arguments": [ { "type": "Identifier", - "name": "x", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 1, @@ -226,79 +277,24 @@ module.exports = { "end": { "line": 1, "column": 62 - } - } - } - ], - "range": [ - 53, - 63 - ], - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 63 + } + }, + "range": [ + 61, + 62 + ], + "name": "x" } - } - }, - "range": [ - 53, - 64 - ], - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 64 - } - } - }, - "range": [ - 0, - 64 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 64 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 64 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 64 - } - }, "tokens": [ { "type": "Keyword", "value": "for", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -344,15 +340,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Identifier", "value": "i", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -362,15 +358,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -380,15 +376,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 13, - 21 - ], "loc": { "start": { "line": 1, @@ -398,15 +394,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 13, + 21 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -416,15 +412,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -434,15 +430,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -452,15 +448,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 26, - 32 - ], "loc": { "start": { "line": 1, @@ -470,15 +466,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 26, + 32 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 33, - 35 - ], "loc": { "start": { "line": 1, @@ -488,15 +484,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 33, + 35 + ] }, { "type": "Keyword", "value": "in", - "range": [ - 36, - 38 - ], "loc": { "start": { "line": 1, @@ -506,15 +502,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 36, + 38 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 1, @@ -524,15 +520,15 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 39, + 40 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -542,15 +538,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 1, @@ -560,15 +556,15 @@ module.exports = { "line": 1, "column": 43 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Identifier", "value": "of", - "range": [ - 44, - 46 - ], "loc": { "start": { "line": 1, @@ -578,15 +574,15 @@ module.exports = { "line": 1, "column": 46 } - } + }, + "range": [ + 44, + 46 + ] }, { "type": "Identifier", "value": "list", - "range": [ - 47, - 51 - ], "loc": { "start": { "line": 1, @@ -596,15 +592,15 @@ module.exports = { "line": 1, "column": 51 } - } + }, + "range": [ + 47, + 51 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 1, @@ -614,15 +610,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Identifier", "value": "process", - "range": [ - 53, - 60 - ], "loc": { "start": { "line": 1, @@ -632,15 +628,15 @@ module.exports = { "line": 1, "column": 60 } - } + }, + "range": [ + 53, + 60 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 60, - 61 - ], "loc": { "start": { "line": 1, @@ -650,15 +646,15 @@ module.exports = { "line": 1, "column": 61 } - } + }, + "range": [ + 60, + 61 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 1, @@ -668,15 +664,15 @@ module.exports = { "line": 1, "column": 62 } - } + }, + "range": [ + 61, + 62 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 62, - 63 - ], "loc": { "start": { "line": 1, @@ -686,15 +682,15 @@ module.exports = { "line": 1, "column": 63 } - } + }, + "range": [ + 62, + 63 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 63, - 64 - ], "loc": { "start": { "line": 1, @@ -704,7 +700,11 @@ module.exports = { "line": 1, "column": 64 } - } + }, + "range": [ + 63, + 64 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/forOf/for-of-with-var-and-braces.result.js b/tests/fixtures/ecma-features/forOf/for-of-with-var-and-braces.result.js index c855e40a..ce4f9283 100644 --- a/tests/fixtures/ecma-features/forOf/for-of-with-var-and-braces.result.js +++ b/tests/fixtures/ecma-features/forOf/for-of-with-var-and-braces.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 41 + ], "body": [ { "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 41 + ], "left": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 5, + 10 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -24,73 +75,87 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "init": null, - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 10 - } - } + "range": [ + 9, + 10 + ], + "name": "x" + }, + "init": null } ], - "kind": "var", - "range": [ - 5, - 10 - ], + "kind": "var" + }, + "right": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 5 + "column": 14 }, "end": { "line": 1, - "column": 10 + "column": 17 } - } - }, - "right": { - "type": "Identifier", - "name": "foo", + }, "range": [ 14, 17 ], + "name": "foo" + }, + "body": { + "type": "BlockStatement", "loc": { "start": { "line": 1, - "column": 14 + "column": 19 }, "end": { - "line": 1, - "column": 17 + "line": 3, + "column": 1 } - } - }, - "body": { - "type": "BlockStatement", + }, + "range": [ + 19, + 41 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 25, + 39 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 25, + 38 + ], "callee": { "type": "Identifier", - "name": "doSomething", - "range": [ - 25, - 36 - ], "loc": { "start": { "line": 2, @@ -100,94 +165,25 @@ module.exports = { "line": 2, "column": 15 } - } - }, - "arguments": [], - "range": [ - 25, - 38 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 17 - } - } - }, - "range": [ - 25, - 39 - ], - "loc": { - "start": { - "line": 2, - "column": 4 + "range": [ + 25, + 36 + ], + "name": "doSomething" }, - "end": { - "line": 2, - "column": 18 - } + "arguments": [] } } - ], - "range": [ - 19, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, "tokens": [ { "type": "Keyword", "value": "for", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "of", - "range": [ - 11, - 13 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 11, + 13 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 14, - 17 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 14, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Identifier", "value": "doSomething", - "range": [ - 25, - 36 - ], "loc": { "start": { "line": 2, @@ -341,15 +337,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 25, + 36 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 2, @@ -359,15 +355,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 2, @@ -377,15 +373,15 @@ module.exports = { "line": 2, "column": 17 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 2, @@ -395,15 +391,15 @@ module.exports = { "line": 2, "column": 18 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -413,7 +409,11 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 40, + 41 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/forOf/for-of-with-var-and-no-braces.result.js b/tests/fixtures/ecma-features/forOf/for-of-with-var-and-no-braces.result.js index 460c8c51..8d08ddec 100644 --- a/tests/fixtures/ecma-features/forOf/for-of-with-var-and-no-braces.result.js +++ b/tests/fixtures/ecma-features/forOf/for-of-with-var-and-no-braces.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 0, + 37 + ], "body": [ { "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 0, + 37 + ], "left": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 5, + 10 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -24,70 +75,70 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "init": null, - "range": [ - 9, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 10 - } - } + "range": [ + 9, + 10 + ], + "name": "x" + }, + "init": null } ], - "kind": "var", - "range": [ - 5, - 10 - ], + "kind": "var" + }, + "right": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 5 + "column": 14 }, "end": { "line": 1, - "column": 10 + "column": 17 } - } - }, - "right": { - "type": "Identifier", - "name": "foo", + }, "range": [ 14, 17 ], + "name": "foo" + }, + "body": { + "type": "ExpressionStatement", "loc": { "start": { - "line": 1, - "column": 14 + "line": 2, + "column": 4 }, "end": { - "line": 1, - "column": 17 + "line": 2, + "column": 18 } - } - }, - "body": { - "type": "ExpressionStatement", + }, + "range": [ + 23, + 37 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 23, + 36 + ], "callee": { "type": "Identifier", - "name": "doSomething", - "range": [ - 23, - 34 - ], "loc": { "start": { "line": 2, @@ -97,78 +148,23 @@ module.exports = { "line": 2, "column": 15 } - } - }, - "arguments": [], - "range": [ - 23, - 36 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 17 - } - } - }, - "range": [ - 23, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 4 + "range": [ + 23, + 34 + ], + "name": "doSomething" }, - "end": { - "line": 2, - "column": 18 - } - } - }, - "range": [ - 0, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 18 + "arguments": [] } } } ], "sourceType": "script", - "range": [ - 0, - 37 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 18 - } - }, "tokens": [ { "type": "Keyword", "value": "for", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "of", - "range": [ - 11, - 13 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 11, + 13 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 14, - 17 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 14, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "doSomething", - "range": [ - 23, - 34 - ], "loc": { "start": { "line": 2, @@ -304,15 +300,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 23, + 34 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 2, @@ -322,15 +318,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 2, @@ -340,15 +336,15 @@ module.exports = { "line": 2, "column": 17 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 2, @@ -358,7 +354,11 @@ module.exports = { "line": 2, "column": 18 } - } + }, + "range": [ + 36, + 37 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/forOf/invalid-for-of-with-const-and-no-braces.result.js b/tests/fixtures/ecma-features/forOf/invalid-for-of-with-const-and-no-braces.result.js index a1bd3d3c..d7092537 100644 --- a/tests/fixtures/ecma-features/forOf/invalid-for-of-with-const-and-no-braces.result.js +++ b/tests/fixtures/ecma-features/forOf/invalid-for-of-with-const-and-no-braces.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 5, "lineNumber": 1, "column": 6, - "description": "Unexpected token const" + "message": "Unexpected token const" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/forOf/invalid-for-of-with-let-and-no-braces.result.js b/tests/fixtures/ecma-features/forOf/invalid-for-of-with-let-and-no-braces.result.js index ab022d0f..37b72404 100644 --- a/tests/fixtures/ecma-features/forOf/invalid-for-of-with-let-and-no-braces.result.js +++ b/tests/fixtures/ecma-features/forOf/invalid-for-of-with-let-and-no-braces.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 5, "lineNumber": 1, "column": 6, - "description": "Unexpected token let" + "message": "Unexpected token let" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/anonymous-generator.result.js b/tests/fixtures/ecma-features/generators/anonymous-generator.result.js index 084cfb19..d08884d2 100644 --- a/tests/fixtures/ecma-features/generators/anonymous-generator.result.js +++ b/tests/fixtures/ecma-features/generators/anonymous-generator.result.js @@ -1,26 +1,108 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 1, + 25 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 14, + 25 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 16, + 23 + ], "expression": { "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 16, + 23 + ], + "delegate": false, "argument": { "type": "Identifier", - "name": "v", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -30,111 +112,25 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "delegate": false, - "range": [ - 16, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 16, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 24 + "range": [ + 22, + 23 + ], + "name": "v" } } } - ], - "range": [ - 14, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 25 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 25 - } - } - }, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -252,15 +248,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { "type": "Identifier", "value": "v", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -270,15 +266,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -288,15 +284,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -306,15 +302,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -324,7 +320,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/double-yield.result.js b/tests/fixtures/ecma-features/generators/double-yield.result.js index c8c8dd7c..343c7241 100644 --- a/tests/fixtures/ecma-features/generators/double-yield.result.js +++ b/tests/fixtures/ecma-features/generators/double-yield.result.js @@ -1,29 +1,125 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 0, + 34 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 0, + 34 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 1, + 32 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 14, + 32 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 16, + 30 + ], "expression": { "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 16, + 30 + ], + "delegate": false, "argument": { "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 22, + 30 + ], + "delegate": false, "argument": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 28, - 30 - ], "loc": { "start": { "line": 1, @@ -33,127 +129,27 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "delegate": false, - "range": [ - 22, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 22 }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "delegate": false, - "range": [ - 16, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 30 + "range": [ + 28, + 30 + ], + "value": 10, + "raw": "10" } } - }, - "range": [ - 16, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 31 - } } } - ], - "range": [ - 14, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 32 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 32 - } - } - }, - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 22, - 27 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 22, + 27 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 28, - 30 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 28, + 30 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -343,15 +339,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -361,7 +357,11 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/empty-generator-declaration.result.js b/tests/fixtures/ecma-features/generators/empty-generator-declaration.result.js index 51e5769b..7e864c55 100644 --- a/tests/fixtures/ecma-features/generators/empty-generator-declaration.result.js +++ b/tests/fixtures/ecma-features/generators/empty-generator-declaration.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "id": { "type": "Identifier", - "name": "t", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,18 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ], + "name": "t" }, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -38,31 +63,16 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "generator": true, - "expression": false, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 14, + 16 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -72,32 +82,18 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] } ], "sourceType": "script", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "t", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -233,7 +229,11 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/generator-declaration.result.js b/tests/fixtures/ecma-features/generators/generator-declaration.result.js index 178429e2..b3a22b03 100644 --- a/tests/fixtures/ecma-features/generators/generator-declaration.result.js +++ b/tests/fixtures/ecma-features/generators/generator-declaration.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "id": { "type": "Identifier", - "name": "test", - "range": [ - 10, - 14 - ], "loc": { "start": { "line": 1, @@ -19,23 +42,68 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 10, + 14 + ], + "name": "test" }, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 18, + 30 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 20, + 28 + ], "expression": { "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 20, + 28 + ], + "delegate": true, "argument": { "type": "Identifier", - "name": "v", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -45,78 +113,20 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "delegate": true, - "range": [ - 20, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 28 - } - } - }, - "range": [ - 20, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 29 + "range": [ + 27, + 28 + ], + "name": "v" } } } - ], - "range": [ - 18, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } + ] } }, { "type": "EmptyStatement", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -126,32 +136,18 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ], "sourceType": "script", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "test", - "range": [ - 10, - 14 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 10, + 14 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 20, - 25 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 20, + 25 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Identifier", "value": "v", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -341,7 +337,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/yield-delegation.result.js b/tests/fixtures/ecma-features/generators/yield-delegation.result.js index ea8b3b72..d34a0d8f 100644 --- a/tests/fixtures/ecma-features/generators/yield-delegation.result.js +++ b/tests/fixtures/ecma-features/generators/yield-delegation.result.js @@ -1,26 +1,108 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 1, + 26 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 14, + 26 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 16, + 24 + ], "expression": { "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 16, + 24 + ], + "delegate": true, "argument": { "type": "Identifier", - "name": "v", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -30,111 +112,25 @@ module.exports = { "line": 1, "column": 24 } - } - }, - "delegate": true, - "range": [ - 16, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "range": [ - 16, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 25 + "range": [ + 23, + 24 + ], + "name": "v" } } } - ], - "range": [ - 14, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 26 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 26 - } - } - }, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -252,15 +248,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -270,15 +266,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "v", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -288,15 +284,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -306,15 +302,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -324,15 +320,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -342,7 +338,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/yield-without-value-in-call.result.js b/tests/fixtures/ecma-features/generators/yield-without-value-in-call.result.js index 7e3575b2..b721c0ef 100644 --- a/tests/fixtures/ecma-features/generators/yield-without-value-in-call.result.js +++ b/tests/fixtures/ecma-features/generators/yield-without-value-in-call.result.js @@ -1,26 +1,107 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 1, + 28 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 14, + 28 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 16, + 26 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 16, + 25 + ], "callee": { "type": "Identifier", - "name": "fn", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -30,17 +111,16 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ], + "name": "fn" }, "arguments": [ { "type": "YieldExpression", - "argument": null, - "delegate": false, - "range": [ - 19, - 24 - ], "loc": { "start": { "line": 1, @@ -50,111 +130,27 @@ module.exports = { "line": 1, "column": 24 } - } - } - ], - "range": [ - 16, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 25 + }, + "range": [ + 19, + 24 + ], + "delegate": false, + "argument": null } - } - }, - "range": [ - 16, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 26 - } + ] } } - ], - "range": [ - 14, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 28 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 28 - } - } - }, - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "fn", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -290,15 +286,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 19, - 24 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 19, + 24 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -344,15 +340,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -362,15 +358,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -380,15 +376,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -398,7 +394,11 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/yield-without-value-no-semi.result.js b/tests/fixtures/ecma-features/generators/yield-without-value-no-semi.result.js index 78343eff..fd582146 100644 --- a/tests/fixtures/ecma-features/generators/yield-without-value-no-semi.result.js +++ b/tests/fixtures/ecma-features/generators/yield-without-value-no-semi.result.js @@ -1,25 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 1, + 23 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 14, + 23 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 16, + 21 + ], "expression": { "type": "YieldExpression", - "argument": null, - "delegate": false, - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -29,95 +95,25 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 16, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 16, + 21 + ], + "delegate": false, + "argument": null } } - ], - "range": [ - 14, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -289,7 +285,11 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/generators/yield-without-value.result.js b/tests/fixtures/ecma-features/generators/yield-without-value.result.js index 9ec20f01..6a9948d4 100644 --- a/tests/fixtures/ecma-features/generators/yield-without-value.result.js +++ b/tests/fixtures/ecma-features/generators/yield-without-value.result.js @@ -1,25 +1,91 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "expression": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 1, + 24 + ], "id": null, + "generator": true, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 14, + 24 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 16, + 22 + ], "expression": { "type": "YieldExpression", - "argument": null, - "delegate": false, - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -29,95 +95,25 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 16, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 16, + 21 + ], + "delegate": false, + "argument": null } } - ], - "range": [ - 14, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "generator": true, - "expression": false, - "range": [ - 1, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 1, - 9 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 1, + 9 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { - "type": "Identifier", + "type": "Keyword", "value": "yield", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -307,7 +303,11 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/globalReturn/return-identifier.result.js b/tests/fixtures/ecma-features/globalReturn/return-identifier.result.js index e58eb35a..f6a7a061 100644 --- a/tests/fixtures/ecma-features/globalReturn/return-identifier.result.js +++ b/tests/fixtures/ecma-features/globalReturn/return-identifier.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "argument": { "type": "Identifier", - "name": "fooz", - "range": [ - 7, - 11 - ], "loc": { "start": { "line": 1, @@ -19,47 +42,20 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 7, + 11 + ], + "name": "fooz" } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Keyword", "value": "return", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -69,15 +65,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Identifier", "value": "fooz", - "range": [ - 7, - 11 - ], "loc": { "start": { "line": 1, @@ -87,15 +83,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 7, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -105,7 +101,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/globalReturn/return-no-arg.result.js b/tests/fixtures/ecma-features/globalReturn/return-no-arg.result.js index 93f8483f..9eeaf9d8 100644 --- a/tests/fixtures/ecma-features/globalReturn/return-no-arg.result.js +++ b/tests/fixtures/ecma-features/globalReturn/return-no-arg.result.js @@ -1,13 +1,22 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], "body": [ { "type": "ReturnStatement", - "argument": null, - "range": [ - 0, - 7 - ], "loc": { "start": { "line": 1, @@ -17,32 +26,19 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 0, + 7 + ], + "argument": null } ], "sourceType": "script", - "range": [ - 0, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 7 - } - }, "tokens": [ { "type": "Keyword", "value": "return", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -52,15 +48,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -70,7 +66,11 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/globalReturn/return-true.result.js b/tests/fixtures/ecma-features/globalReturn/return-true.result.js index 85d8d501..612b7527 100644 --- a/tests/fixtures/ecma-features/globalReturn/return-true.result.js +++ b/tests/fixtures/ecma-features/globalReturn/return-true.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "argument": { "type": "Literal", - "value": true, - "raw": "true", - "range": [ - 7, - 11 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 7, + 11 + ], + "value": true, + "raw": "true" } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Keyword", "value": "return", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Boolean", "value": "true", - "range": [ - 7, - 11 - ], "loc": { "start": { "line": 1, @@ -88,15 +84,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 7, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -106,7 +102,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/embedded-comment.result.js b/tests/fixtures/ecma-features/jsx/embedded-comment.result.js index c99ff1a6..d27c4547 100644 --- a/tests/fixtures/ecma-features/jsx/embedded-comment.result.js +++ b/tests/fixtures/ecma-features/jsx/embedded-comment.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 0, + 33 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 0, + 33 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 3 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 28 }, "end": { "line": 1, - "column": 3 + "column": 32 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 28, + 32 + ], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -60,32 +111,33 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "range": [ - 28, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 28 }, - "end": { - "line": 1, - "column": 32 - } + "range": [ + 30, + 31 + ], + "name": "a" } }, "children": [ { "type": "JSXExpressionContainer", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 3, + 28 + ], "expression": { "type": "JSXEmptyExpression", - "range": [ - 4, - 27 - ], "loc": { "start": { "line": 1, @@ -95,78 +147,22 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 3, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 28 - } + "range": [ + 4, + 27 + ] } } - ], - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - } - }, - "range": [ - 0, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 33 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 33 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -176,15 +172,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -194,15 +190,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -212,15 +208,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -230,15 +226,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -248,15 +244,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -266,15 +262,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -284,15 +280,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -302,15 +298,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -320,15 +316,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -338,7 +334,11 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/embedded-conditional.result.js b/tests/fixtures/ecma-features/jsx/embedded-conditional.result.js index 9f3049c0..e0109e5c 100644 --- a/tests/fixtures/ecma-features/jsx/embedded-conditional.result.js +++ b/tests/fixtures/ecma-features/jsx/embedded-conditional.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 2 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 } }, - "selfClosing": true, + "range": [ + 0, + 27 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 3, + 24 + ], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -45,19 +91,47 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "b" }, "value": { "type": "JSXExpressionContainer", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 5, + 24 + ], "expression": { "type": "ConditionalExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 6, + 23 + ], "test": { "type": "Identifier", - "name": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -67,19 +141,48 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ], + "name": "x" }, "consequent": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "c", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -89,53 +192,53 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 10, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 10 }, - "end": { - "line": 1, - "column": 15 - } - } + "range": [ + 11, + 12 + ], + "name": "c" + }, + "selfClosing": true }, "closingElement": null, - "children": [], - "range": [ - 10, - 15 - ], + "children": [] + }, + "alternate": { + "type": "JSXElement", "loc": { "start": { "line": 1, - "column": 10 + "column": 18 }, "end": { "line": 1, - "column": 15 + "column": 23 } - } - }, - "alternate": { - "type": "JSXElement", + }, + "range": [ + 18, + 23 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 18, + 23 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "d", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -145,159 +248,52 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 18, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 18, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 6, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 5, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 24 - } - } - }, - "range": [ - 3, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 3 - }, - "end": { - "line": 1, - "column": 24 + "range": [ + 19, + 20 + ], + "name": "d" + }, + "selfClosing": true + }, + "closingElement": null, + "children": [] + } } } } ], - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } }, - "end": { - "line": 1, - "column": 27 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 2 + ], + "name": "a" }, - "end": { - "line": 1, - "column": 27 - } - } - }, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 28 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -343,15 +339,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -361,15 +357,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -379,15 +375,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -397,15 +393,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "?", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -415,15 +411,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -433,15 +429,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "JSXIdentifier", "value": "c", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -451,15 +447,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -469,15 +465,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -487,15 +483,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -505,15 +501,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -523,15 +519,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "JSXIdentifier", "value": "d", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -541,15 +537,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -559,15 +555,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -577,15 +573,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -595,15 +591,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -613,15 +609,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -631,15 +627,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -649,7 +645,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/embedded-invalid-js-identifier.result.js b/tests/fixtures/ecma-features/jsx/embedded-invalid-js-identifier.result.js index 5312e600..ceb36c2e 100644 --- a/tests/fixtures/ecma-features/jsx/embedded-invalid-js-identifier.result.js +++ b/tests/fixtures/ecma-features/jsx/embedded-invalid-js-identifier.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ], + "name": "div" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 5 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 35 }, "end": { "line": 1, - "column": 5 + "column": 41 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 35, + 41 + ], "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 37, - 40 - ], "loc": { "start": { "line": 1, @@ -60,35 +111,50 @@ module.exports = { "line": 1, "column": 40 } - } - }, - "range": [ - 35, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 35 }, - "end": { - "line": 1, - "column": 41 - } + "range": [ + 37, + 40 + ], + "name": "div" } }, "children": [ { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "br", - "range": [ - 6, - 8 - ], "loc": { "start": { "line": 1, @@ -98,50 +164,20 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } - } + "range": [ + 6, + 8 + ], + "name": "br" + }, + "selfClosing": true }, "closingElement": null, - "children": [], - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 11 - } - } + "children": [] }, { "type": "Literal", - "value": "7x invalid-js-identifier", - "raw": "7x invalid-js-identifier", - "range": [ - 11, - 35 - ], "loc": { "start": { "line": 1, @@ -151,63 +187,23 @@ module.exports = { "line": 1, "column": 35 } - } - } - ], - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 41 + }, + "range": [ + 11, + 35 + ], + "value": "7x invalid-js-identifier", + "raw": "7x invalid-js-identifier" } - } - }, - "range": [ - 0, - 42 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 42 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 42 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 42 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -217,15 +213,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -235,15 +231,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -253,15 +249,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -271,15 +267,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "JSXIdentifier", "value": "br", - "range": [ - 6, - 8 - ], "loc": { "start": { "line": 1, @@ -289,15 +285,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 6, + 8 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -307,15 +303,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -325,15 +321,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "JSXText", "value": "7x invalid-js-identifier", - "range": [ - 11, - 35 - ], "loc": { "start": { "line": 1, @@ -343,15 +339,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 11, + 35 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -361,15 +357,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -379,15 +375,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 37, - 40 - ], "loc": { "start": { "line": 1, @@ -397,15 +393,15 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 37, + 40 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -415,15 +411,15 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 41, - 42 - ], "loc": { "start": { "line": 1, @@ -433,7 +429,11 @@ module.exports = { "line": 1, "column": 42 } - } + }, + "range": [ + 41, + 42 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/embedded-tags.result.js b/tests/fixtures/ecma-features/jsx/embedded-tags.result.js index 59727868..696360b6 100644 --- a/tests/fixtures/ecma-features/jsx/embedded-tags.result.js +++ b/tests/fixtures/ecma-features/jsx/embedded-tags.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "range": [ + 0, + 58 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "range": [ + 0, + 58 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "range": [ + 0, + 57 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "LeftRight", - "range": [ - 1, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 10 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 } }, - "selfClosing": true, + "range": [ + 0, + 57 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 11, + 21 + ], "name": { "type": "JSXIdentifier", - "name": "left", - "range": [ - 11, - 15 - ], "loc": { "start": { "line": 1, @@ -45,19 +91,48 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 11, + 15 + ], + "name": "left" }, "value": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 16, + 21 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 16, + 21 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -67,66 +142,37 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 16, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 21 - } - } + "range": [ + 17, + 18 + ], + "name": "a" + }, + "selfClosing": true }, "closingElement": null, - "children": [], - "range": [ - 16, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 21 - } - } - }, - "range": [ - 11, - 21 - ], + "children": [] + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 11 + "column": 22 }, "end": { "line": 1, - "column": 21 + "column": 54 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 22, + 54 + ], "name": { "type": "JSXIdentifier", - "name": "right", - "range": [ - 22, - 27 - ], "loc": { "start": { "line": 1, @@ -136,19 +182,48 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 22, + 27 + ], + "name": "right" }, "value": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "range": [ + 28, + 54 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 28, + 31 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -158,34 +233,33 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ], + "name": "b" }, - "selfClosing": false, - "attributes": [], - "range": [ - 28, - 31 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 28 + "column": 50 }, "end": { "line": 1, - "column": 31 + "column": 54 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 50, + 54 + ], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -195,32 +269,17 @@ module.exports = { "line": 1, "column": 53 } - } - }, - "range": [ - 50, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 50 }, - "end": { - "line": 1, - "column": 54 - } + "range": [ + 52, + 53 + ], + "name": "b" } }, "children": [ { "type": "Literal", - "value": "monkeys /> gorillas", - "raw": "monkeys /> gorillas", - "range": [ - 31, - 50 - ], "loc": { "start": { "line": 1, @@ -230,111 +289,48 @@ module.exports = { "line": 1, "column": 50 } - } - } - ], - "range": [ - 28, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 28 - }, - "end": { - "line": 1, - "column": 54 + }, + "range": [ + 31, + 50 + ], + "value": "monkeys /> gorillas", + "raw": "monkeys /> gorillas" } - } - }, - "range": [ - 22, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 22 - }, - "end": { - "line": 1, - "column": 54 - } + ] } } ], - "range": [ - 0, - 57 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } }, - "end": { - "line": 1, - "column": 57 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 57 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 10 + ], + "name": "LeftRight" }, - "end": { - "line": 1, - "column": 57 - } - } - }, - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 58 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 58 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -344,15 +340,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "LeftRight", - "range": [ - 1, - 10 - ], "loc": { "start": { "line": 1, @@ -362,15 +358,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 1, + 10 + ] }, { "type": "JSXIdentifier", "value": "left", - "range": [ - 11, - 15 - ], "loc": { "start": { "line": 1, @@ -380,15 +376,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 11, + 15 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -398,15 +394,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -416,15 +412,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -434,15 +430,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -452,15 +448,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -470,15 +466,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "JSXIdentifier", "value": "right", - "range": [ - 22, - 27 - ], "loc": { "start": { "line": 1, @@ -488,15 +484,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 22, + 27 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -506,15 +502,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -524,15 +520,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -542,15 +538,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -560,15 +556,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "JSXText", "value": "monkeys /> gorillas", - "range": [ - 31, - 50 - ], "loc": { "start": { "line": 1, @@ -578,15 +574,15 @@ module.exports = { "line": 1, "column": 50 } - } + }, + "range": [ + 31, + 50 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 1, @@ -596,15 +592,15 @@ module.exports = { "line": 1, "column": 51 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 1, @@ -614,15 +610,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -632,15 +628,15 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 53, - 54 - ], "loc": { "start": { "line": 1, @@ -650,15 +646,15 @@ module.exports = { "line": 1, "column": 54 } - } + }, + "range": [ + 53, + 54 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 1, @@ -668,15 +664,15 @@ module.exports = { "line": 1, "column": 56 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 56, - 57 - ], "loc": { "start": { "line": 1, @@ -686,15 +682,15 @@ module.exports = { "line": 1, "column": 57 } - } + }, + "range": [ + 56, + 57 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 57, - 58 - ], "loc": { "start": { "line": 1, @@ -704,7 +700,11 @@ module.exports = { "line": 1, "column": 58 } - } + }, + "range": [ + 57, + 58 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/empty-placeholder.result.js b/tests/fixtures/ecma-features/jsx/empty-placeholder.result.js index 209857e8..163a3422 100644 --- a/tests/fixtures/ecma-features/jsx/empty-placeholder.result.js +++ b/tests/fixtures/ecma-features/jsx/empty-placeholder.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 3 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 5 }, "end": { "line": 1, - "column": 3 + "column": 9 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 5, + 9 + ], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -60,32 +111,33 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "range": [ - 5, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 9 - } + "range": [ + 7, + 8 + ], + "name": "a" } }, "children": [ { "type": "JSXExpressionContainer", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 3, + 5 + ], "expression": { "type": "JSXEmptyExpression", - "range": [ - 4, - 4 - ], "loc": { "start": { "line": 1, @@ -95,78 +147,22 @@ module.exports = { "line": 1, "column": 4 } - } - }, - "range": [ - 3, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 5 - } + "range": [ + 4, + 4 + ] } } - ], - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -176,15 +172,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -194,15 +190,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -212,15 +208,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -230,15 +226,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -248,15 +244,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -266,15 +262,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -284,15 +280,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -302,15 +298,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -320,15 +316,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -338,7 +334,11 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/escape-patterns.result.js b/tests/fixtures/ecma-features/jsx/escape-patterns.result.js index 05ba87d7..a21e5ebd 100644 --- a/tests/fixtures/ecma-features/jsx/escape-patterns.result.js +++ b/tests/fixtures/ecma-features/jsx/escape-patterns.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 84 + } + }, + "range": [ + 0, + 84 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 84 + } + }, + "range": [ + 0, + 84 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 83 + } + }, + "range": [ + 0, + 83 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 2 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 83 } }, - "selfClosing": true, + "range": [ + 0, + 83 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 3, + 10 + ], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -45,18 +91,31 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "b" }, "value": { "type": "JSXExpressionContainer", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 5, + 10 + ], "expression": { "type": "Literal", - "value": " ", - "raw": "\" \"", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -66,47 +125,34 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "range": [ - 5, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 10 - } + "range": [ + 6, + 9 + ], + "value": " ", + "raw": "\" \"" } - }, - "range": [ - 3, - 10 - ], + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 3 + "column": 11 }, "end": { "line": 1, - "column": 10 + "column": 16 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 11, + 16 + ], "name": { "type": "JSXIdentifier", - "name": "c", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -116,16 +162,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "c" }, "value": { "type": "Literal", - "value": " ", - "raw": "\" \"", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -135,32 +180,33 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 11, - 16 - ], + }, + "range": [ + 13, + 16 + ], + "value": " ", + "raw": "\" \"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 11 + "column": 17 }, "end": { "line": 1, - "column": 16 + "column": 26 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 17, + 26 + ], "name": { "type": "JSXIdentifier", - "name": "d", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -170,16 +216,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ], + "name": "d" }, "value": { "type": "Literal", - "value": "&", - "raw": "\"&\"", - "range": [ - 19, - 26 - ], "loc": { "start": { "line": 1, @@ -189,32 +234,33 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "range": [ - 17, - 26 - ], + }, + "range": [ + 19, + 26 + ], + "value": "&", + "raw": "\"&\"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 17 + "column": 27 }, "end": { "line": 1, - "column": 26 + "column": 43 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 27, + 43 + ], "name": { "type": "JSXIdentifier", - "name": "e", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -224,16 +270,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ], + "name": "e" }, "value": { "type": "Literal", - "value": "id=1&group=2", - "raw": "\"id=1&group=2\"", - "range": [ - 29, - 43 - ], "loc": { "start": { "line": 1, @@ -243,32 +288,33 @@ module.exports = { "line": 1, "column": 43 } - } - }, - "range": [ - 27, - 43 - ], + }, + "range": [ + 29, + 43 + ], + "value": "id=1&group=2", + "raw": "\"id=1&group=2\"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 27 + "column": 44 }, "end": { "line": 1, - "column": 43 + "column": 59 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 44, + 59 + ], "name": { "type": "JSXIdentifier", - "name": "f", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 1, @@ -278,16 +324,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 44, + 45 + ], + "name": "f" }, "value": { "type": "Literal", - "value": "�", - "raw": "\"�\"", - "range": [ - 46, - 59 - ], "loc": { "start": { "line": 1, @@ -297,32 +342,33 @@ module.exports = { "line": 1, "column": 59 } - } - }, - "range": [ - 44, - 59 - ], + }, + "range": [ + 46, + 59 + ], + "value": "�", + "raw": "\"�\"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 44 + "column": 60 }, "end": { "line": 1, - "column": 59 + "column": 71 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 60, + 71 + ], "name": { "type": "JSXIdentifier", - "name": "g", - "range": [ - 60, - 61 - ], "loc": { "start": { "line": 1, @@ -332,16 +378,15 @@ module.exports = { "line": 1, "column": 61 } - } + }, + "range": [ + 60, + 61 + ], + "name": "g" }, "value": { "type": "Literal", - "value": "{*;", - "raw": "\"{*;\"", - "range": [ - 62, - 71 - ], "loc": { "start": { "line": 1, @@ -351,32 +396,33 @@ module.exports = { "line": 1, "column": 71 } - } - }, - "range": [ - 60, - 71 - ], + }, + "range": [ + 62, + 71 + ], + "value": "{*;", + "raw": "\"{*;\"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 60 + "column": 72 }, "end": { "line": 1, - "column": 71 + "column": 80 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 72, + 80 + ], "name": { "type": "JSXIdentifier", - "name": "h", - "range": [ - 72, - 73 - ], "loc": { "start": { "line": 1, @@ -386,16 +432,15 @@ module.exports = { "line": 1, "column": 73 } - } + }, + "range": [ + 72, + 73 + ], + "name": "h" }, "value": { "type": "Literal", - "value": "&#x;", - "raw": "\"&#x;\"", - "range": [ - 74, - 80 - ], "loc": { "start": { "line": 1, @@ -405,95 +450,46 @@ module.exports = { "line": 1, "column": 80 } - } - }, - "range": [ - 72, - 80 - ], - "loc": { - "start": { - "line": 1, - "column": 72 }, - "end": { - "line": 1, - "column": 80 - } + "range": [ + 74, + 80 + ], + "value": "&#x;", + "raw": "\"&#x;\"" } } ], - "range": [ - 0, - 83 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } }, - "end": { - "line": 1, - "column": 83 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 83 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 2 + ], + "name": "a" }, - "end": { - "line": 1, - "column": 83 - } - } - }, - "range": [ - 0, - 84 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 84 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 84 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 84 + "closingElement": null, + "children": [] + } } - }, + ], + "sourceType": "script", "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -503,15 +499,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -521,15 +517,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -539,15 +535,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -557,15 +553,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -575,15 +571,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "String", "value": "\" \"", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -593,15 +589,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 6, + 9 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -611,15 +607,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "JSXIdentifier", "value": "c", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -629,15 +625,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -647,15 +643,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "JSXText", "value": "\" \"", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -665,15 +661,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "JSXIdentifier", "value": "d", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -683,15 +679,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -701,15 +697,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "JSXText", "value": "\"&\"", - "range": [ - 19, - 26 - ], "loc": { "start": { "line": 1, @@ -719,15 +715,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 19, + 26 + ] }, { "type": "JSXIdentifier", "value": "e", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -737,15 +733,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -755,15 +751,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "JSXText", "value": "\"id=1&group=2\"", - "range": [ - 29, - 43 - ], "loc": { "start": { "line": 1, @@ -773,15 +769,15 @@ module.exports = { "line": 1, "column": 43 } - } + }, + "range": [ + 29, + 43 + ] }, { "type": "JSXIdentifier", "value": "f", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 1, @@ -791,15 +787,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 1, @@ -809,15 +805,15 @@ module.exports = { "line": 1, "column": 46 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "JSXText", "value": "\"�\"", - "range": [ - 46, - 59 - ], "loc": { "start": { "line": 1, @@ -827,15 +823,15 @@ module.exports = { "line": 1, "column": 59 } - } + }, + "range": [ + 46, + 59 + ] }, { "type": "JSXIdentifier", "value": "g", - "range": [ - 60, - 61 - ], "loc": { "start": { "line": 1, @@ -845,15 +841,15 @@ module.exports = { "line": 1, "column": 61 } - } + }, + "range": [ + 60, + 61 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 61, - 62 - ], "loc": { "start": { "line": 1, @@ -863,15 +859,15 @@ module.exports = { "line": 1, "column": 62 } - } + }, + "range": [ + 61, + 62 + ] }, { "type": "JSXText", "value": "\"{*;\"", - "range": [ - 62, - 71 - ], "loc": { "start": { "line": 1, @@ -881,15 +877,15 @@ module.exports = { "line": 1, "column": 71 } - } + }, + "range": [ + 62, + 71 + ] }, { "type": "JSXIdentifier", "value": "h", - "range": [ - 72, - 73 - ], "loc": { "start": { "line": 1, @@ -899,15 +895,15 @@ module.exports = { "line": 1, "column": 73 } - } + }, + "range": [ + 72, + 73 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 73, - 74 - ], "loc": { "start": { "line": 1, @@ -917,15 +913,15 @@ module.exports = { "line": 1, "column": 74 } - } + }, + "range": [ + 73, + 74 + ] }, { "type": "JSXText", "value": "\"&#x;\"", - "range": [ - 74, - 80 - ], "loc": { "start": { "line": 1, @@ -935,15 +931,15 @@ module.exports = { "line": 1, "column": 80 } - } + }, + "range": [ + 74, + 80 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 81, - 82 - ], "loc": { "start": { "line": 1, @@ -953,15 +949,15 @@ module.exports = { "line": 1, "column": 82 } - } + }, + "range": [ + 81, + 82 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 82, - 83 - ], "loc": { "start": { "line": 1, @@ -971,15 +967,15 @@ module.exports = { "line": 1, "column": 83 } - } + }, + "range": [ + 82, + 83 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 83, - 84 - ], "loc": { "start": { "line": 1, @@ -989,7 +985,11 @@ module.exports = { "line": 1, "column": 84 } - } + }, + "range": [ + 83, + 84 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-attribute-missing-equals.result.js b/tests/fixtures/ecma-features/jsx/invalid-attribute-missing-equals.result.js index 3aab0c3b..f9489fcc 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-attribute-missing-equals.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-attribute-missing-equals.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 14, "lineNumber": 1, "column": 15, - "description": "Unexpected string" + "message": "Unexpected token \"app\"" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-attribute.result.js b/tests/fixtures/ecma-features/jsx/invalid-attribute.result.js index 9fa90329..3cea2521 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-attribute.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-attribute.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 5, "lineNumber": 1, "column": 6, - "description": "JSX value should be either an expression or a quoted JSX text" + "message": "JSX value should be either an expression or a quoted JSX text" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-broken-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-broken-tag.result.js index aa67b515..ace1f56b 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-broken-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-broken-tag.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 12, + "index": 7, "lineNumber": 1, - "column": 13, - "description": "Unexpected token ILLEGAL" + "column": 8, + "message": "Unterminated string constant" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-computed-end-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-computed-end-tag-name.result.js index 1cdeca51..674267de 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-computed-end-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-computed-end-tag-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 2, "lineNumber": 1, "column": 3, - "description": "Unexpected token [" + "message": "Unexpected token [" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-computed-string-end-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-computed-string-end-tag-name.result.js index 1cdeca51..674267de 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-computed-string-end-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-computed-string-end-tag-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 2, "lineNumber": 1, "column": 3, - "description": "Unexpected token [" + "message": "Unexpected token [" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-embedded-expression.result.js b/tests/fixtures/ecma-features/jsx/invalid-embedded-expression.result.js index d6de4409..efba70a0 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-embedded-expression.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-embedded-expression.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 9, "lineNumber": 1, "column": 10, - "description": "Unexpected token ;" + "message": "Unexpected token ;" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-leading-dot-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-leading-dot-tag-name.result.js index 23684cf6..1550ffb8 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-leading-dot-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-leading-dot-tag-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 1, "lineNumber": 1, "column": 2, - "description": "Unexpected token ." + "message": "Unexpected token ." }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-matching-placeholder-in-closing-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-matching-placeholder-in-closing-tag.result.js index 2d1ad8ac..24994140 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-matching-placeholder-in-closing-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-matching-placeholder-in-closing-tag.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 27, "lineNumber": 1, "column": 28, - "description": "Unexpected token {" + "message": "Unexpected token {" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tag.result.js index 0bb31198..19d15dbd 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tag.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 7, + "index": 3, "lineNumber": 1, - "column": 8, - "description": "Expected corresponding JSX closing tag for a" + "column": 4, + "message": "Expected corresponding JSX closing tag for " }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tags.result.js b/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tags.result.js index 1f2fa3d7..b8926778 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tags.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-mismatched-closing-tags.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 9, + "index": 8, "lineNumber": 1, - "column": 10, - "description": "Unexpected end of input" + "column": 9, + "message": "Unterminated JSX contents" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-mismatched-dot-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-mismatched-dot-tag-name.result.js index bd56fd9a..6d1e78bf 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-mismatched-dot-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-mismatched-dot-tag-name.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 11, + "index": 7, "lineNumber": 1, - "column": 12, - "description": "Expected corresponding JSX closing tag for a.b.c" + "column": 8, + "message": "Expected corresponding JSX closing tag for " }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-mismatched-namespace-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-mismatched-namespace-tag.result.js index c83000de..96c689a0 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-mismatched-namespace-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-mismatched-namespace-tag.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 9, + "index": 5, "lineNumber": 1, - "column": 10, - "description": "Expected corresponding JSX closing tag for a:b" + "column": 6, + "message": "Expected corresponding JSX closing tag for " }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag-attribute-placeholder.result.js b/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag-attribute-placeholder.result.js index 6e46a62a..c6715eab 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag-attribute-placeholder.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag-attribute-placeholder.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 7, + "index": 5, "lineNumber": 1, - "column": 8, - "description": "JSX attributes must only be assigned a non-empty expression" + "column": 6, + "message": "JSX attributes must only be assigned a non-empty expression" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag.result.js index c8d6b0e3..801a1aa2 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-missing-closing-tag.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 4, + "index": 3, "lineNumber": 1, - "column": 5, - "description": "Unexpected end of input" + "column": 4, + "message": "Unterminated JSX contents" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-name.result.js index da4c7bb8..d6f5dfb0 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 1, "lineNumber": 1, "column": 2, - "description": "Unexpected token :" + "message": "Unexpected token :" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-value.result.js b/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-value.result.js index 8f49499f..2b0fd9e7 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-value.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-missing-namespace-value.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 4, + "index": 5, "lineNumber": 1, - "column": 5, - "description": "Unexpected token /" + "column": 6, + "message": "Unterminated regular expression" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-missing-spread-operator.result.js b/tests/fixtures/ecma-features/jsx/invalid-missing-spread-operator.result.js index 437a2c61..b2f52e84 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-missing-spread-operator.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-missing-spread-operator.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 6, "lineNumber": 1, "column": 7, - "description": "Unexpected identifier" + "message": "Unexpected token props" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-namespace-name-with-docts.result.js b/tests/fixtures/ecma-features/jsx/invalid-namespace-name-with-docts.result.js index 6013cda4..03f355f8 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-namespace-name-with-docts.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-namespace-name-with-docts.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 4, "lineNumber": 1, "column": 5, - "description": "Unexpected token :" + "message": "Unexpected token :" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-namespace-value-with-dots.result.js b/tests/fixtures/ecma-features/jsx/invalid-namespace-value-with-dots.result.js index 63f4cb77..465439f3 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-namespace-value-with-dots.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-namespace-value-with-dots.result.js @@ -1,6 +1,557 @@ module.exports = { - "index": 4, - "lineNumber": 1, - "column": 5, - "description": "Unexpected token ." + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "expression": { + "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], + "openingElement": { + "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], + "attributes": [], + "name": { + "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 1, + 6 + ], + "object": { + "type": "JSXNamespacedName", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 1, + 4 + ], + "namespace": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ], + "name": "a" + }, + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ], + "name": "b" + } + }, + "property": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "c" + } + }, + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 7, + 15 + ], + "name": { + "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], + "object": { + "type": "JSXNamespacedName", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ], + "namespace": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "a" + }, + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ], + "name": "b" + } + }, + "property": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ], + "name": "c" + } + } + }, + "children": [] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "JSXIdentifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "JSXIdentifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "JSXIdentifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": ">", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "<", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Punctuator", + "value": "/", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "JSXIdentifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "JSXIdentifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "JSXIdentifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Punctuator", + "value": ">", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + } + ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-no-common-parent-with-comment.result.js b/tests/fixtures/ecma-features/jsx/invalid-no-common-parent-with-comment.result.js index 625b1e91..bf2e5e6e 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-no-common-parent-with-comment.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-no-common-parent-with-comment.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 49, "lineNumber": 1, "column": 50, - "description": "Adjacent JSX elements must be wrapped in an enclosing tag" + "message": "Adjacent JSX elements must be wrapped in an enclosing tag" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-no-common-parent.result.js b/tests/fixtures/ecma-features/jsx/invalid-no-common-parent.result.js index 44bc3ebb..c453466e 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-no-common-parent.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-no-common-parent.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 22, "lineNumber": 1, "column": 23, - "description": "Adjacent JSX elements must be wrapped in an enclosing tag" + "message": "Adjacent JSX elements must be wrapped in an enclosing tag" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-no-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-no-tag-name.result.js index 4b63e089..5f0ea4d3 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-no-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-no-tag-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 1, "lineNumber": 1, "column": 2, - "description": "Unexpected token /" + "message": "Unexpected token /" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-placeholder-in-closing-tag.result.js b/tests/fixtures/ecma-features/jsx/invalid-placeholder-in-closing-tag.result.js index cf509b4f..b4d7ad28 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-placeholder-in-closing-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-placeholder-in-closing-tag.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 16, "lineNumber": 1, "column": 17, - "description": "Unexpected token {" + "message": "Unexpected token {" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-trailing-dot-tag-name.result.js b/tests/fixtures/ecma-features/jsx/invalid-trailing-dot-tag-name.result.js index c5d79c06..9412307c 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-trailing-dot-tag-name.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-trailing-dot-tag-name.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 3, "lineNumber": 1, "column": 4, - "description": "Unexpected token >" + "message": "Unexpected token >" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/invalid-unexpected-comma.result.js b/tests/fixtures/ecma-features/jsx/invalid-unexpected-comma.result.js index 84fc704b..d24f10ca 100644 --- a/tests/fixtures/ecma-features/jsx/invalid-unexpected-comma.result.js +++ b/tests/fixtures/ecma-features/jsx/invalid-unexpected-comma.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 19, "lineNumber": 1, "column": 20, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/japanese-characters.result.js b/tests/fixtures/ecma-features/jsx/japanese-characters.result.js index 9bb6139b..d3f1e2ca 100644 --- a/tests/fixtures/ecma-features/jsx/japanese-characters.result.js +++ b/tests/fixtures/ecma-features/jsx/japanese-characters.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "日本語", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ], + "name": "日本語" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 5 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 5 }, "end": { "line": 1, - "column": 5 + "column": 11 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 5, + 11 + ], "name": { "type": "JSXIdentifier", - "name": "日本語", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -60,78 +111,23 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "children": [], - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 + "range": [ + 7, + 10 + ], + "name": "日本語" } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 12 - } + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "日本語", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -213,15 +209,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "JSXIdentifier", "value": "日本語", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -231,15 +227,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -249,15 +245,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -267,7 +263,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/less-than-operator.result.js b/tests/fixtures/ecma-features/jsx/less-than-operator.result.js index 83de3fe8..6be31bd8 100644 --- a/tests/fixtures/ecma-features/jsx/less-than-operator.result.js +++ b/tests/fixtures/ecma-features/jsx/less-than-operator.result.js @@ -1,22 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "expression": { "type": "BinaryExpression", - "operator": "<", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "left": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 1, + 8 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 1, + 8 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 2, - 5 - ], "loc": { "start": { "line": 1, @@ -26,49 +91,21 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 1, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 8 - } - } + "range": [ + 2, + 5 + ], + "name": "div" + }, + "selfClosing": true }, "closingElement": null, - "children": [], - "range": [ - 1, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - } - } + "children": [] }, + "operator": "<", "right": { "type": "Identifier", - "name": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -78,62 +115,21 @@ module.exports = { "line": 1, "column": 13 } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 + "range": [ + 12, + 13 + ], + "name": "x" } } } ], "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 2, - 5 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 2, + 5 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/multiple-blank-spaces.result.js b/tests/fixtures/ecma-features/jsx/multiple-blank-spaces.result.js index 638d52b8..fa491363 100644 --- a/tests/fixtures/ecma-features/jsx/multiple-blank-spaces.result.js +++ b/tests/fixtures/ecma-features/jsx/multiple-blank-spaces.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 3 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 7 }, "end": { "line": 1, - "column": 3 + "column": 11 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 7, + 11 + ], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -60,32 +111,17 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 7, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 9, + 10 + ], + "name": "a" } }, "children": [ { "type": "Literal", - "value": " ", - "raw": " ", - "range": [ - 3, - 7 - ], "loc": { "start": { "line": 1, @@ -95,63 +131,23 @@ module.exports = { "line": 1, "column": 7 } - } - } - ], - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 + }, + "range": [ + 3, + 7 + ], + "value": " ", + "raw": " " } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "JSXText", "value": " ", - "range": [ - 3, - 7 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 3, + 7 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -305,7 +301,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/namespaced-attribute-and-value-inserted.result.js b/tests/fixtures/ecma-features/jsx/namespaced-attribute-and-value-inserted.result.js index 917042a0..d2a62e5c 100644 --- a/tests/fixtures/ecma-features/jsx/namespaced-attribute-and-value-inserted.result.js +++ b/tests/fixtures/ecma-features/jsx/namespaced-attribute-and-value-inserted.result.js @@ -1,43 +1,103 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 0, + 40 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 2 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 } }, - "selfClosing": false, + "range": [ + 0, + 15 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 3, + 14 + ], "name": { "type": "JSXNamespacedName", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 3, + 8 + ], "namespace": { "type": "JSXIdentifier", - "name": "n", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -47,15 +107,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "n" }, "name": { "type": "JSXIdentifier", - "name": "foo", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -65,31 +125,16 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "range": [ - 3, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 8 - } + "range": [ + 5, + 8 + ], + "name": "foo" } }, "value": { "type": "Literal", - "value": "bar", - "raw": "\"bar\"", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -99,63 +144,38 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 3, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 9, + 14 + ], + "value": "bar", + "raw": "\"bar\"" } } ], - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - } - }, - "closingElement": { - "type": "JSXClosingElement", "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, - "column": 38 + "column": 1 }, "end": { "line": 1, - "column": 39 + "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, - "range": [ - 36, - 40 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, @@ -165,17 +185,33 @@ module.exports = { "line": 1, "column": 40 } + }, + "range": [ + 36, + 40 + ], + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ], + "name": "a" } }, "children": [ { "type": "Literal", - "value": " ", - "raw": " ", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -185,17 +221,32 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ], + "value": " ", + "raw": " " }, { "type": "JSXExpressionContainer", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 16, + 23 + ], "expression": { "type": "Identifier", - "name": "value", - "range": [ - 17, - 22 - ], "loc": { "start": { "line": 1, @@ -205,53 +256,68 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "range": [ - 16, - 23 - ], + }, + "range": [ + 17, + 22 + ], + "name": "value" + } + }, + { + "type": "Literal", "loc": { "start": { "line": 1, - "column": 16 + "column": 23 }, "end": { "line": 1, - "column": 23 + "column": 24 } - } - }, - { - "type": "Literal", - "value": " ", - "raw": " ", + }, "range": [ 23, 24 ], + "value": " ", + "raw": " " + }, + { + "type": "JSXElement", "loc": { "start": { "line": 1, - "column": 23 + "column": 24 }, "end": { "line": 1, - "column": 24 + "column": 36 } - } - }, - { - "type": "JSXElement", + }, + "range": [ + 24, + 36 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 24, + 27 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -261,34 +327,33 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ], + "name": "b" }, - "selfClosing": false, - "attributes": [], - "range": [ - 24, - 27 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 24 + "column": 32 }, "end": { "line": 1, - "column": 27 + "column": 36 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 32, + 36 + ], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -298,35 +363,50 @@ module.exports = { "line": 1, "column": 35 } - } - }, - "range": [ - 32, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 32 }, - "end": { - "line": 1, - "column": 36 - } + "range": [ + 34, + 35 + ], + "name": "b" } }, "children": [ { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 27, + 32 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 27, + 32 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "c", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -336,113 +416,29 @@ module.exports = { "line": 1, "column": 29 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 27, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 27 }, - "end": { - "line": 1, - "column": 32 - } - } + "range": [ + 28, + 29 + ], + "name": "c" + }, + "selfClosing": true }, "closingElement": null, - "children": [], - "range": [ - 27, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 32 - } - } - } - ], - "range": [ - 24, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 36 + "children": [] } - } - } - ], - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 + ] } - } - }, - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 41 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 41 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -452,15 +448,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -470,15 +466,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "JSXIdentifier", "value": "n", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -488,15 +484,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -506,15 +502,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "JSXIdentifier", "value": "foo", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -524,15 +520,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -542,15 +538,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "JSXText", "value": "\"bar\"", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -560,15 +556,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 9, + 14 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -578,15 +574,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "JSXText", "value": " ", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -596,15 +592,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -614,15 +610,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "value", - "range": [ - 17, - 22 - ], "loc": { "start": { "line": 1, @@ -632,15 +628,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 17, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -650,15 +646,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "JSXText", "value": " ", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -668,15 +664,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -686,15 +682,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -704,15 +700,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -722,15 +718,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -740,15 +736,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "JSXIdentifier", "value": "c", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -758,15 +754,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -776,15 +772,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -794,15 +790,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 1, @@ -812,15 +808,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -830,15 +826,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -848,15 +844,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -866,15 +862,15 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -884,15 +880,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 1, @@ -902,15 +898,15 @@ module.exports = { "line": 1, "column": 38 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 1, @@ -920,15 +916,15 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 1, @@ -938,15 +934,15 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 39, + 40 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -956,7 +952,11 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/namespaced-name-and-attribute.result.js b/tests/fixtures/ecma-features/jsx/namespaced-name-and-attribute.result.js index ba746bc5..49e53910 100644 --- a/tests/fixtures/ecma-features/jsx/namespaced-name-and-attribute.result.js +++ b/tests/fixtures/ecma-features/jsx/namespaced-name-and-attribute.result.js @@ -1,78 +1,103 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "n", - "range": [ - 1, - 2 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 2 - } - } + "loc": { + "start": { + "line": 1, + "column": 0 }, - "name": { - "type": "JSXIdentifier", - "name": "a", - "range": [ - 3, - 4 - ], + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], + "attributes": [ + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 3 + "column": 5 }, "end": { "line": 1, - "column": 4 + "column": 8 } - } - }, - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 4 - } - } - }, - "selfClosing": true, - "attributes": [ - { - "type": "JSXAttribute", + "range": [ + 5, + 8 + ], "name": { "type": "JSXNamespacedName", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], "namespace": { "type": "JSXIdentifier", - "name": "n", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -82,15 +107,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ], + "name": "n" }, "name": { "type": "JSXIdentifier", - "name": "v", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -100,111 +125,82 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "range": [ - 5, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 8 - } + "range": [ + 7, + 8 + ], + "name": "v" + } + }, + "value": null + } + ], + "name": { + "type": "JSXNamespacedName", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 1, + 4 + ], + "namespace": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 } }, - "value": null, "range": [ - 5, - 8 + 1, + 2 ], + "name": "n" + }, + "name": { + "type": "JSXIdentifier", "loc": { "start": { "line": 1, - "column": 5 + "column": 3 }, "end": { "line": 1, - "column": 8 + "column": 4 } - } - } - ], - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 + }, + "range": [ + 3, + 4 + ], + "name": "a" } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 12 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "n", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "JSXIdentifier", "value": "n", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -304,15 +300,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "JSXIdentifier", "value": "v", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -322,15 +318,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -340,15 +336,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -358,15 +354,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -376,7 +372,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/newslines-and-entities.result.js b/tests/fixtures/ecma-features/jsx/newslines-and-entities.result.js index defe6a93..5664539c 100644 --- a/tests/fixtures/ecma-features/jsx/newslines-and-entities.result.js +++ b/tests/fixtures/ecma-features/jsx/newslines-and-entities.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 9, "lineNumber": 1, "column": 10, - "description": "Unexpected token ILLEGAL" + "message": "Expecting Unicode escape sequence \\uXXXX" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/self-closing-tag-with-newline.result.js b/tests/fixtures/ecma-features/jsx/self-closing-tag-with-newline.result.js index 6501f8ae..29417020 100644 --- a/tests/fixtures/ecma-features/jsx/self-closing-tag-with-newline.result.js +++ b/tests/fixtures/ecma-features/jsx/self-closing-tag-with-newline.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 3, "lineNumber": 1, "column": 4, - "description": "Unexpected token ILLEGAL" + "message": "Expecting Unicode escape sequence \\uXXXX" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/self-closing-tag.result.js b/tests/fixtures/ecma-features/jsx/self-closing-tag.result.js index 95e5f161..a44cbb89 100644 --- a/tests/fixtures/ecma-features/jsx/self-closing-tag.result.js +++ b/tests/fixtures/ecma-features/jsx/self-closing-tag.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -23,81 +75,25 @@ module.exports = { "line": 1, "column": 2 } - } - }, - "selfClosing": true, - "attributes": [], - "range": [ - 0, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 2 + ], + "name": "a" }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 6 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -179,7 +175,11 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/spread-operator-attribute-and-regular-attribute.result.js b/tests/fixtures/ecma-features/jsx/spread-operator-attribute-and-regular-attribute.result.js index 3ffb8f0e..52d352cf 100644 --- a/tests/fixtures/ecma-features/jsx/spread-operator-attribute-and-regular-attribute.result.js +++ b/tests/fixtures/ecma-features/jsx/spread-operator-attribute-and-regular-attribute.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 4 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 } }, - "selfClosing": true, + "range": [ + 0, + 35 + ], "attributes": [ { "type": "JSXSpreadAttribute", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 5, + 15 + ], "argument": { "type": "Identifier", - "name": "props", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -45,32 +91,32 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 5, - 15 - ], + }, + "range": [ + 9, + 14 + ], + "name": "props" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 5 + "column": 16 }, "end": { "line": 1, - "column": 15 + "column": 32 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 16, + 32 + ], "name": { "type": "JSXIdentifier", - "name": "post", - "range": [ - 16, - 20 - ], "loc": { "start": { "line": 1, @@ -80,16 +126,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 16, + 20 + ], + "name": "post" }, "value": { "type": "Literal", - "value": "attribute", - "raw": "\"attribute\"", - "range": [ - 21, - 32 - ], "loc": { "start": { "line": 1, @@ -99,95 +144,46 @@ module.exports = { "line": 1, "column": 32 } - } - }, - "range": [ - 16, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 32 - } + "range": [ + 21, + 32 + ], + "value": "attribute", + "raw": "\"attribute\"" } } ], - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } }, - "end": { - "line": 1, - "column": 35 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 4 + ], + "name": "div" }, - "end": { - "line": 1, - "column": 35 - } - } - }, - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 36 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 36 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 6, + 9 + ] }, { "type": "Identifier", "value": "props", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 9, + 14 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "JSXIdentifier", "value": "post", - "range": [ - 16, - 20 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 16, + 20 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "JSXText", "value": "\"attribute\"", - "range": [ - 21, - 32 - ], "loc": { "start": { "line": 1, @@ -341,15 +337,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 21, + 32 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -359,15 +355,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -377,15 +373,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -395,7 +391,11 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/spread-operator-attributes.result.js b/tests/fixtures/ecma-features/jsx/spread-operator-attributes.result.js index f6cfa353..62b59ca3 100644 --- a/tests/fixtures/ecma-features/jsx/spread-operator-attributes.result.js +++ b/tests/fixtures/ecma-features/jsx/spread-operator-attributes.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 4 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 } }, - "selfClosing": true, + "range": [ + 0, + 18 + ], "attributes": [ { "type": "JSXSpreadAttribute", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 5, + 15 + ], "argument": { "type": "Identifier", - "name": "props", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -45,95 +91,45 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 5, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 9, + 14 + ], + "name": "props" } } ], - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 4 + ], + "name": "div" }, - "end": { - "line": 1, - "column": 18 - } - } - }, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 19 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 6, - 9 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 6, + 9 + ] }, { "type": "Identifier", "value": "props", - "range": [ - 9, - 14 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 9, + 14 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/tag-names-with-dots.result.js b/tests/fixtures/ecma-features/jsx/tag-names-with-dots.result.js index 35aa11d1..f70ee280 100644 --- a/tests/fixtures/ecma-features/jsx/tag-names-with-dots.result.js +++ b/tests/fixtures/ecma-features/jsx/tag-names-with-dots.result.js @@ -1,21 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "attributes": [], "name": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 1, + 4 + ], "object": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -25,15 +91,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, "property": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -43,51 +109,50 @@ module.exports = { "line": 1, "column": 4 } - } - }, - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 4 - } + "range": [ + 3, + 4 + ], + "name": "b" } }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 5 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 5 }, "end": { "line": 1, - "column": 5 + "column": 11 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 5, + 11 + ], "name": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], "object": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -97,15 +162,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ], + "name": "a" }, "property": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -115,93 +180,24 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 7, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 10 - } - } - }, - "range": [ - 5, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 11 + "range": [ + 9, + 10 + ], + "name": "b" } } }, - "children": [], - "range": [ - 0, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -211,15 +207,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -229,15 +225,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -247,15 +243,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -265,15 +261,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -283,15 +279,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -301,15 +297,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -319,15 +315,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -337,15 +333,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -355,15 +351,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -373,15 +369,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -391,15 +387,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -409,7 +405,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/tag-names-with-multi-dots.result.js b/tests/fixtures/ecma-features/jsx/tag-names-with-multi-dots.result.js index 753637e2..ce3d3aed 100644 --- a/tests/fixtures/ecma-features/jsx/tag-names-with-multi-dots.result.js +++ b/tests/fixtures/ecma-features/jsx/tag-names-with-multi-dots.result.js @@ -1,23 +1,103 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], + "attributes": [], "name": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 1, + 6 + ], "object": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 1, + 4 + ], "object": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -27,15 +107,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ], + "name": "a" }, "property": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -45,30 +125,16 @@ module.exports = { "line": 1, "column": 4 } - } - }, - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 4 - } + "range": [ + 3, + 4 + ], + "name": "b" } }, "property": { "type": "JSXIdentifier", - "name": "c", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -78,53 +144,66 @@ module.exports = { "line": 1, "column": 6 } - } - }, - "range": [ - 1, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 5, + 6 + ], + "name": "c" } }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 7 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 7 }, "end": { "line": 1, - "column": 7 + "column": 15 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 7, + 15 + ], "name": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], "object": { "type": "JSXMemberExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ], "object": { "type": "JSXIdentifier", - "name": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -134,15 +213,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "a" }, "property": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -152,30 +231,16 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 11, + 12 + ], + "name": "b" } }, "property": { "type": "JSXIdentifier", - "name": "c", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -185,93 +250,24 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "range": [ - 9, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 14 - } - } - }, - "range": [ - 7, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 15 + "range": [ + 13, + 14 + ], + "name": "c" } } }, - "children": [], - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - } - }, - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -281,15 +277,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -299,15 +295,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -317,15 +313,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -335,15 +331,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -353,15 +349,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "JSXIdentifier", "value": "c", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -371,15 +367,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -389,15 +385,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -407,15 +403,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -461,15 +457,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -479,15 +475,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -497,15 +493,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "JSXIdentifier", "value": "c", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -515,15 +511,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -533,15 +529,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -551,7 +547,11 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/test-content.result.js b/tests/fixtures/ecma-features/jsx/test-content.result.js index 7adae823..5d749506 100644 --- a/tests/fixtures/ecma-features/jsx/test-content.result.js +++ b/tests/fixtures/ecma-features/jsx/test-content.result.js @@ -1,19 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "openingElement": { "type": "JSXOpeningElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "attributes": [], "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -23,34 +75,33 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ], + "name": "div" }, - "selfClosing": false, - "attributes": [], - "range": [ - 0, - 5 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, - "column": 0 + "column": 18 }, "end": { "line": 1, - "column": 5 + "column": 24 } - } - }, - "closingElement": { - "type": "JSXClosingElement", + }, + "range": [ + 18, + 24 + ], "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 1, @@ -60,32 +111,17 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "range": [ - 18, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 24 - } + "range": [ + 20, + 23 + ], + "name": "div" } }, "children": [ { "type": "Literal", - "value": "@test content", - "raw": "@test content", - "range": [ - 5, - 18 - ], "loc": { "start": { "line": 1, @@ -95,63 +131,23 @@ module.exports = { "line": 1, "column": 18 } - } - } - ], - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 + }, + "range": [ + 5, + 18 + ], + "value": "@test content", + "raw": "@test content" } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "JSXText", "value": "@test content", - "range": [ - 5, - 18 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 5, + 18 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 20, + 23 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -305,7 +301,11 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/trailing-spread-operator-attribute.result.js b/tests/fixtures/ecma-features/jsx/trailing-spread-operator-attribute.result.js index 54426490..2179b523 100644 --- a/tests/fixtures/ecma-features/jsx/trailing-spread-operator-attribute.result.js +++ b/tests/fixtures/ecma-features/jsx/trailing-spread-operator-attribute.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "range": [ + 0, + 54 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "range": [ + 0, + 54 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "range": [ + 0, + 53 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "range": [ - 1, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 4 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 } }, - "selfClosing": false, + "range": [ + 0, + 47 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 5, + 18 + ], "name": { "type": "JSXIdentifier", - "name": "pre", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -45,16 +91,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ], + "name": "pre" }, "value": { "type": "Literal", - "value": "leading", - "raw": "\"leading\"", - "range": [ - 9, - 18 - ], "loc": { "start": { "line": 1, @@ -64,32 +109,33 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 5, - 18 - ], + }, + "range": [ + 9, + 18 + ], + "value": "leading", + "raw": "\"leading\"" + } + }, + { + "type": "JSXAttribute", "loc": { "start": { "line": 1, - "column": 5 + "column": 19 }, "end": { "line": 1, - "column": 18 + "column": 35 } - } - }, - { - "type": "JSXAttribute", + }, + "range": [ + 19, + 35 + ], "name": { "type": "JSXIdentifier", - "name": "pre2", - "range": [ - 19, - 23 - ], "loc": { "start": { "line": 1, @@ -99,16 +145,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 19, + 23 + ], + "name": "pre2" }, "value": { "type": "Literal", - "value": "attribute", - "raw": "\"attribute\"", - "range": [ - 24, - 35 - ], "loc": { "start": { "line": 1, @@ -118,32 +163,33 @@ module.exports = { "line": 1, "column": 35 } - } - }, - "range": [ - 19, - 35 - ], + }, + "range": [ + 24, + 35 + ], + "value": "attribute", + "raw": "\"attribute\"" + } + }, + { + "type": "JSXSpreadAttribute", "loc": { "start": { "line": 1, - "column": 19 + "column": 36 }, "end": { "line": 1, - "column": 35 + "column": 46 } - } - }, - { - "type": "JSXSpreadAttribute", + }, + "range": [ + 36, + 46 + ], "argument": { "type": "Identifier", - "name": "props", - "range": [ - 40, - 45 - ], "loc": { "start": { "line": 1, @@ -153,63 +199,37 @@ module.exports = { "line": 1, "column": 45 } - } - }, - "range": [ - 36, - 46 - ], - "loc": { - "start": { - "line": 1, - "column": 36 }, - "end": { - "line": 1, - "column": 46 - } + "range": [ + 40, + 45 + ], + "name": "props" } } ], - "range": [ - 0, - 47 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 47 - } - } - }, - "closingElement": { - "type": "JSXClosingElement", "name": { "type": "JSXIdentifier", - "name": "div", - "range": [ - 49, - 52 - ], "loc": { "start": { "line": 1, - "column": 49 + "column": 1 }, "end": { "line": 1, - "column": 52 + "column": 4 } - } + }, + "range": [ + 1, + 4 + ], + "name": "div" }, - "range": [ - 47, - 53 - ], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", "loc": { "start": { "line": 1, @@ -219,63 +239,39 @@ module.exports = { "line": 1, "column": 53 } - } - }, - "children": [], - "range": [ - 0, - 53 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 53 + "range": [ + 47, + 53 + ], + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "range": [ + 49, + 52 + ], + "name": "div" } - } - }, - "range": [ - 0, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 54 - } + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 54 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 54 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -285,15 +281,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 1, - 4 - ], "loc": { "start": { "line": 1, @@ -303,15 +299,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 1, + 4 + ] }, { "type": "JSXIdentifier", "value": "pre", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -321,15 +317,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -339,15 +335,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "JSXText", "value": "\"leading\"", - "range": [ - 9, - 18 - ], "loc": { "start": { "line": 1, @@ -357,15 +353,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 9, + 18 + ] }, { "type": "JSXIdentifier", "value": "pre2", - "range": [ - 19, - 23 - ], "loc": { "start": { "line": 1, @@ -375,15 +371,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 19, + 23 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -393,15 +389,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "JSXText", "value": "\"attribute\"", - "range": [ - 24, - 35 - ], "loc": { "start": { "line": 1, @@ -411,15 +407,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 24, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 1, @@ -429,15 +425,15 @@ module.exports = { "line": 1, "column": 37 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 37, - 40 - ], "loc": { "start": { "line": 1, @@ -447,15 +443,15 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 37, + 40 + ] }, { "type": "Identifier", "value": "props", - "range": [ - 40, - 45 - ], "loc": { "start": { "line": 1, @@ -465,15 +461,15 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 40, + 45 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 1, @@ -483,15 +479,15 @@ module.exports = { "line": 1, "column": 46 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 46, - 47 - ], "loc": { "start": { "line": 1, @@ -501,15 +497,15 @@ module.exports = { "line": 1, "column": 47 } - } + }, + "range": [ + 46, + 47 + ] }, { "type": "Punctuator", "value": "<", - "range": [ - 47, - 48 - ], "loc": { "start": { "line": 1, @@ -519,15 +515,15 @@ module.exports = { "line": 1, "column": 48 } - } + }, + "range": [ + 47, + 48 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 48, - 49 - ], "loc": { "start": { "line": 1, @@ -537,15 +533,15 @@ module.exports = { "line": 1, "column": 49 } - } + }, + "range": [ + 48, + 49 + ] }, { "type": "JSXIdentifier", "value": "div", - "range": [ - 49, - 52 - ], "loc": { "start": { "line": 1, @@ -555,15 +551,15 @@ module.exports = { "line": 1, "column": 52 } - } + }, + "range": [ + 49, + 52 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 1, @@ -573,15 +569,15 @@ module.exports = { "line": 1, "column": 53 } - } + }, + "range": [ + 52, + 53 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 53, - 54 - ], "loc": { "start": { "line": 1, @@ -591,7 +587,11 @@ module.exports = { "line": 1, "column": 54 } - } + }, + "range": [ + 53, + 54 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/jsx/unknown-escape-pattern.result.js b/tests/fixtures/ecma-features/jsx/unknown-escape-pattern.result.js index 2ec1e0d9..4e6a8873 100644 --- a/tests/fixtures/ecma-features/jsx/unknown-escape-pattern.result.js +++ b/tests/fixtures/ecma-features/jsx/unknown-escape-pattern.result.js @@ -1,41 +1,87 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "expression": { "type": "JSXElement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "openingElement": { "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "a", - "range": [ - 1, - 2 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 2 - } + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 } }, - "selfClosing": true, + "range": [ + 0, + 23 + ], "attributes": [ { "type": "JSXAttribute", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 3, + 20 + ], "name": { "type": "JSXIdentifier", - "name": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -45,16 +91,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "b" }, "value": { "type": "Literal", - "value": "¬anentity;", - "raw": "\"¬anentity;\"", - "range": [ - 5, - 20 - ], "loc": { "start": { "line": 1, @@ -64,95 +109,46 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 3, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 5, + 20 + ], + "value": "¬anentity;", + "raw": "\"¬anentity;\"" } } ], - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "name": { + "type": "JSXIdentifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "closingElement": null, - "children": [], - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "range": [ + 1, + 2 + ], + "name": "a" }, - "end": { - "line": 1, - "column": 23 - } - } - }, - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 + "selfClosing": true }, - "end": { - "line": 1, - "column": 24 - } + "closingElement": null, + "children": [] } } ], "sourceType": "script", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Punctuator", "value": "<", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "JSXIdentifier", "value": "a", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "JSXIdentifier", "value": "b", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "JSXText", "value": "\"¬anentity;\"", - "range": [ - 5, - 20 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 5, + 20 + ] }, { "type": "Punctuator", "value": "/", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -252,15 +248,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ">", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -270,15 +266,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -288,7 +284,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/error-delete.result.js b/tests/fixtures/ecma-features/modules/error-delete.result.js index fe86eff3..9eeb5c87 100644 --- a/tests/fixtures/ecma-features/modules/error-delete.result.js +++ b/tests/fixtures/ecma-features/modules/error-delete.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 27, + "index": 19, "lineNumber": 2, - "column": 9, - "description": "Delete of an unqualified identifier in strict mode." + "column": 1, + "message": "Deleting local variable in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/error-function.result.js b/tests/fixtures/ecma-features/modules/error-function.result.js index 97d820a1..1ad46aab 100644 --- a/tests/fixtures/ecma-features/modules/error-function.result.js +++ b/tests/fixtures/ecma-features/modules/error-function.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 14, - "lineNumber": 1, - "column": 15, - "description": "Illegal export declaration" + "index": 16, + "lineNumber": 2, + "column": 2, + "message": "'import' and 'export' may only appear at the top level" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/error-strict.result.js b/tests/fixtures/ecma-features/modules/error-strict.result.js index 4c7dcd8f..5a85a968 100644 --- a/tests/fixtures/ecma-features/modules/error-strict.result.js +++ b/tests/fixtures/ecma-features/modules/error-strict.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 28, "lineNumber": 3, "column": 1, - "description": "Strict mode code may not include a with statement" + "message": "'with' in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-default-array.result.js b/tests/fixtures/ecma-features/modules/export-default-array.result.js index b49a3c0c..6aec5680 100644 --- a/tests/fixtures/ecma-features/modules/export-default-array.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-array.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "declaration": { "type": "ArrayExpression", - "elements": [], - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -19,47 +42,20 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 15, + 17 + ], + "elements": [] } } ], "sourceType": "module", - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -69,15 +65,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -87,15 +83,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -141,7 +137,11 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-default-expression.result.js b/tests/fixtures/ecma-features/modules/export-default-expression.result.js index f874078f..b9e8b977 100644 --- a/tests/fixtures/ecma-features/modules/export-default-expression.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-expression.result.js @@ -1,19 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "declaration": { "type": "BinaryExpression", - "operator": "+", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 16, + 21 + ], "left": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -23,16 +58,17 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ], + "value": 1, + "raw": "1" }, + "operator": "+", "right": { "type": "Literal", - "value": 2, - "raw": "2", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -42,62 +78,22 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 16, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 16 }, - "end": { - "line": 1, - "column": 21 - } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 + "range": [ + 20, + 21 + ], + "value": 2, + "raw": "2" } } } ], "sourceType": "module", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "+", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Numeric", "value": "2", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -233,7 +229,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-default-function.result.js b/tests/fixtures/ecma-features/modules/export-default-function.result.js index 69f4e94e..383afa42 100644 --- a/tests/fixtures/ecma-features/modules/export-default-function.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-function.result.js @@ -1,19 +1,58 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "declaration": { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 15, + 29 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 27, - 29 - ], "loc": { "start": { "line": 1, @@ -23,64 +62,21 @@ module.exports = { "line": 1, "column": 29 } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 15 }, - "end": { - "line": 1, - "column": 29 - } - } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 + "range": [ + 27, + 29 + ], + "body": [] } } } ], "sourceType": "module", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -90,15 +86,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -108,15 +104,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 15, - 23 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 15, + 23 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -198,7 +194,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/modules/export-default-named-function.result.js b/tests/fixtures/ecma-features/modules/export-default-named-function.result.js index 92d85bbb..9fbc71a5 100644 --- a/tests/fixtures/ecma-features/modules/export-default-named-function.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-named-function.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "declaration": { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 15, + 32 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -21,16 +58,18 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 24, + 27 + ], + "name": "foo" }, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 30, - 32 - ], "loc": { "start": { "line": 1, @@ -40,64 +79,21 @@ module.exports = { "line": 1, "column": 32 } - } - }, - "generator": false, - "expression": false, - "range": [ - 15, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 15 }, - "end": { - "line": 1, - "column": 32 - } - } - }, - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 + "range": [ + 30, + 32 + ], + "body": [] } } } ], "sourceType": "module", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 15, - 23 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 15, + 23 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 24, + 27 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -233,7 +229,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/modules/export-default-number.result.js b/tests/fixtures/ecma-features/modules/export-default-number.result.js index 31d3dc66..e90a1fc1 100644 --- a/tests/fixtures/ecma-features/modules/export-default-number.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-number.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "declaration": { "type": "Literal", - "value": 42, - "raw": "42", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 15, + 17 + ], + "value": 42, + "raw": "42" } } ], "sourceType": "module", - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -88,15 +84,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Numeric", "value": "42", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -106,15 +102,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 15, + 17 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -124,7 +120,11 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-default-object.result.js b/tests/fixtures/ecma-features/modules/export-default-object.result.js index 039100ef..fd5403f4 100644 --- a/tests/fixtures/ecma-features/modules/export-default-object.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-object.result.js @@ -1,20 +1,74 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 0, + 26 + ], "declaration": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 15, + 25 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 17, + 23 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, @@ -24,16 +78,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 17, + 20 + ], + "name": "foo" }, "value": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -43,82 +96,25 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 17, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 23 - } - } - } - ], - "range": [ - 15, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 25 + "range": [ + 22, + 23 + ], + "value": 1, + "raw": "1" + }, + "kind": "init" } - } - }, - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } + ] } } ], "sourceType": "module", - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 17, + 20 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -254,7 +250,11 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-default-value.result.js b/tests/fixtures/ecma-features/modules/export-default-value.result.js index 41f41af4..efb2f087 100644 --- a/tests/fixtures/ecma-features/modules/export-default-value.result.js +++ b/tests/fixtures/ecma-features/modules/export-default-value.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExportDefaultDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "declaration": { "type": "Identifier", - "name": "foo", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -19,47 +42,20 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 19 - } + "range": [ + 15, + 18 + ], + "name": "foo" } } ], "sourceType": "module", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -69,15 +65,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 7, - 14 - ], "loc": { "start": { "line": 1, @@ -87,15 +83,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 7, + 14 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -105,15 +101,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -123,7 +119,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-batch.result.js b/tests/fixtures/ecma-features/modules/export-from-batch.result.js index b0a7306f..389efcd3 100644 --- a/tests/fixtures/ecma-features/modules/export-from-batch.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-batch.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "ExportAllDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 14, + 19 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -88,15 +84,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 9, - 13 - ], "loc": { "start": { "line": 1, @@ -106,15 +102,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 9, + 13 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 1, @@ -124,15 +120,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 14, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -142,7 +138,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-default.result.js b/tests/fixtures/ecma-features/modules/export-from-default.result.js index 138d5e5f..3b80ac33 100644 --- a/tests/fixtures/ecma-features/modules/export-from-default.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-default.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 8, + 15 + ], + "local": { "type": "Identifier", - "name": "default", - "range": [ - 8, - 15 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "local": { - "type": "Identifier", - "name": "default", + }, "range": [ 8, 15 ], + "name": "default" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,32 +78,17 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "range": [ - 8, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 8, + 15 + ], + "name": "default" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 22, - 27 - ], "loc": { "start": { "line": 1, @@ -76,47 +98,21 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 28 - } + "range": [ + 22, + 27 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 28 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 8, - 15 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 8, + 15 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 17, + 21 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 22, - 27 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 22, + 27 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -234,7 +230,11 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-named-as-default.result.js b/tests/fixtures/ecma-features/modules/export-from-named-as-default.result.js index 33e4522b..8ee014b0 100644 --- a/tests/fixtures/ecma-features/modules/export-from-named-as-default.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-named-as-default.result.js @@ -1,72 +1,94 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], + "local": { "type": "Identifier", - "name": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 22 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 22 } - } - }, - "range": [ - 8, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 15, + 22 + ], + "name": "default" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 29, - 34 - ], "loc": { "start": { "line": 1, @@ -76,47 +98,21 @@ module.exports = { "line": 1, "column": 34 } - } - }, - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 35 - } + "range": [ + 29, + 34 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 35 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 15, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 24, - 28 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 24, + 28 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 29, - 34 - ], "loc": { "start": { "line": 1, @@ -252,15 +248,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 29, + 34 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -270,7 +266,11 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-named-as-specifier.result.js b/tests/fixtures/ecma-features/modules/export-from-named-as-specifier.result.js index 9e39ad3b..f9ab0f99 100644 --- a/tests/fixtures/ecma-features/modules/export-from-named-as-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-named-as-specifier.result.js @@ -1,72 +1,94 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 8, + 18 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 18 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - "range": [ - 8, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 15, + 18 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 25, - 30 - ], "loc": { "start": { "line": 1, @@ -76,47 +98,21 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 31 - } + "range": [ + 25, + 30 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 20, - 24 - ], "loc": { "start": { "line": 1, @@ -234,15 +230,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 20, + 24 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 25, - 30 - ], "loc": { "start": { "line": 1, @@ -252,15 +248,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 25, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -270,7 +266,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-named-as-specifiers.result.js b/tests/fixtures/ecma-features/modules/export-from-named-as-specifiers.result.js index de929b64..13662925 100644 --- a/tests/fixtures/ecma-features/modules/export-from-named-as-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-named-as-specifiers.result.js @@ -1,72 +1,109 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 0, + 40 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 0, + 40 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], + "local": { "type": "Identifier", - "name": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 22 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 22 } - } - }, - "range": [ - 8, - 22 - ], + }, + "range": [ + 15, + 22 + ], + "name": "default" + } + }, + { + "type": "ExportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 24 }, "end": { "line": 1, - "column": 22 + "column": 27 } - } - }, - { - "type": "ExportSpecifier", - "exported": { + }, + "range": [ + 24, + 27 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -76,15 +113,15 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "local": { - "type": "Identifier", - "name": "bar", + }, "range": [ 24, 27 ], + "name": "bar" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -94,32 +131,17 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 24, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 24 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 24, + 27 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 34, - 39 - ], "loc": { "start": { "line": 1, @@ -129,47 +151,21 @@ module.exports = { "line": 1, "column": 39 } - } - }, - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 40 - } + "range": [ + 34, + 39 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 15, + 22 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 24, + 27 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 29, - 33 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 29, + 33 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 34, - 39 - ], "loc": { "start": { "line": 1, @@ -341,15 +337,15 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 34, + 39 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 1, @@ -359,7 +355,11 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 39, + 40 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-specifier.result.js b/tests/fixtures/ecma-features/modules/export-from-specifier.result.js index 350499d4..1d3a6b83 100644 --- a/tests/fixtures/ecma-features/modules/export-from-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-specifier.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "local": { "type": "Identifier", - "name": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,32 +78,17 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 8, + 11 + ], + "name": "foo" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 18, - 23 - ], "loc": { "start": { "line": 1, @@ -76,47 +98,21 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 24 - } + "range": [ + 18, + 23 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 13, - 17 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 13, + 17 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 18, - 23 - ], "loc": { "start": { "line": 1, @@ -216,15 +212,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 18, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -234,7 +230,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-from-specifiers.result.js b/tests/fixtures/ecma-features/modules/export-from-specifiers.result.js index 93f600e4..9b2dc6fe 100644 --- a/tests/fixtures/ecma-features/modules/export-from-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/export-from-specifiers.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "local": { "type": "Identifier", - "name": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,32 +78,32 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], + }, + "range": [ + 8, + 11 + ], + "name": "foo" + } + }, + { + "type": "ExportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 16 } - } - }, - { - "type": "ExportSpecifier", - "exported": { + }, + "range": [ + 13, + 16 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -76,15 +113,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "local": { - "type": "Identifier", - "name": "bar", + }, "range": [ 13, 16 ], + "name": "bar" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -94,32 +131,17 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -129,47 +151,21 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 29 - } + "range": [ + 23, + 28 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 18, - 22 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 18, + 22 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 23, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -323,7 +319,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-function.result.js b/tests/fixtures/ecma-features/modules/export-function.result.js index 9e501f42..b5943477 100644 --- a/tests/fixtures/ecma-features/modules/export-function.result.js +++ b/tests/fixtures/ecma-features/modules/export-function.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], "declaration": { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 7, + 25 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 16, - 19 - ], "loc": { "start": { "line": 1, @@ -21,16 +58,18 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 16, + 19 + ], + "name": "foo" }, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 23, - 25 - ], "loc": { "start": { "line": 1, @@ -40,66 +79,23 @@ module.exports = { "line": 1, "column": 25 } - } - }, - "generator": false, - "expression": false, - "range": [ - 7, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 25 - } + "range": [ + 23, + 25 + ], + "body": [] } }, "specifiers": [], - "source": null, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 25 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -109,15 +105,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 7, - 15 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 7, + 15 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 16, - 19 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 16, + 19 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -217,7 +213,11 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/modules/export-named-as-default.result.js b/tests/fixtures/ecma-features/modules/export-named-as-default.result.js index 07cfb202..86a57870 100644 --- a/tests/fixtures/ecma-features/modules/export-named-as-default.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-as-default.result.js @@ -1,104 +1,100 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], + "local": { "type": "Identifier", - "name": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 22 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 22 } - } - }, - "range": [ - 8, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 15, + 22 + ], + "name": "default" } } ], - "source": null, - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -108,15 +104,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 15, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -216,7 +212,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-as-specifier.result.js b/tests/fixtures/ecma-features/modules/export-named-as-specifier.result.js index 9c274276..66bf9005 100644 --- a/tests/fixtures/ecma-features/modules/export-named-as-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-as-specifier.result.js @@ -1,104 +1,100 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 8, + 18 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 18 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - "range": [ - 8, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 15, + 18 + ], + "name": "bar" } } ], - "source": null, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -108,15 +104,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -180,15 +176,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -198,15 +194,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -216,7 +212,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-as-specifiers.result.js b/tests/fixtures/ecma-features/modules/export-named-as-specifiers.result.js index 7efbe889..6ac7d47a 100644 --- a/tests/fixtures/ecma-features/modules/export-named-as-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-as-specifiers.result.js @@ -1,72 +1,109 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], + "local": { "type": "Identifier", - "name": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 22 + "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 22 } - } - }, - "range": [ - 8, - 22 - ], + }, + "range": [ + 15, + 22 + ], + "name": "default" + } + }, + { + "type": "ExportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 24 }, "end": { "line": 1, - "column": 22 + "column": 27 } - } - }, - { - "type": "ExportSpecifier", - "exported": { + }, + "range": [ + 24, + 27 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -76,15 +113,15 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "local": { - "type": "Identifier", - "name": "bar", + }, "range": [ 24, 27 ], + "name": "bar" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -94,64 +131,23 @@ module.exports = { "line": 1, "column": 27 } - } - }, - "range": [ - 24, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 24 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 24, + 27 + ], + "name": "bar" } } ], - "source": null, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 15, - 22 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 15, + 22 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 24, - 27 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 24, + 27 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -305,7 +301,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-empty.result.js b/tests/fixtures/ecma-features/modules/export-named-empty.result.js index 146b41c3..04d96aaf 100644 --- a/tests/fixtures/ecma-features/modules/export-named-empty.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-empty.result.js @@ -1,15 +1,22 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "ExportNamedDeclaration", - "declaration": null, - "specifiers": [], - "source": null, - "range": [ - 0, - 10 - ], "loc": { "start": { "line": 1, @@ -19,32 +26,21 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 0, + 10 + ], + "declaration": null, + "specifiers": [], + "source": null } ], "sourceType": "module", - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -54,15 +50,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -72,15 +68,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -90,15 +86,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -108,7 +104,11 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-specifier.result.js b/tests/fixtures/ecma-features/modules/export-named-specifier.result.js index 8548b5f2..05e6245e 100644 --- a/tests/fixtures/ecma-features/modules/export-named-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-specifier.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "local": { "type": "Identifier", - "name": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,64 +78,23 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 8, + 11 + ], + "name": "foo" } } ], - "source": null, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -108,15 +104,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -126,15 +122,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -144,15 +140,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -162,15 +158,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -180,7 +176,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-specifiers-comma.result.js b/tests/fixtures/ecma-features/modules/export-named-specifiers-comma.result.js index a2eb74c0..75467b13 100644 --- a/tests/fixtures/ecma-features/modules/export-named-specifiers-comma.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-specifiers-comma.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "local": { "type": "Identifier", - "name": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,32 +78,32 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], + }, + "range": [ + 8, + 11 + ], + "name": "foo" + } + }, + { + "type": "ExportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 16 } - } - }, - { - "type": "ExportSpecifier", - "exported": { + }, + "range": [ + 13, + 16 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -76,15 +113,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "local": { - "type": "Identifier", - "name": "bar", + }, "range": [ 13, 16 ], + "name": "bar" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -94,64 +131,23 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "bar" } } ], - "source": null, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-named-specifiers.result.js b/tests/fixtures/ecma-features/modules/export-named-specifiers.result.js index 18882d5f..eec1bef7 100644 --- a/tests/fixtures/ecma-features/modules/export-named-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/export-named-specifiers.result.js @@ -1,19 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "exported": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "local": { "type": "Identifier", - "name": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -23,15 +60,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "local": { - "type": "Identifier", - "name": "foo", + }, "range": [ 8, 11 ], + "name": "foo" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -41,32 +78,32 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], + }, + "range": [ + 8, + 11 + ], + "name": "foo" + } + }, + { + "type": "ExportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 16 } - } - }, - { - "type": "ExportSpecifier", - "exported": { + }, + "range": [ + 13, + 16 + ], + "local": { "type": "Identifier", - "name": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -76,15 +113,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "local": { - "type": "Identifier", - "name": "bar", + }, "range": [ 13, 16 ], + "name": "bar" + }, + "exported": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -94,64 +131,23 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "bar" } } ], - "source": null, - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 18 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -269,7 +265,11 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-var-anonymous-function.result.js b/tests/fixtures/ecma-features/modules/export-var-anonymous-function.result.js index e7fb2c65..bfc762dd 100644 --- a/tests/fixtures/ecma-features/modules/export-var-anonymous-function.result.js +++ b/tests/fixtures/ecma-features/modules/export-var-anonymous-function.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "declaration": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 7, + 32 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 11, + 31 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -24,19 +75,35 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ], + "name": "foo" }, "init": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 17, + 31 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 29, - 31 - ], "loc": { "start": { "line": 1, @@ -46,98 +113,27 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "generator": false, - "expression": false, - "range": [ - 17, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 17 }, - "end": { - "line": 1, - "column": 31 - } - } - }, - "range": [ - 11, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 31 + "range": [ + 29, + 31 + ], + "body": [] } } } ], - "kind": "var", - "range": [ - 7, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 32 - } - } + "kind": "var" }, "specifiers": [], - "source": null, - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -147,15 +143,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -165,15 +161,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 17, - 25 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 17, + 25 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -255,15 +251,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -273,15 +269,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -291,15 +287,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -309,7 +305,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-var-number.result.js b/tests/fixtures/ecma-features/modules/export-var-number.result.js index 63085037..471bfa3b 100644 --- a/tests/fixtures/ecma-features/modules/export-var-number.result.js +++ b/tests/fixtures/ecma-features/modules/export-var-number.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "declaration": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 7, + 19 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 11, + 18 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -24,16 +75,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ], + "name": "foo" }, "init": { "type": "Literal", - "value": 1, - "raw": "1", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -43,81 +93,27 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 11, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 17, + 18 + ], + "value": 1, + "raw": "1" } } ], - "kind": "var", - "range": [ - 7, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 19 - } - } + "kind": "var" }, "specifiers": [], - "source": null, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -163,15 +159,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -181,15 +177,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Numeric", "value": "1", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -199,15 +195,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -217,7 +213,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/export-var.result.js b/tests/fixtures/ecma-features/modules/export-var.result.js index b66a6b34..25534f39 100644 --- a/tests/fixtures/ecma-features/modules/export-var.result.js +++ b/tests/fixtures/ecma-features/modules/export-var.result.js @@ -1,20 +1,71 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "body": [ { "type": "ExportNamedDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], "declaration": { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 7, + 15 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 11, + 14 + ], "id": { "type": "Identifier", - "name": "bar", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -24,82 +75,27 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "init": null, - "range": [ - 11, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 14 - } - } + "range": [ + 11, + 14 + ], + "name": "bar" + }, + "init": null } ], - "kind": "var", - "range": [ - 7, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 15 - } - } + "kind": "var" }, "specifiers": [], - "source": null, - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - } + "source": null } ], "sourceType": "module", - "range": [ - 0, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 15 - } - }, "tokens": [ { "type": "Keyword", "value": "export", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -109,15 +105,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -127,15 +123,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -145,15 +141,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -163,7 +159,11 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-default-and-named-specifiers.result.js b/tests/fixtures/ecma-features/modules/import-default-and-named-specifiers.result.js index 067df9d6..9f13762e 100644 --- a/tests/fixtures/ecma-features/modules/import-default-and-named-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/import-default-and-named-specifiers.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "specifiers": [ { "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], "local": { "type": "Identifier", - "name": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -22,32 +59,32 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 7, - 10 - ], + }, + "range": [ + 7, + 10 + ], + "name": "foo" + } + }, + { + "type": "ImportSpecifier", "loc": { "start": { "line": 1, - "column": 7 + "column": 13 }, "end": { "line": 1, - "column": 10 + "column": 16 } - } - }, - { - "type": "ImportSpecifier", - "local": { + }, + "range": [ + 13, + 16 + ], + "imported": { "type": "Identifier", - "name": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -57,15 +94,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 13, 16 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -75,32 +112,17 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -110,47 +132,21 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 29 - } + "range": [ + 23, + 28 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -160,15 +156,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 18, - 22 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 18, + 22 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 23, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -304,7 +300,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-default-and-namespace-specifiers.result.js b/tests/fixtures/ecma-features/modules/import-default-and-namespace-specifiers.result.js index 38203cd5..0a6962ef 100644 --- a/tests/fixtures/ecma-features/modules/import-default-and-namespace-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/import-default-and-namespace-specifiers.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "specifiers": [ { "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], "local": { "type": "Identifier", - "name": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -22,32 +59,32 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 7, - 10 - ], + }, + "range": [ + 7, + 10 + ], + "name": "foo" + } + }, + { + "type": "ImportNamespaceSpecifier", "loc": { "start": { "line": 1, - "column": 7 + "column": 12 }, "end": { "line": 1, - "column": 10 + "column": 20 } - } - }, - { - "type": "ImportNamespaceSpecifier", + }, + "range": [ + 12, + 20 + ], "local": { "type": "Identifier", - "name": "bar", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, @@ -57,32 +94,17 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 12, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 12 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 17, + 20 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 26, - 31 - ], "loc": { "start": { "line": 1, @@ -92,47 +114,21 @@ module.exports = { "line": 1, "column": 31 } - } - }, - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 32 - } + "range": [ + 26, + 31 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -142,15 +138,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -160,15 +156,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 14, + 16 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 17, + 20 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 21, - 25 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 21, + 25 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 26, - 31 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 26, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -286,7 +282,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-default-as.result.js b/tests/fixtures/ecma-features/modules/import-default-as.result.js index a1385770..eebf0b85 100644 --- a/tests/fixtures/ecma-features/modules/import-default-as.result.js +++ b/tests/fixtures/ecma-features/modules/import-default-as.result.js @@ -1,71 +1,93 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 0, + 35 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 8, + 22 + ], + "imported": { "type": "Identifier", - "name": "foo", - "range": [ - 19, - 22 - ], "loc": { "start": { "line": 1, - "column": 19 + "column": 8 }, "end": { "line": 1, - "column": 22 + "column": 15 } - } - }, - "imported": { - "type": "Identifier", - "name": "default", + }, "range": [ 8, 15 ], + "name": "default" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 19 }, "end": { "line": 1, - "column": 15 + "column": 22 } - } - }, - "range": [ - 8, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 19, + 22 + ], + "name": "foo" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 29, - 34 - ], "loc": { "start": { "line": 1, @@ -75,47 +97,21 @@ module.exports = { "line": 1, "column": 34 } - } - }, - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 35 - } + "range": [ + 29, + 34 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 35 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Keyword", "value": "default", - "range": [ - 8, - 15 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 8, + 15 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 16, - 18 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 16, + 18 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 19, - 22 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 19, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 24, - 28 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 24, + 28 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 29, - 34 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 29, + 34 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -269,7 +265,11 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-default.result.js b/tests/fixtures/ecma-features/modules/import-default.result.js index fe411ff0..302d67ea 100644 --- a/tests/fixtures/ecma-features/modules/import-default.result.js +++ b/tests/fixtures/ecma-features/modules/import-default.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "specifiers": [ { "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], "local": { "type": "Identifier", - "name": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -22,32 +59,17 @@ module.exports = { "line": 1, "column": 10 } - } - }, - "range": [ - 7, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 10 - } + "range": [ + 7, + 10 + ], + "name": "foo" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -57,47 +79,21 @@ module.exports = { "line": 1, "column": 21 } - } - }, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 16, + 21 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 11, - 15 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 11, + 15 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 16, - 21 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 16, + 21 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -179,7 +175,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-jquery.result.js b/tests/fixtures/ecma-features/modules/import-jquery.result.js index ab8af592..d9f86150 100644 --- a/tests/fixtures/ecma-features/modules/import-jquery.result.js +++ b/tests/fixtures/ecma-features/modules/import-jquery.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "specifiers": [ { "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ], "local": { "type": "Identifier", - "name": "$", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -22,32 +59,17 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "range": [ - 7, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 8 - } + "range": [ + 7, + 8 + ], + "name": "$" } } ], "source": { "type": "Literal", - "value": "jquery", - "raw": "\"jquery\"", - "range": [ - 14, - 22 - ], "loc": { "start": { "line": 1, @@ -57,47 +79,21 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 2, - "column": 0 - } + "range": [ + 14, + 22 + ], + "value": "jquery", + "raw": "\"jquery\"" } } ], "sourceType": "module", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 0 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Identifier", "value": "$", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 9, - 13 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 9, + 13 + ] }, { "type": "String", "value": "\"jquery\"", - "range": [ - 14, - 22 - ], "loc": { "start": { "line": 1, @@ -161,7 +157,11 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 14, + 22 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-module.result.js b/tests/fixtures/ecma-features/modules/import-module.result.js index 2643a24f..3db364e7 100644 --- a/tests/fixtures/ecma-features/modules/import-module.result.js +++ b/tests/fixtures/ecma-features/modules/import-module.result.js @@ -1,17 +1,39 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "specifiers": [], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 7, - 12 - ], "loc": { "start": { "line": 1, @@ -21,47 +43,21 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 13 - } + "range": [ + 7, + 12 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -71,15 +67,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 7, - 12 - ], "loc": { "start": { "line": 1, @@ -89,15 +85,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 7, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -107,7 +103,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-as-specifier.result.js b/tests/fixtures/ecma-features/modules/import-named-as-specifier.result.js index b441d10a..0990b1ae 100644 --- a/tests/fixtures/ecma-features/modules/import-named-as-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-as-specifier.result.js @@ -1,71 +1,93 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 8, + 18 + ], + "imported": { "type": "Identifier", - "name": "baz", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 18 + "column": 11 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 8, 11 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - "range": [ - 8, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 15, + 18 + ], + "name": "baz" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 25, - 30 - ], "loc": { "start": { "line": 1, @@ -75,47 +97,21 @@ module.exports = { "line": 1, "column": 30 } - } - }, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 31 - } + "range": [ + 25, + 30 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Identifier", "value": "baz", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 20, - 24 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 20, + 24 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 25, - 30 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 25, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -269,7 +265,11 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-as-specifiers.result.js b/tests/fixtures/ecma-features/modules/import-named-as-specifiers.result.js index b6ca2d2f..29bc59fa 100644 --- a/tests/fixtures/ecma-features/modules/import-named-as-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-as-specifiers.result.js @@ -1,71 +1,108 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 0, + 36 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 8, + 18 + ], + "imported": { "type": "Identifier", - "name": "baz", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, - "column": 15 + "column": 8 }, "end": { "line": 1, - "column": 18 + "column": 11 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 8, 11 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 15 }, "end": { "line": 1, - "column": 11 + "column": 18 } - } - }, - "range": [ - 8, - 18 - ], + }, + "range": [ + 15, + 18 + ], + "name": "baz" + } + }, + { + "type": "ImportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 20 }, "end": { "line": 1, - "column": 18 + "column": 23 } - } - }, - { - "type": "ImportSpecifier", - "local": { + }, + "range": [ + 20, + 23 + ], + "imported": { "type": "Identifier", - "name": "xyz", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 1, @@ -75,15 +112,15 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "imported": { - "type": "Identifier", - "name": "xyz", + }, "range": [ 20, 23 ], + "name": "xyz" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -93,32 +130,17 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "range": [ - 20, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 23 - } + "range": [ + 20, + 23 + ], + "name": "xyz" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 30, - 35 - ], "loc": { "start": { "line": 1, @@ -128,47 +150,21 @@ module.exports = { "line": 1, "column": 35 } - } - }, - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 36 - } + "range": [ + 30, + 35 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 36 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 12, + 14 + ] }, { "type": "Identifier", "value": "baz", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Identifier", "value": "xyz", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 20, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -304,15 +300,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 25, - 29 - ], "loc": { "start": { "line": 1, @@ -322,15 +318,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 25, + 29 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 30, - 35 - ], "loc": { "start": { "line": 1, @@ -340,15 +336,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 30, + 35 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 35, - 36 - ], "loc": { "start": { "line": 1, @@ -358,7 +354,11 @@ module.exports = { "line": 1, "column": 36 } - } + }, + "range": [ + 35, + 36 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-empty.result.js b/tests/fixtures/ecma-features/modules/import-named-empty.result.js index 77309085..eee15feb 100644 --- a/tests/fixtures/ecma-features/modules/import-named-empty.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-empty.result.js @@ -1,17 +1,39 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], "specifiers": [], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 15, - 20 - ], "loc": { "start": { "line": 1, @@ -21,47 +43,21 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 21 - } + "range": [ + 15, + 20 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 21 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -71,15 +67,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -89,15 +85,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 10, - 14 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 10, + 14 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 15, - 20 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 15, + 20 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -161,7 +157,11 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-specifier.result.js b/tests/fixtures/ecma-features/modules/import-named-specifier.result.js index a25bf86a..531a0c3c 100644 --- a/tests/fixtures/ecma-features/modules/import-named-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-specifier.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "imported": { "type": "Identifier", - "name": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -22,15 +59,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 8, 11 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -40,32 +77,17 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 8, + 11 + ], + "name": "bar" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 18, - 23 - ], "loc": { "start": { "line": 1, @@ -75,47 +97,21 @@ module.exports = { "line": 1, "column": 23 } - } - }, - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 24 - } + "range": [ + 18, + 23 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 24 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 13, - 17 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 13, + 17 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 18, - 23 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 18, + 23 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -233,7 +229,11 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-specifiers-comma.result.js b/tests/fixtures/ecma-features/modules/import-named-specifiers-comma.result.js index 3c10855b..da3b7c5f 100644 --- a/tests/fixtures/ecma-features/modules/import-named-specifiers-comma.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-specifiers-comma.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 0, + 30 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "imported": { "type": "Identifier", - "name": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -22,15 +59,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 8, 11 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -40,32 +77,32 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], + }, + "range": [ + 8, + 11 + ], + "name": "bar" + } + }, + { + "type": "ImportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 16 } - } - }, - { - "type": "ImportSpecifier", - "local": { + }, + "range": [ + 13, + 16 + ], + "imported": { "type": "Identifier", - "name": "baz", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -75,15 +112,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "imported": { - "type": "Identifier", - "name": "baz", + }, "range": [ 13, 16 ], + "name": "baz" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -93,32 +130,17 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "baz" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 24, - 29 - ], "loc": { "start": { "line": 1, @@ -128,47 +150,21 @@ module.exports = { "line": 1, "column": 29 } - } - }, - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 30 - } + "range": [ + 24, + 29 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "baz", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 19, - 23 - ], "loc": { "start": { "line": 1, @@ -304,15 +300,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 19, + 23 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 24, - 29 - ], "loc": { "start": { "line": 1, @@ -322,15 +318,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 24, + 29 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -340,7 +336,11 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-named-specifiers.result.js b/tests/fixtures/ecma-features/modules/import-named-specifiers.result.js index 2a1ed55c..ae83c96e 100644 --- a/tests/fixtures/ecma-features/modules/import-named-specifiers.result.js +++ b/tests/fixtures/ecma-features/modules/import-named-specifiers.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "imported": { "type": "Identifier", - "name": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -22,15 +59,15 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "imported": { - "type": "Identifier", - "name": "bar", + }, "range": [ 8, 11 ], + "name": "bar" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -40,32 +77,32 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 8, - 11 - ], + }, + "range": [ + 8, + 11 + ], + "name": "bar" + } + }, + { + "type": "ImportSpecifier", "loc": { "start": { "line": 1, - "column": 8 + "column": 13 }, "end": { "line": 1, - "column": 11 + "column": 16 } - } - }, - { - "type": "ImportSpecifier", - "local": { + }, + "range": [ + 13, + 16 + ], + "imported": { "type": "Identifier", - "name": "baz", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -75,15 +112,15 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "imported": { - "type": "Identifier", - "name": "baz", + }, "range": [ 13, 16 ], + "name": "baz" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, @@ -93,32 +130,17 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 13, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 13 }, - "end": { - "line": 1, - "column": 16 - } + "range": [ + 13, + 16 + ], + "name": "baz" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -128,47 +150,21 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 29 - } + "range": [ + 23, + 28 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -178,15 +174,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -196,15 +192,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 8, - 11 - ], "loc": { "start": { "line": 1, @@ -214,15 +210,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 8, + 11 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -232,15 +228,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Identifier", "value": "baz", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 1, @@ -250,15 +246,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -268,15 +264,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 18, - 22 - ], "loc": { "start": { "line": 1, @@ -286,15 +282,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 18, + 22 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 23, - 28 - ], "loc": { "start": { "line": 1, @@ -304,15 +300,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 23, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -322,7 +318,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-namespace-specifier.result.js b/tests/fixtures/ecma-features/modules/import-namespace-specifier.result.js index 3dd30c16..442bcf2c 100644 --- a/tests/fixtures/ecma-features/modules/import-namespace-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/import-namespace-specifier.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "specifiers": [ { "type": "ImportNamespaceSpecifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 7, + 15 + ], "local": { "type": "Identifier", - "name": "foo", - "range": [ - 12, - 15 - ], "loc": { "start": { "line": 1, @@ -22,32 +59,17 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "range": [ - 7, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 12, + 15 + ], + "name": "foo" } } ], "source": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 21, - 26 - ], "loc": { "start": { "line": 1, @@ -57,47 +79,21 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 21, + 26 + ], + "value": "foo", + "raw": "\"foo\"" } } ], "sourceType": "module", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -107,15 +103,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "*", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 9, - 11 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 9, + 11 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 12, - 15 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 12, + 15 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 16, - 20 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 16, + 20 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 21, - 26 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 21, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -215,7 +211,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/import-null-as-nil.result.js b/tests/fixtures/ecma-features/modules/import-null-as-nil.result.js index da3eacb3..51de8627 100644 --- a/tests/fixtures/ecma-features/modules/import-null-as-nil.result.js +++ b/tests/fixtures/ecma-features/modules/import-null-as-nil.result.js @@ -1,71 +1,93 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 0, + 33 + ], "body": [ { "type": "ImportDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 0, + 33 + ], "specifiers": [ { "type": "ImportSpecifier", - "local": { + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 9, + 20 + ], + "imported": { "type": "Identifier", - "name": "nil", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, - "column": 17 + "column": 9 }, "end": { "line": 1, - "column": 20 + "column": 13 } - } - }, - "imported": { - "type": "Identifier", - "name": "null", + }, "range": [ 9, 13 ], + "name": "null" + }, + "local": { + "type": "Identifier", "loc": { "start": { "line": 1, - "column": 9 + "column": 17 }, "end": { "line": 1, - "column": 13 + "column": 20 } - } - }, - "range": [ - 9, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 17, + 20 + ], + "name": "nil" } } ], "source": { "type": "Literal", - "value": "bar", - "raw": "\"bar\"", - "range": [ - 28, - 33 - ], "loc": { "start": { "line": 1, @@ -75,47 +97,21 @@ module.exports = { "line": 1, "column": 33 } - } - }, - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 2, - "column": 0 - } + "range": [ + 28, + 33 + ], + "value": "bar", + "raw": "\"bar\"" } } ], "sourceType": "module", - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 0 - } - }, "tokens": [ { "type": "Keyword", "value": "import", - "range": [ - 0, - 6 - ], "loc": { "start": { "line": 1, @@ -125,15 +121,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 0, + 6 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Null", "value": "null", - "range": [ - 9, - 13 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 9, + 13 + ] }, { "type": "Identifier", "value": "as", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 14, + 16 + ] }, { "type": "Identifier", "value": "nil", - "range": [ - 17, - 20 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 17, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Identifier", "value": "from", - "range": [ - 23, - 27 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 23, + 27 + ] }, { "type": "String", "value": "\"bar\"", - "range": [ - 28, - 33 - ], "loc": { "start": { "line": 1, @@ -251,7 +247,11 @@ module.exports = { "line": 1, "column": 33 } - } + }, + "range": [ + 28, + 33 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-await.result.js b/tests/fixtures/ecma-features/modules/invalid-await.result.js index 9d157a1e..17d1ba59 100644 --- a/tests/fixtures/ecma-features/modules/invalid-await.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-await.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 11, "lineNumber": 1, "column": 12, - "description": "Use of future reserved word in strict mode" + "message": "Unexpected token await" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-class.result.js b/tests/fixtures/ecma-features/modules/invalid-class.result.js index fb4396ad..25e055bd 100644 --- a/tests/fixtures/ecma-features/modules/invalid-class.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-class.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 15, "lineNumber": 1, "column": 16, - "description": "Unexpected reserved word" + "message": "Unexpected token class" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-batch-missing-from-clause.result.js b/tests/fixtures/ecma-features/modules/invalid-export-batch-missing-from-clause.result.js index d9b99b9b..f2375cd2 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-batch-missing-from-clause.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-batch-missing-from-clause.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 8, - "lineNumber": 1, - "column": 9, - "description": "Missing from clause" + "index": 9, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-batch-token.result.js b/tests/fixtures/ecma-features/modules/invalid-export-batch-token.result.js index 7da37cc2..fa80be05 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-batch-token.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-batch-token.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 8, + "index": 9, "lineNumber": 1, - "column": 9, - "description": "Unexpected token +" + "column": 10, + "message": "Unexpected token +" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-default-equal.result.js b/tests/fixtures/ecma-features/modules/invalid-export-default-equal.result.js index f0f77428..2307539d 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-default-equal.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-default-equal.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 15, "lineNumber": 1, "column": 16, - "description": "Unexpected token =" + "message": "Unexpected token =" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-default-token.result.js b/tests/fixtures/ecma-features/modules/invalid-export-default-token.result.js index 0b8d997f..7d0e4da8 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-default-token.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-default-token.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 16, + "index": 8, "lineNumber": 1, - "column": 17, - "description": "Unexpected token +" + "column": 9, + "message": "Unexpected token default" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-default.result.js b/tests/fixtures/ecma-features/modules/invalid-export-default.result.js index 9ae31d2c..3bfa9d5e 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-default.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-default.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 14, + "index": 20, "lineNumber": 1, - "column": 15, - "description": "Unexpected token from" + "column": 21, + "message": "Unexpected token \"foo\"" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-named-default.result.js b/tests/fixtures/ecma-features/modules/invalid-export-named-default.result.js index 074e0216..7d0e4da8 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-named-default.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-named-default.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 16, + "index": 8, "lineNumber": 1, - "column": 17, - "description": "Missing from clause" + "column": 9, + "message": "Unexpected token default" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-named-extra-comma.result.js b/tests/fixtures/ecma-features/modules/invalid-export-named-extra-comma.result.js index bd35b8d1..71fbc25e 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-named-extra-comma.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-named-extra-comma.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 16, "lineNumber": 1, "column": 17, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-export-named-middle-comma.result.js b/tests/fixtures/ecma-features/modules/invalid-export-named-middle-comma.result.js index c10592aa..2650c22f 100644 --- a/tests/fixtures/ecma-features/modules/invalid-export-named-middle-comma.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-export-named-middle-comma.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 12, "lineNumber": 1, "column": 13, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-default-after-named-after-default.result.js b/tests/fixtures/ecma-features/modules/invalid-import-default-after-named-after-default.result.js index 37801017..3840ae72 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-default-after-named-after-default.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-default-after-named-after-default.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 17, "lineNumber": 1, "column": 18, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-default-after-named.result.js b/tests/fixtures/ecma-features/modules/invalid-import-default-after-named.result.js index c10592aa..2650c22f 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-default-after-named.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-default-after-named.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 12, "lineNumber": 1, "column": 13, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-default-missing-module-specifier.result.js b/tests/fixtures/ecma-features/modules/invalid-import-default-missing-module-specifier.result.js index bea09d12..67cd07b5 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-default-missing-module-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-default-missing-module-specifier.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 10, - "lineNumber": 1, - "column": 11, - "description": "Missing from clause" + "index": 11, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-default-module-specifier.result.js b/tests/fixtures/ecma-features/modules/invalid-import-default-module-specifier.result.js index af7f274f..9b520a58 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-default-module-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-default-module-specifier.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 16, "lineNumber": 1, "column": 17, - "description": "Invalid module specifier" + "message": "Unexpected token bar" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-default.result.js b/tests/fixtures/ecma-features/modules/invalid-import-default.result.js index b9ac8905..b2c0d7d9 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-default.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-default.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 6, + "index": 7, "lineNumber": 1, - "column": 7, - "description": "Unexpected token default" + "column": 8, + "message": "Unexpected token default" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-missing-module-specifier.result.js b/tests/fixtures/ecma-features/modules/invalid-import-missing-module-specifier.result.js index 09708d5f..56b2c92b 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-missing-module-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-missing-module-specifier.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 19, - "lineNumber": 1, - "column": 20, - "description": "Missing from clause" + "index": 20, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-module-specifier.result.js b/tests/fixtures/ecma-features/modules/invalid-import-module-specifier.result.js index df9c58b2..27e1b80c 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-module-specifier.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-module-specifier.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 18, "lineNumber": 1, "column": 19, - "description": "Invalid module specifier" + "message": "Unexpected token bar" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-named-after-named.result.js b/tests/fixtures/ecma-features/modules/invalid-import-named-after-named.result.js index c10592aa..2650c22f 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-named-after-named.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-named-after-named.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 12, "lineNumber": 1, "column": 13, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-named-after-namespace.result.js b/tests/fixtures/ecma-features/modules/invalid-import-named-after-namespace.result.js index b70f9acc..397186ec 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-named-after-namespace.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-named-after-namespace.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 15, "lineNumber": 1, "column": 16, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-named-as-missing-from.result.js b/tests/fixtures/ecma-features/modules/invalid-import-named-as-missing-from.result.js index 1e2f3f1a..1df2bf9e 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-named-as-missing-from.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-named-as-missing-from.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 23, - "lineNumber": 1, - "column": 24, - "description": "Missing from clause" + "index": 24, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-named-extra-comma.result.js b/tests/fixtures/ecma-features/modules/invalid-import-named-extra-comma.result.js index bd35b8d1..71fbc25e 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-named-extra-comma.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-named-extra-comma.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 16, "lineNumber": 1, "column": 17, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-named-middle-comma.result.js b/tests/fixtures/ecma-features/modules/invalid-import-named-middle-comma.result.js index c10592aa..2650c22f 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-named-middle-comma.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-named-middle-comma.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 12, "lineNumber": 1, "column": 13, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-namespace-after-named.result.js b/tests/fixtures/ecma-features/modules/invalid-import-namespace-after-named.result.js index c10592aa..2650c22f 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-namespace-after-named.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-namespace-after-named.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 12, "lineNumber": 1, "column": 13, - "description": "Unexpected token ," + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/modules/invalid-import-namespace-missing-as.result.js b/tests/fixtures/ecma-features/modules/invalid-import-namespace-missing-as.result.js index 9a00bcfe..cf21fb2c 100644 --- a/tests/fixtures/ecma-features/modules/invalid-import-namespace-missing-as.result.js +++ b/tests/fixtures/ecma-features/modules/invalid-import-namespace-missing-as.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 8, + "index": 9, "lineNumber": 1, - "column": 9, - "description": "Missing as after import *" + "column": 10, + "message": "Unexpected token from" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/newTarget/invalid-new-target.result.js b/tests/fixtures/ecma-features/newTarget/invalid-new-target.result.js index ee425b1a..deaf3293 100644 --- a/tests/fixtures/ecma-features/newTarget/invalid-new-target.result.js +++ b/tests/fixtures/ecma-features/newTarget/invalid-new-target.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 12, + "index": 8, "lineNumber": 1, - "column": 13, - "description": "Unexpected identifier" + "column": 9, + "message": "new.target can only be used in functions" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/newTarget/invalid-unknown-property.result.js b/tests/fixtures/ecma-features/newTarget/invalid-unknown-property.result.js index d0d1bf0f..52de9c60 100644 --- a/tests/fixtures/ecma-features/newTarget/invalid-unknown-property.result.js +++ b/tests/fixtures/ecma-features/newTarget/invalid-unknown-property.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 25, "lineNumber": 1, "column": 26, - "description": "Unexpected identifier" + "message": "The only valid meta property for new is new.target" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/newTarget/simple-new-target.result.js b/tests/fixtures/ecma-features/newTarget/simple-new-target.result.js index 400fcc9c..50b45bf2 100644 --- a/tests/fixtures/ecma-features/newTarget/simple-new-target.result.js +++ b/tests/fixtures/ecma-features/newTarget/simple-new-target.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 40 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 40 + ], "id": { "type": "Identifier", - "name": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,24 +42,68 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "f" }, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 13, + 40 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 19, + 38 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 23, + 37 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 2, @@ -46,16 +113,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 23, + 24 + ], + "name": "x" }, "init": { "type": "MetaProperty", - "meta": "new", - "property": "target", - "range": [ - 27, - 37 - ], "loc": { "start": { "line": 2, @@ -65,97 +131,61 @@ module.exports = { "line": 2, "column": 22 } - } - }, - "range": [ - 23, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 8 }, - "end": { - "line": 2, - "column": 22 + "range": [ + 27, + 37 + ], + "meta": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 27, + 30 + ], + "name": "new" + }, + "property": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 31, + 37 + ], + "name": "target" } } } ], - "kind": "var", - "range": [ - 19, - 38 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 23 - } - } - } - ], - "range": [ - 13, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 3, - "column": 1 + "kind": "var" } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -165,15 +195,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -183,15 +213,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -201,15 +231,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -219,15 +249,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -237,15 +267,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 19, - 22 - ], "loc": { "start": { "line": 2, @@ -255,15 +285,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 19, + 22 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 2, @@ -273,15 +303,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 2, @@ -291,15 +321,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "new", - "range": [ - 27, - 30 - ], "loc": { "start": { "line": 2, @@ -309,15 +339,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 27, + 30 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 2, @@ -327,15 +357,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Identifier", "value": "target", - "range": [ - 31, - 37 - ], "loc": { "start": { "line": 2, @@ -345,15 +375,15 @@ module.exports = { "line": 2, "column": 22 } - } + }, + "range": [ + 31, + 37 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 2, @@ -363,15 +393,15 @@ module.exports = { "line": 2, "column": 23 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 3, @@ -381,7 +411,11 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 39, + 40 + ] } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-addition-property.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-addition-property.result.js index 94a4f101..d9878c12 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-addition-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-addition-property.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 29 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 4, + 28 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,24 +59,67 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 28 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 14, + 26 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "BinaryExpression", - "operator": "+", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 15, + 20 + ], "left": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -49,16 +129,17 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 15, + 16 + ], + "value": 5, + "raw": "5" }, + "operator": "+", "right": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -68,30 +149,17 @@ module.exports = { "line": 2, "column": 10 } - } - }, - "range": [ - 15, - 20 - ], - "loc": { - "start": { - "line": 2, - "column": 5 }, - "end": { - "line": 2, - "column": 10 - } + "range": [ + 19, + 20 + ], + "value": 5, + "raw": "5" } }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 23, - 26 - ], "loc": { "start": { "line": 2, @@ -101,99 +169,27 @@ module.exports = { "line": 2, "column": 16 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 14, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 16 - } - } - } - ], - "range": [ - 8, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 3, - "column": 1 + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "kind": "init" } - } - }, - "range": [ - 4, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 3, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -203,15 +199,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -221,15 +217,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -239,15 +235,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -257,15 +253,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -275,15 +271,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -293,15 +289,15 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "+", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -311,15 +307,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -329,15 +325,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 2, @@ -347,15 +343,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 2, @@ -365,15 +361,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 23, - 26 - ], "loc": { "start": { "line": 2, @@ -383,15 +379,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 23, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 3, @@ -401,15 +397,15 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 3, @@ -419,7 +415,11 @@ module.exports = { "line": 3, "column": 2 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-and-identifier.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-and-identifier.result.js index 43616df7..223995bf 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-and-identifier.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-and-identifier.result.js @@ -1,20 +1,74 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "expression": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 1, + 17 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 2, + 9 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -24,16 +78,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "x" }, "value": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -43,36 +96,37 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ], + "value": 10, + "raw": "10" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 2, - 9 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 2 + "column": 11 }, "end": { "line": 1, - "column": 9 + "column": 16 } - } - }, - { - "type": "Property", + }, + "range": [ + 11, + 16 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -82,16 +136,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "y" }, "value": { "type": "Literal", - "value": 20, - "raw": "20", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -101,82 +154,25 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 11, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 16 - } - } - } - ], - "range": [ - 1, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 + "range": [ + 14, + 16 + ], + "value": 20, + "raw": "20" + }, + "kind": "init" } - } - }, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -186,15 +182,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -204,15 +200,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -276,15 +272,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -294,15 +290,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -312,15 +308,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -330,15 +326,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -348,15 +344,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Numeric", "value": "20", - "range": [ - 14, - 16 - ], "loc": { "start": { "line": 1, @@ -366,15 +362,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 14, + 16 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -384,15 +380,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -402,15 +398,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -420,7 +416,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-getter-and-setter.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-getter-and-setter.result.js index fe93a406..fc461135 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-getter-and-setter.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-getter-and-setter.result.js @@ -1,20 +1,74 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 0, + 32 + ], "expression": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 1, + 30 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 2, + 14 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "x", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -24,19 +78,36 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ], + "name": "x" }, + "kind": "get", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 12, - 14 - ], "loc": { "start": { "line": 1, @@ -46,53 +117,36 @@ module.exports = { "line": 1, "column": 14 } - } - }, - "generator": false, - "expression": false, - "range": [ - 9, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 9 }, - "end": { - "line": 1, - "column": 14 - } + "range": [ + 12, + 14 + ], + "body": [] } - }, - "kind": "get", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 2, - 14 - ], + } + }, + { + "type": "Property", "loc": { "start": { "line": 1, - "column": 2 + "column": 16 }, "end": { "line": 1, - "column": 14 + "column": 29 } - } - }, - { - "type": "Property", + }, + "range": [ + 16, + 29 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "x", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -102,19 +156,36 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ], + "name": "x" }, + "kind": "set", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 23, + 29 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "v", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -124,16 +195,16 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ], + "name": "v" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 27, - 29 - ], "loc": { "start": { "line": 1, @@ -143,99 +214,24 @@ module.exports = { "line": 1, "column": 29 } - } - }, - "generator": false, - "expression": false, - "range": [ - 23, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 23 }, - "end": { - "line": 1, - "column": 29 - } - } - }, - "kind": "set", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 16, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 29 + "range": [ + 27, + 29 + ], + "body": [] } } } - ], - "range": [ - 1, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 32 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -245,15 +241,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -263,15 +259,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 2, - 5 - ], "loc": { "start": { "line": 1, @@ -281,15 +277,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 2, + 5 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -299,15 +295,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -317,15 +313,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -335,15 +331,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -353,15 +349,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -371,15 +367,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -389,15 +385,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -407,15 +403,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 16, - 19 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 16, + 19 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -461,15 +457,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -479,15 +475,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -497,15 +493,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -515,15 +511,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "v", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -533,15 +529,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -551,15 +547,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -569,15 +565,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -587,15 +583,15 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 1, @@ -605,15 +601,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 1, @@ -623,15 +619,15 @@ module.exports = { "line": 1, "column": 31 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -641,7 +637,11 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-string-property.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-string-property.result.js index 25591a4a..758277ec 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-string-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-string-property.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 29 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 4, + 28 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,21 +59,51 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 28 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 14, + 26 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Literal", - "value": "hey", - "raw": "\"hey\"", - "range": [ - 15, - 20 - ], "loc": { "start": { "line": 2, @@ -46,15 +113,16 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 15, + 20 + ], + "value": "hey", + "raw": "\"hey\"" }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 23, - 26 - ], "loc": { "start": { "line": 2, @@ -64,99 +132,27 @@ module.exports = { "line": 2, "column": 16 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 14, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 16 - } - } - } - ], - "range": [ - 8, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 3, - "column": 1 + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "kind": "init" } - } - }, - "range": [ - 4, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 3, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -166,15 +162,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -184,15 +180,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -238,15 +234,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "String", "value": "\"hey\"", - "range": [ - 15, - 20 - ], "loc": { "start": { "line": 2, @@ -256,15 +252,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 15, + 20 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 2, @@ -274,15 +270,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 2, @@ -292,15 +288,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 23, - 26 - ], "loc": { "start": { "line": 2, @@ -310,15 +306,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 23, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 3, @@ -328,15 +324,15 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 3, @@ -346,7 +342,11 @@ module.exports = { "line": 3, "column": 2 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-variable-property.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-variable-property.result.js index 483cf610..fa5f0d5e 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-variable-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/computed-variable-property.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "range": [ + 0, + 27 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 4, + 26 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 26 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 14, + 24 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 2, @@ -45,15 +113,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 15, + 18 + ], + "name": "bar" }, "value": { "type": "Identifier", - "name": "foo", - "range": [ - 21, - 24 - ], "loc": { "start": { "line": 2, @@ -63,99 +131,27 @@ module.exports = { "line": 2, "column": 14 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 14, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 14 - } - } - } - ], - "range": [ - 8, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 3, - "column": 1 + "range": [ + 21, + 24 + ], + "name": "foo" + }, + "kind": "init" } - } - }, - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 3, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -165,15 +161,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -183,15 +179,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -237,15 +233,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 2, @@ -255,15 +251,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 2, @@ -273,15 +269,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -291,15 +287,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 21, - 24 - ], "loc": { "start": { "line": 2, @@ -309,15 +305,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 21, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -327,15 +323,15 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 3, @@ -345,7 +341,11 @@ module.exports = { "line": 3, "column": 2 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-computed-variable-property.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-computed-variable-property.result.js index 27428dfd..e253e4bf 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-computed-variable-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-computed-variable-property.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 20, "lineNumber": 3, "column": 1, - "description": "Unexpected token }" + "message": "Unexpected token }" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.result.js index efa2268a..f7180132 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 5, "lineNumber": 1, "column": 6, - "description": "Unexpected token }" + "message": "Unexpected token }" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-addition.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-addition.result.js index c612cc4a..750041c1 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-addition.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-addition.result.js @@ -1,24 +1,90 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "expression": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 1, + 18 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 2, + 17 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "BinaryExpression", - "operator": "+", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 3, + 12 + ], "left": { "type": "Literal", - "value": "x", - "raw": "\"x\"", - "range": [ - 3, - 6 - ], "loc": { "start": { "line": 1, @@ -28,16 +94,17 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 3, + 6 + ], + "value": "x", + "raw": "\"x\"" }, + "operator": "+", "right": { "type": "Literal", - "value": "y", - "raw": "\"y\"", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -47,31 +114,17 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 3, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 3 }, - "end": { - "line": 1, - "column": 12 - } + "range": [ + 9, + 12 + ], + "value": "y", + "raw": "\"y\"" } }, "value": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -81,82 +134,25 @@ module.exports = { "line": 1, "column": 17 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 2, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 2 }, - "end": { - "line": 1, - "column": 17 - } - } - } - ], - "range": [ - 1, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 18 + "range": [ + 15, + 17 + ], + "value": 10, + "raw": "10" + }, + "kind": "init" } - } - }, - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -166,15 +162,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -184,15 +180,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "String", "value": "\"x\"", - "range": [ - 3, - 6 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 3, + 6 + ] }, { "type": "Punctuator", "value": "+", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "String", "value": "\"y\"", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -274,15 +270,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -292,15 +288,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 15, - 17 - ], "loc": { "start": { "line": 1, @@ -310,15 +306,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 15, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -328,15 +324,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -346,15 +342,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -364,7 +360,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-method.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-method.result.js index 439aa59c..52937b51 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-method.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression-with-method.result.js @@ -1,20 +1,74 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "expression": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 1, + 21 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 2, + 20 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -24,19 +78,35 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "x" }, "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 7, + 20 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 18, - 20 - ], "loc": { "start": { "line": 1, @@ -46,99 +116,25 @@ module.exports = { "line": 1, "column": 20 } - } - }, - "generator": false, - "expression": false, - "range": [ - 7, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 20 - } + "range": [ + 18, + 20 + ], + "body": [] } }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 2, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 2 - }, - "end": { - "line": 1, - "column": 20 - } - } - } - ], - "range": [ - 1, - 21 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 21 + "kind": "init" } - } - }, - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -148,15 +144,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -166,15 +162,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -184,15 +180,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 7, - 15 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 7, + 15 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -274,15 +270,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -292,15 +288,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -310,15 +306,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -328,15 +324,15 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -346,15 +342,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -364,15 +360,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -382,7 +378,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression.result.js b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression.result.js index f4fb1112..e970140d 100644 --- a/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression.result.js +++ b/tests/fixtures/ecma-features/objectLiteralComputedProperties/standalone-expression.result.js @@ -1,20 +1,74 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "expression": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 1, + 10 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 2, + 9 + ], + "method": false, + "shorthand": false, + "computed": true, "key": { "type": "Identifier", - "name": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -24,16 +78,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ], + "name": "x" }, "value": { "type": "Literal", - "value": 10, - "raw": "10", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -43,82 +96,25 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": true, - "range": [ - 2, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 2 }, - "end": { - "line": 1, - "column": 9 - } - } - } - ], - "range": [ - 1, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 10 + "range": [ + 7, + 9 + ], + "value": 10, + "raw": "10" + }, + "kind": "init" } - } - }, - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, "tokens": [ { "type": "Punctuator", "value": "(", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 1, - 2 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 2 } - } + }, + "range": [ + 1, + 2 + ] }, { "type": "Punctuator", "value": "[", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "]", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Numeric", "value": "10", - "range": [ - 7, - 9 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 7, + 9 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -290,7 +286,11 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-property.result.js b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-property.result.js index 7d1da761..976511e1 100644 --- a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-property.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 78, + "index": 62, "lineNumber": 7, - "column": 18, - "description": "Duplicate '__proto__' property in object literal are not allowed" + "column": 2, + "message": "Redefinition of __proto__ property" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-string-property.result.js b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-string-property.result.js index 51dd9aee..4d43f85c 100644 --- a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-string-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/proto-string-property.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 82, + "index": 64, "lineNumber": 7, - "column": 20, - "description": "Duplicate '__proto__' property in object literal are not allowed" + "column": 2, + "message": "Redefinition of __proto__ property" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-properties.result.js b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-properties.result.js index 5b4e4e4c..9747c26c 100644 --- a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-properties.result.js +++ b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-properties.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "range": [ + 0, + 53 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "Literal", - "value": "use strict", - "raw": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -20,35 +42,50 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 0, - 13 - ], + }, + "range": [ + 0, + 12 + ], + "value": "use strict", + "raw": "\"use strict\"" + } + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 3, "column": 0 }, "end": { - "line": 1, - "column": 13 + "line": 6, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 15, + 53 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 19, + 52 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 3, @@ -58,20 +95,51 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 19, + 20 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 23, + 52 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 26, + 36 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -81,16 +149,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 26, + 27 + ], + "name": "y" }, "value": { "type": "Literal", - "value": "first", - "raw": "'first'", - "range": [ - 29, - 36 - ], "loc": { "start": { "line": 4, @@ -100,36 +167,37 @@ module.exports = { "line": 4, "column": 11 } - } + }, + "range": [ + 29, + 36 + ], + "value": "first", + "raw": "'first'" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 26, - 36 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { - "line": 4, + "line": 5, "column": 1 }, "end": { - "line": 4, - "column": 11 + "line": 5, + "column": 12 } - } - }, - { - "type": "Property", + }, + "range": [ + 39, + 50 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "y", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 5, @@ -139,16 +207,15 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 39, + 40 + ], + "name": "y" }, "value": { "type": "Literal", - "value": "second", - "raw": "'second'", - "range": [ - 42, - 50 - ], "loc": { "start": { "line": 5, @@ -158,99 +225,28 @@ module.exports = { "line": 5, "column": 12 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 39, - 50 - ], - "loc": { - "start": { - "line": 5, - "column": 1 }, - "end": { - "line": 5, - "column": 12 - } - } - } - ], - "range": [ - 23, - 52 - ], - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 6, - "column": 1 + "range": [ + 42, + 50 + ], + "value": "second", + "raw": "'second'" + }, + "kind": "init" } - } - }, - "range": [ - 19, - 52 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 6, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 15, - 53 - ], - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 53 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - }, "tokens": [ { "type": "String", "value": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -260,15 +256,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 0, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -278,15 +274,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 3, @@ -296,15 +292,15 @@ module.exports = { "line": 3, "column": 3 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 3, @@ -314,15 +310,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 3, @@ -332,15 +328,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 3, @@ -350,15 +346,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -368,15 +364,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 4, @@ -386,15 +382,15 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "String", "value": "'first'", - "range": [ - 29, - 36 - ], "loc": { "start": { "line": 4, @@ -404,15 +400,15 @@ module.exports = { "line": 4, "column": 11 } - } + }, + "range": [ + 29, + 36 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 4, @@ -422,15 +418,15 @@ module.exports = { "line": 4, "column": 12 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Identifier", "value": "y", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 5, @@ -440,15 +436,15 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 39, + 40 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 5, @@ -458,15 +454,15 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "String", "value": "'second'", - "range": [ - 42, - 50 - ], "loc": { "start": { "line": 5, @@ -476,15 +472,15 @@ module.exports = { "line": 5, "column": 12 } - } + }, + "range": [ + 42, + 50 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 6, @@ -494,15 +490,15 @@ module.exports = { "line": 6, "column": 1 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 52, - 53 - ], "loc": { "start": { "line": 6, @@ -512,7 +508,11 @@ module.exports = { "line": 6, "column": 2 } - } + }, + "range": [ + 52, + 53 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-string-properties.result.js b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-string-properties.result.js index 53188fe6..128460a5 100644 --- a/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-string-properties.result.js +++ b/tests/fixtures/ecma-features/objectLiteralDuplicateProperties/strict-duplicate-string-properties.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "range": [ + 0, + 57 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "Literal", - "value": "use strict", - "raw": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -20,35 +42,50 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 0, - 13 - ], + }, + "range": [ + 0, + 12 + ], + "value": "use strict", + "raw": "\"use strict\"" + } + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 3, "column": 0 }, "end": { - "line": 1, - "column": 13 + "line": 6, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 15, + 57 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 19, + 56 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 3, @@ -58,21 +95,51 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 19, + 20 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 23, + 56 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 26, + 38 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Literal", - "value": "y", - "raw": "\"y\"", - "range": [ - 26, - 29 - ], "loc": { "start": { "line": 4, @@ -82,16 +149,16 @@ module.exports = { "line": 4, "column": 4 } - } + }, + "range": [ + 26, + 29 + ], + "value": "y", + "raw": "\"y\"" }, "value": { "type": "Literal", - "value": "first", - "raw": "\"first\"", - "range": [ - 31, - 38 - ], "loc": { "start": { "line": 4, @@ -101,37 +168,37 @@ module.exports = { "line": 4, "column": 13 } - } + }, + "range": [ + 31, + 38 + ], + "value": "first", + "raw": "\"first\"" }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 26, - 38 - ], + "kind": "init" + }, + { + "type": "Property", "loc": { "start": { - "line": 4, + "line": 5, "column": 1 }, "end": { - "line": 4, - "column": 13 + "line": 5, + "column": 14 } - } - }, - { - "type": "Property", + }, + "range": [ + 41, + 54 + ], + "method": false, + "shorthand": false, + "computed": false, "key": { "type": "Literal", - "value": "y", - "raw": "\"y\"", - "range": [ - 41, - 44 - ], "loc": { "start": { "line": 5, @@ -141,16 +208,16 @@ module.exports = { "line": 5, "column": 4 } - } + }, + "range": [ + 41, + 44 + ], + "value": "y", + "raw": "\"y\"" }, "value": { "type": "Literal", - "value": "second", - "raw": "\"second\"", - "range": [ - 46, - 54 - ], "loc": { "start": { "line": 5, @@ -160,99 +227,28 @@ module.exports = { "line": 5, "column": 14 } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 41, - 54 - ], - "loc": { - "start": { - "line": 5, - "column": 1 }, - "end": { - "line": 5, - "column": 14 - } - } - } - ], - "range": [ - 23, - 56 - ], - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 6, - "column": 1 + "range": [ + 46, + 54 + ], + "value": "second", + "raw": "\"second\"" + }, + "kind": "init" } - } - }, - "range": [ - 19, - 56 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 6, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 15, - 57 - ], - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 57 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - }, "tokens": [ { "type": "String", "value": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -262,15 +258,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 0, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -280,15 +276,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 15, - 18 - ], "loc": { "start": { "line": 3, @@ -298,15 +294,15 @@ module.exports = { "line": 3, "column": 3 } - } + }, + "range": [ + 15, + 18 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 3, @@ -316,15 +312,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 3, @@ -334,15 +330,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 3, @@ -352,15 +348,15 @@ module.exports = { "line": 3, "column": 9 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "String", "value": "\"y\"", - "range": [ - 26, - 29 - ], "loc": { "start": { "line": 4, @@ -370,15 +366,15 @@ module.exports = { "line": 4, "column": 4 } - } + }, + "range": [ + 26, + 29 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 4, @@ -388,15 +384,15 @@ module.exports = { "line": 4, "column": 5 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "String", "value": "\"first\"", - "range": [ - 31, - 38 - ], "loc": { "start": { "line": 4, @@ -406,15 +402,15 @@ module.exports = { "line": 4, "column": 13 } - } + }, + "range": [ + 31, + 38 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 38, - 39 - ], "loc": { "start": { "line": 4, @@ -424,15 +420,15 @@ module.exports = { "line": 4, "column": 14 } - } + }, + "range": [ + 38, + 39 + ] }, { "type": "String", "value": "\"y\"", - "range": [ - 41, - 44 - ], "loc": { "start": { "line": 5, @@ -442,15 +438,15 @@ module.exports = { "line": 5, "column": 4 } - } + }, + "range": [ + 41, + 44 + ] }, { "type": "Punctuator", "value": ":", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 5, @@ -460,15 +456,15 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 44, + 45 + ] }, { "type": "String", "value": "\"second\"", - "range": [ - 46, - 54 - ], "loc": { "start": { "line": 5, @@ -478,15 +474,15 @@ module.exports = { "line": 5, "column": 14 } - } + }, + "range": [ + 46, + 54 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 6, @@ -496,15 +492,15 @@ module.exports = { "line": 6, "column": 1 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 56, - 57 - ], "loc": { "start": { "line": 6, @@ -514,7 +510,11 @@ module.exports = { "line": 6, "column": 2 } - } + }, + "range": [ + 56, + 57 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/invalid-method-no-braces.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/invalid-method-no-braces.result.js index 11d5ceb1..f8f2ba97 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/invalid-method-no-braces.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/invalid-method-no-braces.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 19, "lineNumber": 2, "column": 14, - "description": "Unexpected number" + "message": "Unexpected token 42" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/method-property.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/method-property.result.js index bf99b790..2c0741fd 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/method-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/method-property.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 50 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 50 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 4, + 49 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 49 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 14, + 47 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 14, - 17 - ], "loc": { "start": { "line": 2, @@ -45,24 +113,69 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 14, + 17 + ], + "name": "foo" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 17, + 47 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 20, + 47 + ], "body": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 30, + 41 + ], "argument": { "type": "Identifier", - "name": "bar", - "range": [ - 37, - 40 - ], "loc": { "start": { "line": 3, @@ -72,147 +185,30 @@ module.exports = { "line": 3, "column": 18 } - } - }, - "range": [ - 30, - 41 - ], - "loc": { - "start": { - "line": 3, - "column": 8 }, - "end": { - "line": 3, - "column": 19 - } + "range": [ + 37, + 40 + ], + "name": "bar" } } - ], - "range": [ - 20, - 47 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 17, - 47 - ], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 14, - 47 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 + ] } } } - ], - "range": [ - 8, - 49 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 5, - "column": 1 - } - } - }, - "range": [ - 4, - 49 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 5, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 50 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 50 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -222,15 +218,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -240,15 +236,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -258,15 +254,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -276,15 +272,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 14, - 17 - ], "loc": { "start": { "line": 2, @@ -294,15 +290,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 14, + 17 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -312,15 +308,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 2, @@ -330,15 +326,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 2, @@ -348,15 +344,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 30, - 36 - ], "loc": { "start": { "line": 3, @@ -366,15 +362,15 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 30, + 36 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 37, - 40 - ], "loc": { "start": { "line": 3, @@ -384,15 +380,15 @@ module.exports = { "line": 3, "column": 18 } - } + }, + "range": [ + 37, + 40 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 3, @@ -402,15 +398,15 @@ module.exports = { "line": 3, "column": 19 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 46, - 47 - ], "loc": { "start": { "line": 4, @@ -420,15 +416,15 @@ module.exports = { "line": 4, "column": 5 } - } + }, + "range": [ + 46, + 47 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 48, - 49 - ], "loc": { "start": { "line": 5, @@ -438,15 +434,15 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 48, + 49 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 49, - 50 - ], "loc": { "start": { "line": 5, @@ -456,7 +452,11 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 49, + 50 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-get.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-get.result.js index fd664176..a9a13bc5 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-get.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-get.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "range": [ + 0, + 26 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 25 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 4, + 25 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 10, + 23 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "get", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 2, @@ -45,19 +113,36 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 10, + 13 + ], + "name": "get" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 13, + 23 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 16, - 23 - ], "loc": { "start": { "line": 2, @@ -67,96 +152,21 @@ module.exports = { "line": 3, "column": 5 } - } - }, - "generator": false, - "expression": false, - "range": [ - 13, - 23 - ], - "loc": { - "start": { - "line": 2, - "column": 7 }, - "end": { - "line": 3, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 10, - 23 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 3, - "column": 5 + "range": [ + 16, + 23 + ], + "body": [] } } } - ], - "range": [ - 4, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 2 + ] } } }, { "type": "EmptyStatement", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -166,32 +176,18 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 26, + 27 + ] } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 2, @@ -255,15 +251,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 10, + 13 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 2, @@ -273,15 +269,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -291,15 +287,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -309,15 +305,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 3, @@ -327,15 +323,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 4, @@ -345,15 +341,15 @@ module.exports = { "line": 4, "column": 1 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 4, @@ -363,15 +359,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -381,7 +377,11 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-set.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-set.result.js index b02ed3a4..c82cc704 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-set.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-named-set.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "range": [ + 0, + 26 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 25 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 4, + 25 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 10, + 23 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "set", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 2, @@ -45,19 +113,36 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 10, + 13 + ], + "name": "set" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 13, + 23 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 16, - 23 - ], "loc": { "start": { "line": 2, @@ -67,96 +152,21 @@ module.exports = { "line": 3, "column": 5 } - } - }, - "generator": false, - "expression": false, - "range": [ - 13, - 23 - ], - "loc": { - "start": { - "line": 2, - "column": 7 }, - "end": { - "line": 3, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 10, - 23 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 3, - "column": 5 + "range": [ + 16, + 23 + ], + "body": [] } } } - ], - "range": [ - 4, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 25 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 2 + ] } } }, { "type": "EmptyStatement", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -166,32 +176,18 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 26, + 27 + ] } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 10, - 13 - ], "loc": { "start": { "line": 2, @@ -255,15 +251,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 10, + 13 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 2, @@ -273,15 +269,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 2, @@ -291,15 +287,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -309,15 +305,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 3, @@ -327,15 +323,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 4, @@ -345,15 +341,15 @@ module.exports = { "line": 4, "column": 1 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 4, @@ -363,15 +359,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 4, @@ -381,7 +377,11 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-argument.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-argument.result.js index c397b6a6..66f0609d 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-argument.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-argument.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "range": [ + 0, + 35 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 34 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 33 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 4, + 33 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 10, + 31 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "method", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 2, @@ -45,19 +113,36 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 10, + 16 + ], + "name": "method" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 16, + 31 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "test", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 2, @@ -67,16 +152,16 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 17, + 21 + ], + "name": "test" } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 23, - 31 - ], "loc": { "start": { "line": 2, @@ -86,96 +171,21 @@ module.exports = { "line": 4, "column": 5 } - } - }, - "generator": false, - "expression": false, - "range": [ - 16, - 31 - ], - "loc": { - "start": { - "line": 2, - "column": 10 }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 10, - 31 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 + "range": [ + 23, + 31 + ], + "body": [] } } } - ], - "range": [ - 4, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 5, - "column": 1 - } - } - }, - "range": [ - 0, - 33 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - } - }, - "range": [ - 0, - 34 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 + ] } } }, { "type": "EmptyStatement", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -185,32 +195,18 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 34, + 35 + ] } ], "sourceType": "script", - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 3 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -256,15 +252,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "method", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 2, @@ -274,15 +270,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 10, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -292,15 +288,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "test", - "range": [ - 17, - 21 - ], "loc": { "start": { "line": 2, @@ -310,15 +306,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 17, + 21 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 2, @@ -328,15 +324,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 2, @@ -346,15 +342,15 @@ module.exports = { "line": 2, "column": 18 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 4, @@ -364,15 +360,15 @@ module.exports = { "line": 4, "column": 5 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -382,15 +378,15 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 5, @@ -400,15 +396,15 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -418,7 +414,11 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 34, + 35 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-string-name.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-string-name.result.js index 5321b509..6f610463 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-string-name.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method-with-string-name.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 0, + 32 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "range": [ + 0, + 31 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 30 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,21 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 4, + 30 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 10, + 28 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Literal", - "value": "method", - "raw": "\"method\"", - "range": [ - 10, - 18 - ], "loc": { "start": { "line": 2, @@ -46,19 +113,37 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 10, + 18 + ], + "value": "method", + "raw": "\"method\"" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 18, + 28 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 21, - 28 - ], "loc": { "start": { "line": 2, @@ -68,96 +153,21 @@ module.exports = { "line": 3, "column": 5 } - } - }, - "generator": false, - "expression": false, - "range": [ - 18, - 28 - ], - "loc": { - "start": { - "line": 2, - "column": 12 }, - "end": { - "line": 3, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 10, - 28 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 3, - "column": 5 + "range": [ + 21, + 28 + ], + "body": [] } } } - ], - "range": [ - 4, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 2 + ] } } }, { "type": "EmptyStatement", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 4, @@ -167,32 +177,18 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 31, + 32 + ] } ], "sourceType": "script", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -202,15 +198,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -220,15 +216,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -238,15 +234,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "String", "value": "\"method\"", - "range": [ - 10, - 18 - ], "loc": { "start": { "line": 2, @@ -256,15 +252,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 10, + 18 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 2, @@ -274,15 +270,15 @@ module.exports = { "line": 2, "column": 13 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -292,15 +288,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 2, @@ -310,15 +306,15 @@ module.exports = { "line": 2, "column": 16 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 3, @@ -328,15 +324,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 4, @@ -346,15 +342,15 @@ module.exports = { "line": 4, "column": 1 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 30, - 31 - ], "loc": { "start": { "line": 4, @@ -364,15 +360,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 30, + 31 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 4, @@ -382,7 +378,11 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 31, + 32 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method.result.js index d02cd669..05d14d69 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/simple-method.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "range": [ + 0, + 30 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "range": [ + 0, + 29 + ], "expression": { "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 28 + ], "operator": "=", "left": { "type": "Identifier", - "name": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,51 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ], + "name": "x" }, "right": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 4, + 28 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 10, + 26 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Identifier", - "name": "method", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 2, @@ -45,19 +113,36 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 10, + 16 + ], + "name": "method" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 16, + 26 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 19, - 26 - ], "loc": { "start": { "line": 2, @@ -67,96 +152,21 @@ module.exports = { "line": 3, "column": 5 } - } - }, - "generator": false, - "expression": false, - "range": [ - 16, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 10 }, - "end": { - "line": 3, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 10, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 3, - "column": 5 + "range": [ + 19, + 26 + ], + "body": [] } } } - ], - "range": [ - 4, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - } - }, - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 2 + ] } } }, { "type": "EmptyStatement", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 4, @@ -166,32 +176,18 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 29, + 30 + ] } ], "sourceType": "script", - "range": [ - 0, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, "tokens": [ { "type": "Identifier", "value": "x", - "range": [ - 0, - 1 - ], "loc": { "start": { "line": 1, @@ -201,15 +197,15 @@ module.exports = { "line": 1, "column": 1 } - } + }, + "range": [ + 0, + 1 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 2, - 3 - ], "loc": { "start": { "line": 1, @@ -219,15 +215,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 2, + 3 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -237,15 +233,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Identifier", "value": "method", - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 2, @@ -255,15 +251,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 10, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -273,15 +269,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -291,15 +287,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -309,15 +305,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -327,15 +323,15 @@ module.exports = { "line": 3, "column": 5 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 4, @@ -345,15 +341,15 @@ module.exports = { "line": 4, "column": 1 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 4, @@ -363,15 +359,15 @@ module.exports = { "line": 4, "column": 2 } - } + }, + "range": [ + 28, + 29 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 4, @@ -381,7 +377,11 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 29, + 30 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/string-name-method-property.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/string-name-method-property.result.js index 8b23890d..4fdffc89 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandMethods/string-name-method-property.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandMethods/string-name-method-property.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 52 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 52 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 4, + 51 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,21 +59,51 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 51 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 14, + 49 + ], + "method": true, + "shorthand": false, + "computed": false, "key": { "type": "Literal", - "value": "foo", - "raw": "\"foo\"", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 2, @@ -46,24 +113,70 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 14, + 19 + ], + "value": "foo", + "raw": "\"foo\"" }, + "kind": "init", "value": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 19, + 49 + ], "id": null, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 22, + 49 + ], "body": [ { "type": "ReturnStatement", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 32, + 43 + ], "argument": { "type": "Identifier", - "name": "bar", - "range": [ - 39, - 42 - ], "loc": { "start": { "line": 3, @@ -73,147 +186,30 @@ module.exports = { "line": 3, "column": 18 } - } - }, - "range": [ - 32, - 43 - ], - "loc": { - "start": { - "line": 3, - "column": 8 }, - "end": { - "line": 3, - "column": 19 - } + "range": [ + 39, + 42 + ], + "name": "bar" } } - ], - "range": [ - 22, - 49 - ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 19, - 49 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "range": [ - 14, - 49 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 + ] } } } - ], - "range": [ - 8, - 51 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 5, - "column": 1 - } - } - }, - "range": [ - 4, - 51 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 5, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 52 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 52 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -223,15 +219,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -241,15 +237,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -259,15 +255,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -277,15 +273,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "String", "value": "\"foo\"", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 2, @@ -295,15 +291,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 14, + 19 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -313,15 +309,15 @@ module.exports = { "line": 2, "column": 10 } - } + }, + "range": [ + 19, + 20 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 2, @@ -331,15 +327,15 @@ module.exports = { "line": 2, "column": 11 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 2, @@ -349,15 +345,15 @@ module.exports = { "line": 2, "column": 13 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Keyword", "value": "return", - "range": [ - 32, - 38 - ], "loc": { "start": { "line": 3, @@ -367,15 +363,15 @@ module.exports = { "line": 3, "column": 14 } - } + }, + "range": [ + 32, + 38 + ] }, { "type": "Identifier", "value": "bar", - "range": [ - 39, - 42 - ], "loc": { "start": { "line": 3, @@ -385,15 +381,15 @@ module.exports = { "line": 3, "column": 18 } - } + }, + "range": [ + 39, + 42 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 3, @@ -403,15 +399,15 @@ module.exports = { "line": 3, "column": 19 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 48, - 49 - ], "loc": { "start": { "line": 4, @@ -421,15 +417,15 @@ module.exports = { "line": 4, "column": 5 } - } + }, + "range": [ + 48, + 49 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 50, - 51 - ], "loc": { "start": { "line": 5, @@ -439,15 +435,15 @@ module.exports = { "line": 5, "column": 1 } - } + }, + "range": [ + 50, + 51 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 5, @@ -457,7 +453,11 @@ module.exports = { "line": 5, "column": 2 } - } + }, + "range": [ + 51, + 52 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/objectLiteralShorthandProperties/shorthand-properties.result.js b/tests/fixtures/ecma-features/objectLiteralShorthandProperties/shorthand-properties.result.js index 1cdf0bdb..a27872be 100644 --- a/tests/fixtures/ecma-features/objectLiteralShorthandProperties/shorthand-properties.result.js +++ b/tests/fixtures/ecma-features/objectLiteralShorthandProperties/shorthand-properties.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "range": [ + 0, + 66 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 0, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,33 +59,33 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ], + "name": "foo" }, - "init": null, - "range": [ - 4, - 7 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 1, + "line": 2, "column": 4 }, "end": { - "line": 1, + "line": 2, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 13, + 16 + ], "id": { "type": "Identifier", - "name": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -58,33 +95,33 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ], + "name": "get" }, - "init": null, - "range": [ - 13, - 16 - ], + "init": null + }, + { + "type": "VariableDeclarator", "loc": { "start": { - "line": 2, + "line": 3, "column": 4 }, "end": { - "line": 2, + "line": 3, "column": 7 } - } - }, - { - "type": "VariableDeclarator", + }, + "range": [ + 22, + 25 + ], "id": { "type": "Identifier", - "name": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -94,53 +131,53 @@ module.exports = { "line": 3, "column": 7 } - } - }, - "init": null, - "range": [ - 22, - 25 - ], - "loc": { - "start": { - "line": 3, - "column": 4 }, - "end": { - "line": 3, - "column": 7 - } - } + "range": [ + 22, + 25 + ], + "name": "set" + }, + "init": null } ], - "kind": "var", - "range": [ - 0, - 26 - ], + "kind": "var" + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 5, "column": 0 }, "end": { - "line": 3, - "column": 8 + "line": 9, + "column": 2 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 28, + 66 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 32, + 65 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -150,20 +187,51 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ], + "name": "x" }, "init": { "type": "ObjectExpression", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 36, + 65 + ], "properties": [ { "type": "Property", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 42, + 45 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -173,15 +241,16 @@ module.exports = { "line": 6, "column": 7 } - } - }, - "value": { - "type": "Identifier", - "name": "foo", + }, "range": [ 42, 45 ], + "name": "foo" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 6, @@ -191,36 +260,35 @@ module.exports = { "line": 6, "column": 7 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 42, - 45 - ], + }, + "range": [ + 42, + 45 + ], + "name": "foo" + } + }, + { + "type": "Property", "loc": { "start": { - "line": 6, + "line": 7, "column": 4 }, "end": { - "line": 6, + "line": 7, "column": 7 } - } - }, - { - "type": "Property", + }, + "range": [ + 51, + 54 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "get", - "range": [ - 51, - 54 - ], "loc": { "start": { "line": 7, @@ -230,15 +298,16 @@ module.exports = { "line": 7, "column": 7 } - } - }, - "value": { - "type": "Identifier", - "name": "get", + }, "range": [ 51, 54 ], + "name": "get" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 7, @@ -248,36 +317,35 @@ module.exports = { "line": 7, "column": 7 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 51, - 54 - ], + }, + "range": [ + 51, + 54 + ], + "name": "get" + } + }, + { + "type": "Property", "loc": { "start": { - "line": 7, + "line": 8, "column": 4 }, "end": { - "line": 7, + "line": 8, "column": 7 } - } - }, - { - "type": "Property", + }, + "range": [ + 60, + 63 + ], + "method": false, + "shorthand": true, + "computed": false, "key": { "type": "Identifier", - "name": "set", - "range": [ - 60, - 63 - ], "loc": { "start": { "line": 8, @@ -287,15 +355,16 @@ module.exports = { "line": 8, "column": 7 } - } - }, - "value": { - "type": "Identifier", - "name": "set", + }, "range": [ 60, 63 ], + "name": "set" + }, + "kind": "init", + "value": { + "type": "Identifier", "loc": { "start": { "line": 8, @@ -305,99 +374,26 @@ module.exports = { "line": 8, "column": 7 } - } - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "range": [ - 60, - 63 - ], - "loc": { - "start": { - "line": 8, - "column": 4 }, - "end": { - "line": 8, - "column": 7 - } + "range": [ + 60, + 63 + ], + "name": "set" } } - ], - "range": [ - 36, - 65 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 9, - "column": 1 - } - } - }, - "range": [ - 32, - 65 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 9, - "column": 1 - } + ] } } ], - "kind": "var", - "range": [ - 28, - 66 - ], - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 66 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 9, - "column": 2 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -407,15 +403,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -425,15 +421,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -443,15 +439,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 13, - 16 - ], "loc": { "start": { "line": 2, @@ -461,15 +457,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 13, + 16 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 2, @@ -479,15 +475,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 22, - 25 - ], "loc": { "start": { "line": 3, @@ -497,15 +493,15 @@ module.exports = { "line": 3, "column": 7 } - } + }, + "range": [ + 22, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 3, @@ -515,15 +511,15 @@ module.exports = { "line": 3, "column": 8 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 28, - 31 - ], "loc": { "start": { "line": 5, @@ -533,15 +529,15 @@ module.exports = { "line": 5, "column": 3 } - } + }, + "range": [ + 28, + 31 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 32, - 33 - ], "loc": { "start": { "line": 5, @@ -551,15 +547,15 @@ module.exports = { "line": 5, "column": 5 } - } + }, + "range": [ + 32, + 33 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 5, @@ -569,15 +565,15 @@ module.exports = { "line": 5, "column": 7 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 36, - 37 - ], "loc": { "start": { "line": 5, @@ -587,15 +583,15 @@ module.exports = { "line": 5, "column": 9 } - } + }, + "range": [ + 36, + 37 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 42, - 45 - ], "loc": { "start": { "line": 6, @@ -605,15 +601,15 @@ module.exports = { "line": 6, "column": 7 } - } + }, + "range": [ + 42, + 45 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 45, - 46 - ], "loc": { "start": { "line": 6, @@ -623,15 +619,15 @@ module.exports = { "line": 6, "column": 8 } - } + }, + "range": [ + 45, + 46 + ] }, { "type": "Identifier", "value": "get", - "range": [ - 51, - 54 - ], "loc": { "start": { "line": 7, @@ -641,15 +637,15 @@ module.exports = { "line": 7, "column": 7 } - } + }, + "range": [ + 51, + 54 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 54, - 55 - ], "loc": { "start": { "line": 7, @@ -659,15 +655,15 @@ module.exports = { "line": 7, "column": 8 } - } + }, + "range": [ + 54, + 55 + ] }, { "type": "Identifier", "value": "set", - "range": [ - 60, - 63 - ], "loc": { "start": { "line": 8, @@ -677,15 +673,15 @@ module.exports = { "line": 8, "column": 7 } - } + }, + "range": [ + 60, + 63 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 64, - 65 - ], "loc": { "start": { "line": 9, @@ -695,15 +691,15 @@ module.exports = { "line": 9, "column": 1 } - } + }, + "range": [ + 64, + 65 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 65, - 66 - ], "loc": { "start": { "line": 9, @@ -713,7 +709,11 @@ module.exports = { "line": 9, "column": 2 } - } + }, + "range": [ + 65, + 66 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/octalLiterals/invalid.result.js b/tests/fixtures/ecma-features/octalLiterals/invalid.result.js index 6081eafe..59ae7eea 100644 --- a/tests/fixtures/ecma-features/octalLiterals/invalid.result.js +++ b/tests/fixtures/ecma-features/octalLiterals/invalid.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 4, "lineNumber": 1, "column": 5, - "description": "Unexpected token ILLEGAL" + "message": "Identifier directly after number" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/octalLiterals/lowercase.result.js b/tests/fixtures/ecma-features/octalLiterals/lowercase.result.js index 2982c359..7631534d 100644 --- a/tests/fixtures/ecma-features/octalLiterals/lowercase.result.js +++ b/tests/fixtures/ecma-features/octalLiterals/lowercase.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "expression": { "type": "Literal", - "value": 463, - "raw": "0o717", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 0, + 5 + ], + "value": 463, + "raw": "0o717" } } ], "sourceType": "script", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, "tokens": [ { "type": "Numeric", "value": "0o717", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/octalLiterals/strict-uppercase.result.js b/tests/fixtures/ecma-features/octalLiterals/strict-uppercase.result.js index 547d8cd2..49739987 100644 --- a/tests/fixtures/ecma-features/octalLiterals/strict-uppercase.result.js +++ b/tests/fixtures/ecma-features/octalLiterals/strict-uppercase.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "Literal", - "value": "use strict", - "raw": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -20,33 +42,33 @@ module.exports = { "line": 1, "column": 12 } - } - }, - "range": [ - 0, - 13 - ], + }, + "range": [ + 0, + 12 + ], + "value": "use strict", + "raw": "\"use strict\"" + } + }, + { + "type": "ExpressionStatement", "loc": { "start": { - "line": 1, + "line": 2, "column": 0 }, "end": { - "line": 1, - "column": 13 + "line": 2, + "column": 6 } - } - }, - { - "type": "ExpressionStatement", + }, + "range": [ + 14, + 20 + ], "expression": { "type": "Literal", - "value": 463, - "raw": "0O717", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 2, @@ -56,47 +78,21 @@ module.exports = { "line": 2, "column": 5 } - } - }, - "range": [ - 14, - 20 - ], - "loc": { - "start": { - "line": 2, - "column": 0 }, - "end": { - "line": 2, - "column": 6 - } + "range": [ + 14, + 19 + ], + "value": 463, + "raw": "0O717" } } ], "sourceType": "script", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 6 - } - }, "tokens": [ { "type": "String", "value": "\"use strict\"", - "range": [ - 0, - 12 - ], "loc": { "start": { "line": 1, @@ -106,15 +102,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 0, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -124,15 +120,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Numeric", "value": "0O717", - "range": [ - 14, - 19 - ], "loc": { "start": { "line": 2, @@ -142,15 +138,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 14, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 2, @@ -160,7 +156,11 @@ module.exports = { "line": 2, "column": 6 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/octalLiterals/uppercase.result.js b/tests/fixtures/ecma-features/octalLiterals/uppercase.result.js index 51b7ebee..72f01ff2 100644 --- a/tests/fixtures/ecma-features/octalLiterals/uppercase.result.js +++ b/tests/fixtures/ecma-features/octalLiterals/uppercase.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], "expression": { "type": "Literal", - "value": 463, - "raw": "0O717", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 6 - } + "range": [ + 0, + 5 + ], + "value": 463, + "raw": "0O717" } } ], "sourceType": "script", - "range": [ - 0, - 6 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, "tokens": [ { "type": "Numeric", "value": "0O717", - "range": [ - 0, - 5 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 0, + 5 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/regexUFlag/regex-u-extended-escape.result.js b/tests/fixtures/ecma-features/regexUFlag/regex-u-extended-escape.result.js index 2021c479..f111ee8a 100644 --- a/tests/fixtures/ecma-features/regexUFlag/regex-u-extended-escape.result.js +++ b/tests/fixtures/ecma-features/regexUFlag/regex-u-extended-escape.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 4, + 40 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,15 @@ module.exports = { "line": 1, "column": 5 } - } - }, - "init": { - "type": "Literal", - "value": null, - "raw": "/[\\u{0000000000000061}-\\u{7A}]/u", - "regex": { - "pattern": "[\\u{0000000000000061}-\\u{7A}]", - "flags": "u" }, "range": [ - 8, - 40 + 4, + 5 ], + "name": "x" + }, + "init": { + "type": "Literal", "loc": { "start": { "line": 1, @@ -45,64 +77,28 @@ module.exports = { "line": 1, "column": 40 } - } - }, - "range": [ - 4, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 40 + "range": [ + 8, + 40 + ], + "value": null, + "raw": "/[\\u{0000000000000061}-\\u{7A}]/u", + "regex": { + "pattern": "[\\u{0000000000000061}-\\u{7A}]", + "flags": "u" } } } ], - "kind": "var", - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 41 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 41 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 41 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -112,15 +108,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -130,15 +126,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -148,19 +144,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "RegularExpression", "value": "/[\\u{0000000000000061}-\\u{7A}]/u", - "regex": { - "pattern": "[\\u{0000000000000061}-\\u{7A}]", - "flags": "u" - }, - "range": [ - 8, - 40 - ], "loc": { "start": { "line": 1, @@ -170,15 +162,19 @@ module.exports = { "line": 1, "column": 40 } + }, + "range": [ + 8, + 40 + ], + "regex": { + "flags": "u", + "pattern": "[\\u{0000000000000061}-\\u{7A}]" } }, { "type": "Punctuator", "value": ";", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 1, @@ -188,7 +184,11 @@ module.exports = { "line": 1, "column": 41 } - } + }, + "range": [ + 40, + 41 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/regexUFlag/regex-u-invalid-extended-escape.result.js b/tests/fixtures/ecma-features/regexUFlag/regex-u-invalid-extended-escape.result.js index 92df24b5..8370cfa6 100644 --- a/tests/fixtures/ecma-features/regexUFlag/regex-u-invalid-extended-escape.result.js +++ b/tests/fixtures/ecma-features/regexUFlag/regex-u-invalid-extended-escape.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 21, + "index": 12, "lineNumber": 1, - "column": 22, - "description": "Invalid regular expression" + "column": 13, + "message": "Code point out of bounds" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/regexUFlag/regex-u-simple.result.js b/tests/fixtures/ecma-features/regexUFlag/regex-u-simple.result.js index 324bfa99..ba8560d7 100644 --- a/tests/fixtures/ecma-features/regexUFlag/regex-u-simple.result.js +++ b/tests/fixtures/ecma-features/regexUFlag/regex-u-simple.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 4, + 16 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,15 @@ module.exports = { "line": 1, "column": 7 } - } - }, - "init": { - "type": "Literal", - "value": null, - "raw": "/foo/u", - "regex": { - "pattern": "foo", - "flags": "u" }, "range": [ - 10, - 16 + 4, + 7 ], + "name": "foo" + }, + "init": { + "type": "Literal", "loc": { "start": { "line": 1, @@ -45,64 +77,28 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 4, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 16 + "range": [ + 10, + 16 + ], + "value": null, + "raw": "/foo/u", + "regex": { + "pattern": "foo", + "flags": "u" } } } ], - "kind": "var", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -112,15 +108,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -130,15 +126,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -148,19 +144,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "RegularExpression", "value": "/foo/u", - "regex": { - "pattern": "foo", - "flags": "u" - }, - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 1, @@ -170,15 +162,19 @@ module.exports = { "line": 1, "column": 16 } + }, + "range": [ + 10, + 16 + ], + "regex": { + "flags": "u", + "pattern": "foo" } }, { "type": "Punctuator", "value": ";", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -188,7 +184,11 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/regexYFlag/regexp-y-simple.result.js b/tests/fixtures/ecma-features/regexYFlag/regexp-y-simple.result.js index 54242629..e0bf35b6 100644 --- a/tests/fixtures/ecma-features/regexYFlag/regexp-y-simple.result.js +++ b/tests/fixtures/ecma-features/regexYFlag/regexp-y-simple.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 4, + 16 + ], "id": { "type": "Identifier", - "name": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -22,20 +59,15 @@ module.exports = { "line": 1, "column": 7 } - } - }, - "init": { - "type": "Literal", - "value": null, - "raw": "/foo/y", - "regex": { - "pattern": "foo", - "flags": "y" }, "range": [ - 10, - 16 + 4, + 7 ], + "name": "foo" + }, + "init": { + "type": "Literal", "loc": { "start": { "line": 1, @@ -45,64 +77,28 @@ module.exports = { "line": 1, "column": 16 } - } - }, - "range": [ - 4, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 16 + "range": [ + 10, + 16 + ], + "value": null, + "raw": "/foo/y", + "regex": { + "pattern": "foo", + "flags": "y" } } } ], - "kind": "var", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 17 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 17 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -112,15 +108,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "foo", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -130,15 +126,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -148,19 +144,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "RegularExpression", "value": "/foo/y", - "regex": { - "pattern": "foo", - "flags": "y" - }, - "range": [ - 10, - 16 - ], "loc": { "start": { "line": 1, @@ -170,15 +162,19 @@ module.exports = { "line": 1, "column": 16 } + }, + "range": [ + 10, + 16 + ], + "regex": { + "flags": "y", + "pattern": "foo" } }, { "type": "Punctuator", "value": ";", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -188,7 +184,11 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/basic-rest.result.js b/tests/fixtures/ecma-features/restParams/basic-rest.result.js index 8fbb0886..9f872275 100644 --- a/tests/fixtures/ecma-features/restParams/basic-rest.result.js +++ b/tests/fixtures/ecma-features/restParams/basic-rest.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], "id": { "type": "Identifier", - "name": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,16 +42,18 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "f" }, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -38,17 +63,31 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ], + "name": "a" }, { "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 14, + 18 + ], "argument": { "type": "Identifier", - "name": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -58,31 +97,17 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 14, - 18 - ], - "loc": { - "start": { - "line": 1, - "column": 14 }, - "end": { - "line": 1, - "column": 18 - } + "range": [ + 17, + 18 + ], + "name": "b" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 20, - 22 - ], "loc": { "start": { "line": 1, @@ -92,31 +117,16 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 20, + 22 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -126,32 +136,18 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ], "sourceType": "script", - "range": [ - 0, - 23 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 14, - 17 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 14, + 17 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -287,15 +283,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 20, - 21 - ], "loc": { "start": { "line": 1, @@ -305,15 +301,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 20, + 21 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -323,15 +319,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -341,7 +337,11 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/error-no-default.result.js b/tests/fixtures/ecma-features/restParams/error-no-default.result.js index 70ea254b..dd0b8fb4 100644 --- a/tests/fixtures/ecma-features/restParams/error-no-default.result.js +++ b/tests/fixtures/ecma-features/restParams/error-no-default.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 19, "lineNumber": 1, "column": 20, - "description": "Rest parameter can not have a default value" + "message": "Unexpected token =" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/error-not-last.result.js b/tests/fixtures/ecma-features/restParams/error-not-last.result.js index 714dee79..4e7e97af 100644 --- a/tests/fixtures/ecma-features/restParams/error-not-last.result.js +++ b/tests/fixtures/ecma-features/restParams/error-not-last.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 18, "lineNumber": 1, "column": 19, - "description": "Rest parameter must be last formal parameter" + "message": "Unexpected token ," }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/func-expression-multi.result.js b/tests/fixtures/ecma-features/restParams/func-expression-multi.result.js index f3e9f009..f56dcac4 100644 --- a/tests/fixtures/ecma-features/restParams/func-expression-multi.result.js +++ b/tests/fixtures/ecma-features/restParams/func-expression-multi.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 4, + 28 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,19 +59,35 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 8, + 28 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "Identifier", - "name": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -44,17 +97,31 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ], + "name": "a" }, { "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 20, + 24 + ], "argument": { "type": "Identifier", - "name": "b", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -64,31 +131,17 @@ module.exports = { "line": 1, "column": 24 } - } - }, - "range": [ - 20, - 24 - ], - "loc": { - "start": { - "line": 1, - "column": 20 }, - "end": { - "line": 1, - "column": 24 - } + "range": [ + 23, + 24 + ], + "name": "b" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 26, - 28 - ], "loc": { "start": { "line": 1, @@ -98,81 +151,24 @@ module.exports = { "line": 1, "column": 28 } - } - }, - "generator": false, - "expression": false, - "range": [ - 8, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 28 - } - } - }, - "range": [ - 4, - 28 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 28 + "range": [ + 26, + 28 + ], + "body": [] } } } ], - "kind": "var", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 29 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 8, - 16 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 8, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 16, - 17 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 17 } - } + }, + "range": [ + 16, + 17 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -290,15 +286,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 20, - 23 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 20, + 23 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 23, - 24 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 24 } - } + }, + "range": [ + 23, + 24 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -344,15 +340,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -362,15 +358,15 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 27, - 28 - ], "loc": { "start": { "line": 1, @@ -380,15 +376,15 @@ module.exports = { "line": 1, "column": 28 } - } + }, + "range": [ + 27, + 28 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 28, - 29 - ], "loc": { "start": { "line": 1, @@ -398,7 +394,11 @@ module.exports = { "line": 1, "column": 29 } - } + }, + "range": [ + 28, + 29 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/func-expression.result.js b/tests/fixtures/ecma-features/restParams/func-expression.result.js index 0ce6e353..3a8641ee 100644 --- a/tests/fixtures/ecma-features/restParams/func-expression.result.js +++ b/tests/fixtures/ecma-features/restParams/func-expression.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 4, + 26 + ], "id": { "type": "Identifier", - "name": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,21 +59,51 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "x" }, "init": { "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 8, + 26 + ], "id": null, + "generator": false, + "expression": false, "params": [ { "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 18, + 22 + ], "argument": { "type": "Identifier", - "name": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -46,31 +113,17 @@ module.exports = { "line": 1, "column": 22 } - } - }, - "range": [ - 18, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 18 }, - "end": { - "line": 1, - "column": 22 - } + "range": [ + 21, + 22 + ], + "name": "a" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 24, - 26 - ], "loc": { "start": { "line": 1, @@ -80,81 +133,24 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "generator": false, - "expression": false, - "range": [ - 8, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 8 }, - "end": { - "line": 1, - "column": 26 - } - } - }, - "range": [ - 4, - 26 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 26 + "range": [ + 24, + 26 + ], + "body": [] } } } ], - "kind": "var", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -164,15 +160,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "x", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -182,15 +178,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -200,15 +196,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Keyword", "value": "function", - "range": [ - 8, - 16 - ], "loc": { "start": { "line": 1, @@ -218,15 +214,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 8, + 16 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -236,15 +232,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 18, - 21 - ], "loc": { "start": { "line": 1, @@ -254,15 +250,15 @@ module.exports = { "line": 1, "column": 21 } - } + }, + "range": [ + 18, + 21 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 21, - 22 - ], "loc": { "start": { "line": 1, @@ -272,15 +268,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 21, + 22 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 22, - 23 - ], "loc": { "start": { "line": 1, @@ -290,15 +286,15 @@ module.exports = { "line": 1, "column": 23 } - } + }, + "range": [ + 22, + 23 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 24, - 25 - ], "loc": { "start": { "line": 1, @@ -308,15 +304,15 @@ module.exports = { "line": 1, "column": 25 } - } + }, + "range": [ + 24, + 25 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 1, @@ -326,15 +322,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -344,7 +340,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/invalid-rest-param.result.js b/tests/fixtures/ecma-features/restParams/invalid-rest-param.result.js index 6fd44019..ea9373db 100644 --- a/tests/fixtures/ecma-features/restParams/invalid-rest-param.result.js +++ b/tests/fixtures/ecma-features/restParams/invalid-rest-param.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 14, "lineNumber": 1, "column": 15, - "description": "Invalid rest parameter" + "message": "Unexpected token {" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/restParams/single-rest.result.js b/tests/fixtures/ecma-features/restParams/single-rest.result.js index 2e74663b..3a79eb27 100644 --- a/tests/fixtures/ecma-features/restParams/single-rest.result.js +++ b/tests/fixtures/ecma-features/restParams/single-rest.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "id": { "type": "Identifier", - "name": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -19,18 +42,34 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ], + "name": "f" }, + "generator": false, + "expression": false, "params": [ { "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 11, + 15 + ], "argument": { "type": "Identifier", - "name": "b", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -40,31 +79,17 @@ module.exports = { "line": 1, "column": 15 } - } - }, - "range": [ - 11, - 15 - ], - "loc": { - "start": { - "line": 1, - "column": 11 }, - "end": { - "line": 1, - "column": 15 - } + "range": [ + 14, + 15 + ], + "name": "b" } } ], "body": { "type": "BlockStatement", - "body": [], - "range": [ - 17, - 19 - ], "loc": { "start": { "line": 1, @@ -74,31 +99,16 @@ module.exports = { "line": 1, "column": 19 } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 19 - } + "range": [ + 17, + 19 + ], + "body": [] } }, { "type": "EmptyStatement", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -108,32 +118,18 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ], "sourceType": "script", - "range": [ - 0, - 20 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 20 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -143,15 +139,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "f", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -161,15 +157,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -179,15 +175,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 1, @@ -197,15 +193,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 11, + 14 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 14, - 15 - ], "loc": { "start": { "line": 1, @@ -215,15 +211,15 @@ module.exports = { "line": 1, "column": 15 } - } + }, + "range": [ + 14, + 15 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -233,15 +229,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 1, @@ -251,15 +247,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -269,15 +265,15 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 19, - 20 - ], "loc": { "start": { "line": 1, @@ -287,7 +283,11 @@ module.exports = { "line": 1, "column": 20 } - } + }, + "range": [ + 19, + 20 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/spread/error-invalid-if.result.js b/tests/fixtures/ecma-features/spread/error-invalid-if.result.js index c6fa6319..95e30f8b 100644 --- a/tests/fixtures/ecma-features/spread/error-invalid-if.result.js +++ b/tests/fixtures/ecma-features/spread/error-invalid-if.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 10, + "index": 6, "lineNumber": 1, - "column": 11, - "description": "Spread must be the final element of an element list" + "column": 7, + "message": "Unexpected token ..." }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/spread/error-invalid-sequence.result.js b/tests/fixtures/ecma-features/spread/error-invalid-sequence.result.js index a064626f..ef21dc07 100644 --- a/tests/fixtures/ecma-features/spread/error-invalid-sequence.result.js +++ b/tests/fixtures/ecma-features/spread/error-invalid-sequence.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 8, + "index": 4, "lineNumber": 1, - "column": 9, - "description": "Illegal spread element" + "column": 5, + "message": "Unexpected token ..." }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/spread/multi-function-call.result.js b/tests/fixtures/ecma-features/spread/multi-function-call.result.js index 1adc0ce5..20380ab5 100644 --- a/tests/fixtures/ecma-features/spread/multi-function-call.result.js +++ b/tests/fixtures/ecma-features/spread/multi-function-call.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], "callee": { "type": "Identifier", - "name": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,16 +58,16 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "foo" }, "arguments": [ { "type": "Identifier", - "name": "a", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -40,17 +77,31 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "a" }, { "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 7, + 11 + ], "argument": { "type": "Identifier", - "name": "b", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -60,78 +111,23 @@ module.exports = { "line": 1, "column": 11 } - } - }, - "range": [ - 7, - 11 - ], - "loc": { - "start": { - "line": 1, - "column": 7 }, - "end": { - "line": 1, - "column": 11 - } + "range": [ + 10, + 11 + ], + "name": "b" } } - ], - "range": [ - 0, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Identifier", "value": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 5, - 6 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 5, + 6 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 7, - 10 - ], "loc": { "start": { "line": 1, @@ -213,15 +209,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 7, + 10 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 10, - 11 - ], "loc": { "start": { "line": 1, @@ -231,15 +227,15 @@ module.exports = { "line": 1, "column": 11 } - } + }, + "range": [ + 10, + 11 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -249,15 +245,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -267,7 +263,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/spread/not-final-param.result.js b/tests/fixtures/ecma-features/spread/not-final-param.result.js index ed7c2ac0..6830f042 100644 --- a/tests/fixtures/ecma-features/spread/not-final-param.result.js +++ b/tests/fixtures/ecma-features/spread/not-final-param.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "callee": { "type": "Identifier", - "name": "func", - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -21,18 +58,32 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 0, + 4 + ], + "name": "func" }, "arguments": [ { "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], "argument": { "type": "Identifier", - "name": "a", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -42,30 +93,16 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "range": [ - 5, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 5 }, - "end": { - "line": 1, - "column": 9 - } + "range": [ + 8, + 9 + ], + "name": "a" } }, { "type": "Identifier", - "name": "b", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -75,63 +112,22 @@ module.exports = { "line": 1, "column": 12 } - } - } - ], - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 + }, + "range": [ + 11, + 12 + ], + "name": "b" } - } - }, - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 14 - } - }, "tokens": [ { "type": "Identifier", "value": "func", - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 0, + 4 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 5, - 8 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 5, + 8 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ",", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -213,15 +209,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 11, - 12 - ], "loc": { "start": { "line": 1, @@ -231,15 +227,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 11, + 12 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -249,15 +245,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -267,7 +263,11 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/spread/simple-function-call.result.js b/tests/fixtures/ecma-features/spread/simple-function-call.result.js index 8145576e..4030fd79 100644 --- a/tests/fixtures/ecma-features/spread/simple-function-call.result.js +++ b/tests/fixtures/ecma-features/spread/simple-function-call.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "callee": { "type": "Identifier", - "name": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,18 +58,32 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "foo" }, "arguments": [ { "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 4, + 8 + ], "argument": { "type": "Identifier", - "name": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -42,78 +93,23 @@ module.exports = { "line": 1, "column": 8 } - } - }, - "range": [ - 4, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 8 - } + "range": [ + 7, + 8 + ], + "name": "a" } } - ], - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 10 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, "tokens": [ { "type": "Identifier", "value": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -123,15 +119,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 3, - 4 - ], "loc": { "start": { "line": 1, @@ -141,15 +137,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 3, + 4 + ] }, { "type": "Punctuator", "value": "...", - "range": [ - 4, - 7 - ], "loc": { "start": { "line": 1, @@ -159,15 +155,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 4, + 7 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -177,15 +173,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -195,15 +191,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -213,7 +209,11 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.result.js b/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.result.js deleted file mode 100644 index 65f17042..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.result.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - "index": 0, - "lineNumber": 1, - "column": 1, - "description": "Unexpected reserved word" -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.src.js b/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.src.js deleted file mode 100644 index 1cadceec..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/invalid-super-global-call.src.js +++ /dev/null @@ -1 +0,0 @@ -super(); \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.result.js b/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.result.js deleted file mode 100644 index cbd72409..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.result.js +++ /dev/null @@ -1,533 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "o", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "foo", - "range": [ - 15, - 18 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 7 - } - } - }, - "value": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Super", - "range": [ - 41, - 46 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } - }, - "arguments": [], - "range": [ - 41, - 48 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 15 - } - } - }, - "range": [ - 41, - 49 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 16 - } - } - } - ], - "range": [ - 31, - 55 - ], - "loc": { - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 20, - 55 - ], - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 15, - 55 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 5, - "column": 5 - } - } - } - ], - "range": [ - 8, - 57 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - "range": [ - 4, - 57 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 6, - "column": 1 - } - } - } - ], - "kind": "var", - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 58 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "var", - "range": [ - 0, - 3 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 3 - } - } - }, - { - "type": "Identifier", - "value": "o", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": "=", - "range": [ - 6, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 7 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 8, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 15, - 18 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 7 - } - } - }, - { - "type": "Punctuator", - "value": ":", - "range": [ - 18, - 19 - ], - "loc": { - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 8 - } - } - }, - { - "type": "Keyword", - "value": "function", - "range": [ - 20, - 28 - ], - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 28, - 29 - ], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 29, - 30 - ], - "loc": { - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 21 - } - } - }, - { - "type": "Keyword", - "value": "super", - "range": [ - 41, - 46 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 46, - 47 - ], - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 14 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 47, - 48 - ], - "loc": { - "start": { - "line": 4, - "column": 14 - }, - "end": { - "line": 4, - "column": 15 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 48, - 49 - ], - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 16 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 54, - 55 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 56, - 57 - ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 57, - 58 - ], - "loc": { - "start": { - "line": 6, - "column": 1 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.src.js b/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.src.js deleted file mode 100644 index 730aa7fd..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-function-call-in-object-literal.src.js +++ /dev/null @@ -1,6 +0,0 @@ -var o = { - - foo: function() { - super(); - } -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-function-call.result.js b/tests/fixtures/ecma-features/superInFunctions/super-function-call.result.js deleted file mode 100644 index 832370c7..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-function-call.result.js +++ /dev/null @@ -1,346 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Super", - "range": [ - 21, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 9 - } - } - }, - "arguments": [], - "range": [ - 21, - 28 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 11 - } - } - }, - "range": [ - 21, - 29 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 12 - } - } - } - ], - "range": [ - 15, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 31 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - { - "type": "EmptyStatement", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 32 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "function", - "range": [ - 0, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 13, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 14 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 16 - } - } - }, - { - "type": "Keyword", - "value": "super", - "range": [ - 21, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 9 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 26, - 27 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 27, - 28 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 28, - 29 - ], - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 12 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 30, - 31 - ], - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-function-call.src.js b/tests/fixtures/ecma-features/superInFunctions/super-function-call.src.js deleted file mode 100644 index 7937758a..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-function-call.src.js +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - super(); -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.result.js b/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.result.js deleted file mode 100644 index 43fe9f37..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.result.js +++ /dev/null @@ -1,605 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "o", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "foo", - "range": [ - 15, - 18 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 7 - } - } - }, - "value": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Super", - "range": [ - 41, - 46 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "range": [ - 47, - 50 - ], - "loc": { - "start": { - "line": 4, - "column": 14 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "range": [ - 41, - 50 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "arguments": [], - "range": [ - 41, - 52 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 19 - } - } - }, - "range": [ - 41, - 53 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 20 - } - } - } - ], - "range": [ - 31, - 59 - ], - "loc": { - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 20, - 59 - ], - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "range": [ - 15, - 59 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 5, - "column": 5 - } - } - } - ], - "range": [ - 8, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - "range": [ - 4, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 6, - "column": 1 - } - } - } - ], - "kind": "var", - "range": [ - 0, - 62 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 62 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 2 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "var", - "range": [ - 0, - 3 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 3 - } - } - }, - { - "type": "Identifier", - "value": "o", - "range": [ - 4, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": "=", - "range": [ - 6, - 7 - ], - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 7 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 8, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 9 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 15, - 18 - ], - "loc": { - "start": { - "line": 3, - "column": 4 - }, - "end": { - "line": 3, - "column": 7 - } - } - }, - { - "type": "Punctuator", - "value": ":", - "range": [ - 18, - 19 - ], - "loc": { - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 8 - } - } - }, - { - "type": "Keyword", - "value": "function", - "range": [ - 20, - 28 - ], - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 28, - 29 - ], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 29, - 30 - ], - "loc": { - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 21 - } - } - }, - { - "type": "Keyword", - "value": "super", - "range": [ - 41, - 46 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": ".", - "range": [ - 46, - 47 - ], - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 14 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 47, - 50 - ], - "loc": { - "start": { - "line": 4, - "column": 14 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 50, - 51 - ], - "loc": { - "start": { - "line": 4, - "column": 17 - }, - "end": { - "line": 4, - "column": 18 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 51, - 52 - ], - "loc": { - "start": { - "line": 4, - "column": 18 - }, - "end": { - "line": 4, - "column": 19 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 52, - 53 - ], - "loc": { - "start": { - "line": 4, - "column": 19 - }, - "end": { - "line": 4, - "column": 20 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 58, - 59 - ], - "loc": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 60, - 61 - ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 61, - 62 - ], - "loc": { - "start": { - "line": 6, - "column": 1 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.src.js b/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.src.js deleted file mode 100644 index babe3fee..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-property-call-in-object-literal.src.js +++ /dev/null @@ -1,6 +0,0 @@ -var o = { - - foo: function() { - super.foo(); - } -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-property-call.result.js b/tests/fixtures/ecma-features/superInFunctions/super-property-call.result.js deleted file mode 100644 index d8bcce32..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-property-call.result.js +++ /dev/null @@ -1,418 +0,0 @@ -module.exports = { - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Super", - "range": [ - 21, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 9 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "range": [ - 27, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - "range": [ - 21, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - "arguments": [], - "range": [ - 21, - 32 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 15 - } - } - }, - "range": [ - 21, - 33 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 16 - } - } - } - ], - "range": [ - 15, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 35 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - { - "type": "EmptyStatement", - "range": [ - 35, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ], - "sourceType": "script", - "range": [ - 0, - 36 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 2 - } - }, - "tokens": [ - { - "type": "Keyword", - "value": "function", - "range": [ - 0, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 12, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 13, - 14 - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 14 - } - } - }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 16 - } - } - }, - { - "type": "Keyword", - "value": "super", - "range": [ - 21, - 26 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 9 - } - } - }, - { - "type": "Punctuator", - "value": ".", - "range": [ - 26, - 27 - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 10 - } - } - }, - { - "type": "Identifier", - "value": "foo", - "range": [ - 27, - 30 - ], - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - { - "type": "Punctuator", - "value": "(", - "range": [ - 30, - 31 - ], - "loc": { - "start": { - "line": 2, - "column": 13 - }, - "end": { - "line": 2, - "column": 14 - } - } - }, - { - "type": "Punctuator", - "value": ")", - "range": [ - 31, - 32 - ], - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 2, - "column": 15 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 32, - 33 - ], - "loc": { - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 16 - } - } - }, - { - "type": "Punctuator", - "value": "}", - "range": [ - 34, - 35 - ], - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - { - "type": "Punctuator", - "value": ";", - "range": [ - 35, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ] -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/superInFunctions/super-property-call.src.js b/tests/fixtures/ecma-features/superInFunctions/super-property-call.src.js deleted file mode 100644 index eb670388..00000000 --- a/tests/fixtures/ecma-features/superInFunctions/super-property-call.src.js +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - super.foo(); -}; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/deeply-nested.result.js b/tests/fixtures/ecma-features/templateStrings/deeply-nested.result.js index 6662b0c1..d437f986 100644 --- a/tests/fixtures/ecma-features/templateStrings/deeply-nested.result.js +++ b/tests/fixtures/ecma-features/templateStrings/deeply-nested.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 0, + 45 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 0, + 45 + ], "expression": { "type": "TaggedTemplateExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], "tag": { "type": "Identifier", - "name": "raw", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,123 +58,83 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "raw" }, "quasi": { "type": "TemplateLiteral", - "quasis": [ + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 3, + 44 + ], + "expressions": [ { - "type": "TemplateElement", - "value": { - "raw": "hello ", - "cooked": "hello " - }, - "tail": false, - "range": [ - 3, - 12 - ], + "type": "TemplateLiteral", "loc": { "start": { "line": 1, - "column": 3 + "column": 12 }, "end": { "line": 1, - "column": 12 + "column": 42 } - } - }, - { - "type": "TemplateElement", - "value": { - "raw": "", - "cooked": "" }, - "tail": true, "range": [ - 42, - 44 + 12, + 42 ], - "loc": { - "start": { - "line": 1, - "column": 42 - }, - "end": { - "line": 1, - "column": 44 - } - } - } - ], - "expressions": [ - { - "type": "TemplateLiteral", - "quasis": [ + "expressions": [ { - "type": "TemplateElement", - "value": { - "raw": "nested ", - "cooked": "nested " - }, - "tail": false, - "range": [ - 12, - 22 - ], + "type": "BinaryExpression", "loc": { "start": { "line": 1, - "column": 12 + "column": 22 }, "end": { "line": 1, - "column": 22 + "column": 35 } - } - }, - { - "type": "TemplateElement", - "value": { - "raw": " blah", - "cooked": " blah" }, - "tail": true, "range": [ - 35, - 42 + 22, + 35 ], - "loc": { - "start": { - "line": 1, - "column": 35 - }, - "end": { - "line": 1, - "column": 42 - } - } - } - ], - "expressions": [ - { - "type": "BinaryExpression", - "operator": "+", "left": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 22, + 30 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "deeply", - "cooked": "deeply" - }, - "tail": true, - "range": [ - 22, - 30 - ], "loc": { "start": { "line": 1, @@ -147,32 +144,22 @@ module.exports = { "line": 1, "column": 30 } - } - } - ], - "expressions": [], - "range": [ - 22, - 30 - ], - "loc": { - "start": { - "line": 1, - "column": 22 - }, - "end": { - "line": 1, - "column": 30 + }, + "range": [ + 22, + 30 + ], + "value": { + "raw": "deeply", + "cooked": "deeply" + }, + "tail": true } - } + ] }, + "operator": "+", "right": { "type": "ObjectExpression", - "properties": [], - "range": [ - 33, - 35 - ], "loc": { "start": { "line": 1, @@ -182,109 +169,118 @@ module.exports = { "line": 1, "column": 35 } + }, + "range": [ + 33, + 35 + ], + "properties": [] + } + } + ], + "quasis": [ + { + "type": "TemplateElement", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 22 } }, "range": [ - 22, - 35 + 12, + 22 ], + "value": { + "raw": "nested ", + "cooked": "nested " + }, + "tail": false + }, + { + "type": "TemplateElement", "loc": { "start": { "line": 1, - "column": 22 + "column": 35 }, "end": { "line": 1, - "column": 35 + "column": 42 } - } + }, + "range": [ + 35, + 42 + ], + "value": { + "raw": " blah", + "cooked": " blah" + }, + "tail": true } - ], + ] + } + ], + "quasis": [ + { + "type": "TemplateElement", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, "range": [ - 12, - 42 + 3, + 12 ], + "value": { + "raw": "hello ", + "cooked": "hello " + }, + "tail": false + }, + { + "type": "TemplateElement", "loc": { "start": { "line": 1, - "column": 12 + "column": 42 }, "end": { "line": 1, - "column": 42 + "column": 44 } - } - } - ], - "range": [ - 3, - 44 - ], - "loc": { - "start": { - "line": 1, - "column": 3 - }, - "end": { - "line": 1, - "column": 44 + }, + "range": [ + 42, + 44 + ], + "value": { + "raw": "", + "cooked": "" + }, + "tail": true } - } - }, - "range": [ - 0, - 44 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 44 - } - } - }, - "range": [ - 0, - 45 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 45 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 45 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 45 - } - }, "tokens": [ { "type": "Identifier", "value": "raw", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -294,15 +290,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Template", "value": "`hello ${", - "range": [ - 3, - 12 - ], "loc": { "start": { "line": 1, @@ -312,15 +308,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 3, + 12 + ] }, { "type": "Template", "value": "`nested ${", - "range": [ - 12, - 22 - ], "loc": { "start": { "line": 1, @@ -330,15 +326,15 @@ module.exports = { "line": 1, "column": 22 } - } + }, + "range": [ + 12, + 22 + ] }, { "type": "Template", "value": "`deeply`", - "range": [ - 22, - 30 - ], "loc": { "start": { "line": 1, @@ -348,15 +344,15 @@ module.exports = { "line": 1, "column": 30 } - } + }, + "range": [ + 22, + 30 + ] }, { "type": "Punctuator", "value": "+", - "range": [ - 31, - 32 - ], "loc": { "start": { "line": 1, @@ -366,15 +362,15 @@ module.exports = { "line": 1, "column": 32 } - } + }, + "range": [ + 31, + 32 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 33, - 34 - ], "loc": { "start": { "line": 1, @@ -384,15 +380,15 @@ module.exports = { "line": 1, "column": 34 } - } + }, + "range": [ + 33, + 34 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 34, - 35 - ], "loc": { "start": { "line": 1, @@ -402,15 +398,15 @@ module.exports = { "line": 1, "column": 35 } - } + }, + "range": [ + 34, + 35 + ] }, { "type": "Template", "value": "} blah`", - "range": [ - 35, - 42 - ], "loc": { "start": { "line": 1, @@ -420,15 +416,15 @@ module.exports = { "line": 1, "column": 42 } - } + }, + "range": [ + 35, + 42 + ] }, { "type": "Template", "value": "}`", - "range": [ - 42, - 44 - ], "loc": { "start": { "line": 1, @@ -438,15 +434,15 @@ module.exports = { "line": 1, "column": 44 } - } + }, + "range": [ + 42, + 44 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 44, - 45 - ], "loc": { "start": { "line": 1, @@ -456,7 +452,11 @@ module.exports = { "line": 1, "column": 45 } - } + }, + "range": [ + 44, + 45 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/escape-characters.result.js b/tests/fixtures/ecma-features/templateStrings/escape-characters.result.js index 24f86be9..451d26cd 100644 --- a/tests/fixtures/ecma-features/templateStrings/escape-characters.result.js +++ b/tests/fixtures/ecma-features/templateStrings/escape-characters.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 0, + 40 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 0, + 40 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 4, + 39 + ], "id": { "type": "Identifier", - "name": "ts", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -22,22 +59,33 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ], + "name": "ts" }, "init": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 9, + 39 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "\\\\n\\\\r\\\\b\\\\v\\\\t\\\\f\\\\\\n\\\\\\r\\n", - "cooked": "\\n\\r\\b\\v\\t\\f\\\n\\\r\n" - }, - "tail": true, - "range": [ - 9, - 39 - ], "loc": { "start": { "line": 1, @@ -47,81 +95,29 @@ module.exports = { "line": 1, "column": 39 } - } - } - ], - "expressions": [], - "range": [ - 9, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 39 + }, + "range": [ + 9, + 39 + ], + "value": { + "raw": "\\\\n\\\\r\\\\b\\\\v\\\\t\\\\f\\\\\\n\\\\\\r\\n", + "cooked": "\\n\\r\\b\\v\\t\\f\\\n\\\r\n" + }, + "tail": true } - } - }, - "range": [ - 4, - 39 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 39 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 40 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -131,15 +127,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "ts", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -149,15 +145,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -167,15 +163,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Template", "value": "`\\\\n\\\\r\\\\b\\\\v\\\\t\\\\f\\\\\\n\\\\\\r\\n`", - "range": [ - 9, - 39 - ], "loc": { "start": { "line": 1, @@ -185,15 +181,15 @@ module.exports = { "line": 1, "column": 39 } - } + }, + "range": [ + 9, + 39 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 1, @@ -203,7 +199,11 @@ module.exports = { "line": 1, "column": 40 } - } + }, + "range": [ + 39, + 40 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/expressions.result.js b/tests/fixtures/ecma-features/templateStrings/expressions.result.js index dffe6248..10610238 100644 --- a/tests/fixtures/ecma-features/templateStrings/expressions.result.js +++ b/tests/fixtures/ecma-features/templateStrings/expressions.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "range": [ + 0, + 59 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 4, + 9 + ], "id": { "type": "Identifier", - "name": "a", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -22,16 +59,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ], + "name": "a" }, "init": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -41,52 +77,53 @@ module.exports = { "line": 1, "column": 9 } - } - }, - "range": [ - 4, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 4 }, - "end": { - "line": 1, - "column": 9 - } + "range": [ + 8, + 9 + ], + "value": 5, + "raw": "5" } } ], - "kind": "var", - "range": [ - 0, - 10 - ], + "kind": "var" + }, + { + "type": "VariableDeclaration", "loc": { "start": { - "line": 1, + "line": 2, "column": 0 }, "end": { - "line": 1, - "column": 10 + "line": 2, + "column": 15 } - } - }, - { - "type": "VariableDeclaration", + }, + "range": [ + 11, + 26 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 15, + 25 + ], "id": { "type": "Identifier", - "name": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -96,16 +133,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 15, + 16 + ], + "name": "b" }, "init": { "type": "Literal", - "value": "Fred", - "raw": "'Fred'", - "range": [ - 19, - 25 - ], "loc": { "start": { "line": 2, @@ -115,141 +151,87 @@ module.exports = { "line": 2, "column": 14 } - } - }, - "range": [ - 15, - 25 - ], - "loc": { - "start": { - "line": 2, - "column": 4 }, - "end": { - "line": 2, - "column": 14 - } + "range": [ + 19, + 25 + ], + "value": "Fred", + "raw": "'Fred'" } } ], - "kind": "var", - "range": [ - 11, - 26 - ], + "kind": "var" + }, + { + "type": "ExpressionStatement", "loc": { "start": { - "line": 2, + "line": 4, "column": 0 }, "end": { - "line": 2, - "column": 15 + "line": 4, + "column": 31 } - } - }, - { - "type": "ExpressionStatement", + }, + "range": [ + 28, + 59 + ], "expression": { "type": "TemplateLiteral", - "quasis": [ + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "range": [ + 28, + 58 + ], + "expressions": [ { - "type": "TemplateElement", - "value": { - "raw": "Hello ", - "cooked": "Hello " - }, - "tail": false, - "range": [ - 28, - 37 - ], + "type": "Identifier", "loc": { "start": { "line": 4, - "column": 0 + "column": 9 }, "end": { "line": 4, - "column": 9 + "column": 10 } - } - }, - { - "type": "TemplateElement", - "value": { - "raw": ". a + 5 = ", - "cooked": ". a + 5 = " }, - "tail": false, "range": [ - 38, - 51 + 37, + 38 ], - "loc": { - "start": { - "line": 4, - "column": 10 - }, - "end": { - "line": 4, - "column": 23 - } - } + "name": "b" }, { - "type": "TemplateElement", - "value": { - "raw": "", - "cooked": "" - }, - "tail": true, - "range": [ - 56, - 58 - ], + "type": "BinaryExpression", "loc": { "start": { "line": 4, - "column": 28 + "column": 23 }, "end": { "line": 4, - "column": 30 + "column": 28 } - } - } - ], - "expressions": [ - { - "type": "Identifier", - "name": "b", + }, "range": [ - 37, - 38 + 51, + 56 ], - "loc": { - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - } - }, - { - "type": "BinaryExpression", - "operator": "+", "left": { "type": "Identifier", - "name": "a", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 4, @@ -259,16 +241,16 @@ module.exports = { "line": 4, "column": 24 } - } + }, + "range": [ + 51, + 52 + ], + "name": "a" }, + "operator": "+", "right": { "type": "Literal", - "value": 5, - "raw": "5", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 4, @@ -278,78 +260,92 @@ module.exports = { "line": 4, "column": 28 } + }, + "range": [ + 55, + 56 + ], + "value": 5, + "raw": "5" + } + } + ], + "quasis": [ + { + "type": "TemplateElement", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 } }, "range": [ - 51, - 56 + 28, + 37 ], + "value": { + "raw": "Hello ", + "cooked": "Hello " + }, + "tail": false + }, + { + "type": "TemplateElement", "loc": { "start": { "line": 4, - "column": 23 + "column": 10 }, "end": { "line": 4, - "column": 28 + "column": 23 } - } - } - ], - "range": [ - 28, - 58 - ], - "loc": { - "start": { - "line": 4, - "column": 0 + }, + "range": [ + 38, + 51 + ], + "value": { + "raw": ". a + 5 = ", + "cooked": ". a + 5 = " + }, + "tail": false }, - "end": { - "line": 4, - "column": 30 + { + "type": "TemplateElement", + "loc": { + "start": { + "line": 4, + "column": 28 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "range": [ + 56, + 58 + ], + "value": { + "raw": "", + "cooked": "" + }, + "tail": true } - } - }, - "range": [ - 28, - 59 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 31 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 59 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 31 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -359,15 +355,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -377,15 +373,15 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 6, - 7 - ], "loc": { "start": { "line": 1, @@ -395,15 +391,15 @@ module.exports = { "line": 1, "column": 7 } - } + }, + "range": [ + 6, + 7 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -413,15 +409,15 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 9, - 10 - ], "loc": { "start": { "line": 1, @@ -431,15 +427,15 @@ module.exports = { "line": 1, "column": 10 } - } + }, + "range": [ + 9, + 10 + ] }, { "type": "Keyword", "value": "var", - "range": [ - 11, - 14 - ], "loc": { "start": { "line": 2, @@ -449,15 +445,15 @@ module.exports = { "line": 2, "column": 3 } - } + }, + "range": [ + 11, + 14 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 2, @@ -467,15 +463,15 @@ module.exports = { "line": 2, "column": 5 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 17, - 18 - ], "loc": { "start": { "line": 2, @@ -485,15 +481,15 @@ module.exports = { "line": 2, "column": 7 } - } + }, + "range": [ + 17, + 18 + ] }, { "type": "String", "value": "'Fred'", - "range": [ - 19, - 25 - ], "loc": { "start": { "line": 2, @@ -503,15 +499,15 @@ module.exports = { "line": 2, "column": 14 } - } + }, + "range": [ + 19, + 25 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 2, @@ -521,15 +517,15 @@ module.exports = { "line": 2, "column": 15 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Template", "value": "`Hello ${", - "range": [ - 28, - 37 - ], "loc": { "start": { "line": 4, @@ -539,15 +535,15 @@ module.exports = { "line": 4, "column": 9 } - } + }, + "range": [ + 28, + 37 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 37, - 38 - ], "loc": { "start": { "line": 4, @@ -557,15 +553,15 @@ module.exports = { "line": 4, "column": 10 } - } + }, + "range": [ + 37, + 38 + ] }, { "type": "Template", "value": "}. a + 5 = ${", - "range": [ - 38, - 51 - ], "loc": { "start": { "line": 4, @@ -575,15 +571,15 @@ module.exports = { "line": 4, "column": 23 } - } + }, + "range": [ + 38, + 51 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 51, - 52 - ], "loc": { "start": { "line": 4, @@ -593,15 +589,15 @@ module.exports = { "line": 4, "column": 24 } - } + }, + "range": [ + 51, + 52 + ] }, { "type": "Punctuator", "value": "+", - "range": [ - 53, - 54 - ], "loc": { "start": { "line": 4, @@ -611,15 +607,15 @@ module.exports = { "line": 4, "column": 26 } - } + }, + "range": [ + 53, + 54 + ] }, { "type": "Numeric", "value": "5", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 4, @@ -629,15 +625,15 @@ module.exports = { "line": 4, "column": 28 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Template", "value": "}`", - "range": [ - 56, - 58 - ], "loc": { "start": { "line": 4, @@ -647,15 +643,15 @@ module.exports = { "line": 4, "column": 30 } - } + }, + "range": [ + 56, + 58 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 58, - 59 - ], "loc": { "start": { "line": 4, @@ -665,7 +661,11 @@ module.exports = { "line": 4, "column": 31 } - } + }, + "range": [ + 58, + 59 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/multi-line-template-string.result.js b/tests/fixtures/ecma-features/templateStrings/multi-line-template-string.result.js index 467d9d83..9787eece 100644 --- a/tests/fixtures/ecma-features/templateStrings/multi-line-template-string.result.js +++ b/tests/fixtures/ecma-features/templateStrings/multi-line-template-string.result.js @@ -1,22 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 0, + 111 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 0, + 111 + ], "expression": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 0, + 110 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "The last man on Earth\n sat alone in a room.\n There was\n a knock\n on the\n door...", - "cooked": "The last man on Earth\n sat alone in a room.\n There was\n a knock\n on the\n door..." - }, - "tail": true, - "range": [ - 0, - 110 - ], "loc": { "start": { "line": 1, @@ -26,64 +60,26 @@ module.exports = { "line": 6, "column": 12 } - } - } - ], - "expressions": [], - "range": [ - 0, - 110 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 12 + }, + "range": [ + 0, + 110 + ], + "value": { + "raw": "The last man on Earth\n sat alone in a room.\n There was\n a knock\n on the\n door...", + "cooked": "The last man on Earth\n sat alone in a room.\n There was\n a knock\n on the\n door..." + }, + "tail": true } - } - }, - "range": [ - 0, - 111 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 13 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 111 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 13 - } - }, "tokens": [ { "type": "Template", "value": "`The last man on Earth\n sat alone in a room.\n There was\n a knock\n on the\n door...`", - "range": [ - 0, - 110 - ], "loc": { "start": { "line": 1, @@ -93,15 +89,15 @@ module.exports = { "line": 6, "column": 12 } - } + }, + "range": [ + 0, + 110 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 110, - 111 - ], "loc": { "start": { "line": 6, @@ -111,7 +107,11 @@ module.exports = { "line": 6, "column": 13 } - } + }, + "range": [ + 110, + 111 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/octal-literal.result.js b/tests/fixtures/ecma-features/templateStrings/octal-literal.result.js index 25dc23f6..40993c99 100644 --- a/tests/fixtures/ecma-features/templateStrings/octal-literal.result.js +++ b/tests/fixtures/ecma-features/templateStrings/octal-literal.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 4, + "index": 1, "lineNumber": 1, - "column": 5, - "description": "Octal literals are not allowed in template strings." + "column": 2, + "message": "Octal literal in strict mode" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/simple-template-string.result.js b/tests/fixtures/ecma-features/templateStrings/simple-template-string.result.js index 4cbb6d07..ea4f6ec1 100644 --- a/tests/fixtures/ecma-features/templateStrings/simple-template-string.result.js +++ b/tests/fixtures/ecma-features/templateStrings/simple-template-string.result.js @@ -1,22 +1,56 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], "expression": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 0, + 4 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "42", - "cooked": "42" - }, - "tail": true, - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -26,64 +60,26 @@ module.exports = { "line": 1, "column": 4 } - } - } - ], - "expressions": [], - "range": [ - 0, - 4 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 4 + }, + "range": [ + 0, + 4 + ], + "value": { + "raw": "42", + "cooked": "42" + }, + "tail": true } - } - }, - "range": [ - 0, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 5 - } + ] } } ], "sourceType": "script", - "range": [ - 0, - 5 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 5 - } - }, "tokens": [ { "type": "Template", "value": "`42`", - "range": [ - 0, - 4 - ], "loc": { "start": { "line": 1, @@ -93,15 +89,15 @@ module.exports = { "line": 1, "column": 4 } - } + }, + "range": [ + 0, + 4 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 4, - 5 - ], "loc": { "start": { "line": 1, @@ -111,7 +107,11 @@ module.exports = { "line": 1, "column": 5 } - } + }, + "range": [ + 4, + 5 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/single-dollar-sign.result.js b/tests/fixtures/ecma-features/templateStrings/single-dollar-sign.result.js index fc1239bb..d574fb3d 100644 --- a/tests/fixtures/ecma-features/templateStrings/single-dollar-sign.result.js +++ b/tests/fixtures/ecma-features/templateStrings/single-dollar-sign.result.js @@ -1,18 +1,55 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "body": [ { "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], "declarations": [ { "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], "id": { "type": "Identifier", - "name": "ts", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -22,22 +59,33 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ], + "name": "ts" }, "init": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "$", - "cooked": "$" - }, - "tail": true, - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -47,81 +95,29 @@ module.exports = { "line": 1, "column": 12 } - } - } - ], - "expressions": [], - "range": [ - 9, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 12 + }, + "range": [ + 9, + 12 + ], + "value": { + "raw": "$", + "cooked": "$" + }, + "tail": true } - } - }, - "range": [ - 4, - 12 - ], - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 12 - } + ] } } ], - "kind": "var", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - } + "kind": "var" } ], "sourceType": "script", - "range": [ - 0, - 13 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, "tokens": [ { "type": "Keyword", "value": "var", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -131,15 +127,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Identifier", "value": "ts", - "range": [ - 4, - 6 - ], "loc": { "start": { "line": 1, @@ -149,15 +145,15 @@ module.exports = { "line": 1, "column": 6 } - } + }, + "range": [ + 4, + 6 + ] }, { "type": "Punctuator", "value": "=", - "range": [ - 7, - 8 - ], "loc": { "start": { "line": 1, @@ -167,15 +163,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 7, + 8 + ] }, { "type": "Template", "value": "`$`", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -185,15 +181,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -203,7 +199,11 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/tagged-no-placeholders.result.js b/tests/fixtures/ecma-features/templateStrings/tagged-no-placeholders.result.js index c2852e26..ee2f2ec3 100644 --- a/tests/fixtures/ecma-features/templateStrings/tagged-no-placeholders.result.js +++ b/tests/fixtures/ecma-features/templateStrings/tagged-no-placeholders.result.js @@ -1,17 +1,54 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 0, + 9 + ], "expression": { "type": "TaggedTemplateExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 0, + 8 + ], "tag": { "type": "Identifier", - "name": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -21,22 +58,33 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ], + "name": "foo" }, "quasi": { "type": "TemplateLiteral", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 3, + 8 + ], + "expressions": [], "quasis": [ { "type": "TemplateElement", - "value": { - "raw": "foo", - "cooked": "foo" - }, - "tail": true, - "range": [ - 3, - 8 - ], "loc": { "start": { "line": 1, @@ -46,79 +94,27 @@ module.exports = { "line": 1, "column": 8 } - } - } - ], - "expressions": [], - "range": [ - 3, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 3 - }, - "end": { - "line": 1, - "column": 8 + }, + "range": [ + 3, + 8 + ], + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true } - } - }, - "range": [ - 0, - 8 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 9 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, "tokens": [ { "type": "Identifier", "value": "foo", - "range": [ - 0, - 3 - ], "loc": { "start": { "line": 1, @@ -128,15 +124,15 @@ module.exports = { "line": 1, "column": 3 } - } + }, + "range": [ + 0, + 3 + ] }, { "type": "Template", "value": "`foo`", - "range": [ - 3, - 8 - ], "loc": { "start": { "line": 1, @@ -146,15 +142,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 3, + 8 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 8, - 9 - ], "loc": { "start": { "line": 1, @@ -164,7 +160,11 @@ module.exports = { "line": 1, "column": 9 } - } + }, + "range": [ + 8, + 9 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/templateStrings/tagged-template-string.result.js b/tests/fixtures/ecma-features/templateStrings/tagged-template-string.result.js index 12b2faac..fc2d508f 100644 --- a/tests/fixtures/ecma-features/templateStrings/tagged-template-string.result.js +++ b/tests/fixtures/ecma-features/templateStrings/tagged-template-string.result.js @@ -1,15 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "range": [ + 0, + 76 + ], "body": [ { "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 43 + ], "id": { "type": "Identifier", - "name": "tag", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -19,26 +42,83 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ], + "name": "tag" }, + "generator": false, + "expression": false, "params": [], "body": { "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 15, + 43 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "range": [ + 18, + 41 + ], "expression": { "type": "CallExpression", + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 18, + 40 + ], "callee": { "type": "MemberExpression", - "computed": false, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 18, + 29 + ], "object": { "type": "Identifier", - "name": "console", - "range": [ - 18, - 25 - ], "loc": { "start": { "line": 2, @@ -48,15 +128,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 18, + 25 + ], + "name": "console" }, "property": { "type": "Identifier", - "name": "log", - "range": [ - 26, - 29 - ], "loc": { "start": { "line": 2, @@ -66,31 +146,18 @@ module.exports = { "line": 2, "column": 12 } - } - }, - "range": [ - 18, - 29 - ], - "loc": { - "start": { - "line": 2, - "column": 1 }, - "end": { - "line": 2, - "column": 12 - } - } + "range": [ + 26, + 29 + ], + "name": "log" + }, + "computed": false }, "arguments": [ { "type": "Identifier", - "name": "arguments", - "range": [ - 30, - 39 - ], "loc": { "start": { "line": 2, @@ -100,83 +167,53 @@ module.exports = { "line": 2, "column": 22 } - } - } - ], - "range": [ - 18, - 40 - ], - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 23 + }, + "range": [ + 30, + 39 + ], + "name": "arguments" } - } - }, - "range": [ - 18, - 41 - ], - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 24 - } + ] } } - ], - "range": [ - 15, - 43 - ], - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 3, - "column": 1 - } - } - }, - "generator": false, - "expression": false, - "range": [ - 0, - 43 - ], + ] + } + }, + { + "type": "ExpressionStatement", "loc": { "start": { - "line": 1, + "line": 4, "column": 0 }, "end": { - "line": 3, - "column": 1 + "line": 4, + "column": 32 } - } - }, - { - "type": "ExpressionStatement", + }, + "range": [ + 44, + 76 + ], "expression": { "type": "TaggedTemplateExpression", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "range": [ + 44, + 75 + ], "tag": { "type": "Identifier", - "name": "tag", - "range": [ - 44, - 47 - ], "loc": { "start": { "line": 4, @@ -186,185 +223,144 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 44, + 47 + ], + "name": "tag" }, "quasi": { "type": "TemplateLiteral", - "quasis": [ + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "range": [ + 47, + 75 + ], + "expressions": [ { - "type": "TemplateElement", - "value": { - "raw": "a is ", - "cooked": "a is " - }, - "tail": false, - "range": [ - 47, - 55 - ], + "type": "Identifier", "loc": { "start": { "line": 4, - "column": 3 + "column": 11 }, "end": { "line": 4, - "column": 11 + "column": 12 } - } - }, - { - "type": "TemplateElement", - "value": { - "raw": " while b is ", - "cooked": " while b is " }, - "tail": false, "range": [ - 56, - 71 + 55, + 56 ], + "name": "a" + }, + { + "type": "Identifier", "loc": { "start": { "line": 4, - "column": 12 + "column": 27 }, "end": { "line": 4, - "column": 27 + "column": 28 } - } - }, - { - "type": "TemplateElement", - "value": { - "raw": ".", - "cooked": "." }, - "tail": true, "range": [ - 72, - 75 + 71, + 72 ], + "name": "b" + } + ], + "quasis": [ + { + "type": "TemplateElement", "loc": { "start": { "line": 4, - "column": 28 + "column": 3 }, "end": { "line": 4, - "column": 31 + "column": 11 } - } - } - ], - "expressions": [ - { - "type": "Identifier", - "name": "a", + }, "range": [ - 55, - 56 + 47, + 55 ], + "value": { + "raw": "a is ", + "cooked": "a is " + }, + "tail": false + }, + { + "type": "TemplateElement", "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 12 + "column": 27 } - } - }, - { - "type": "Identifier", - "name": "b", + }, "range": [ - 71, - 72 + 56, + 71 ], + "value": { + "raw": " while b is ", + "cooked": " while b is " + }, + "tail": false + }, + { + "type": "TemplateElement", "loc": { "start": { "line": 4, - "column": 27 + "column": 28 }, "end": { "line": 4, - "column": 28 + "column": 31 } - } - } - ], - "range": [ - 47, - 75 - ], - "loc": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 31 + }, + "range": [ + 72, + 75 + ], + "value": { + "raw": ".", + "cooked": "." + }, + "tail": true } - } - }, - "range": [ - 44, - 75 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 31 - } - } - }, - "range": [ - 44, - 76 - ], - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 32 + ] } } } ], "sourceType": "script", - "range": [ - 0, - 76 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 32 - } - }, "tokens": [ { "type": "Keyword", "value": "function", - "range": [ - 0, - 8 - ], "loc": { "start": { "line": 1, @@ -374,15 +370,15 @@ module.exports = { "line": 1, "column": 8 } - } + }, + "range": [ + 0, + 8 + ] }, { "type": "Identifier", "value": "tag", - "range": [ - 9, - 12 - ], "loc": { "start": { "line": 1, @@ -392,15 +388,15 @@ module.exports = { "line": 1, "column": 12 } - } + }, + "range": [ + 9, + 12 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 12, - 13 - ], "loc": { "start": { "line": 1, @@ -410,15 +406,15 @@ module.exports = { "line": 1, "column": 13 } - } + }, + "range": [ + 12, + 13 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 13, - 14 - ], "loc": { "start": { "line": 1, @@ -428,15 +424,15 @@ module.exports = { "line": 1, "column": 14 } - } + }, + "range": [ + 13, + 14 + ] }, { "type": "Punctuator", "value": "{", - "range": [ - 15, - 16 - ], "loc": { "start": { "line": 1, @@ -446,15 +442,15 @@ module.exports = { "line": 1, "column": 16 } - } + }, + "range": [ + 15, + 16 + ] }, { "type": "Identifier", "value": "console", - "range": [ - 18, - 25 - ], "loc": { "start": { "line": 2, @@ -464,15 +460,15 @@ module.exports = { "line": 2, "column": 8 } - } + }, + "range": [ + 18, + 25 + ] }, { "type": "Punctuator", "value": ".", - "range": [ - 25, - 26 - ], "loc": { "start": { "line": 2, @@ -482,15 +478,15 @@ module.exports = { "line": 2, "column": 9 } - } + }, + "range": [ + 25, + 26 + ] }, { "type": "Identifier", "value": "log", - "range": [ - 26, - 29 - ], "loc": { "start": { "line": 2, @@ -500,15 +496,15 @@ module.exports = { "line": 2, "column": 12 } - } + }, + "range": [ + 26, + 29 + ] }, { "type": "Punctuator", "value": "(", - "range": [ - 29, - 30 - ], "loc": { "start": { "line": 2, @@ -518,15 +514,15 @@ module.exports = { "line": 2, "column": 13 } - } + }, + "range": [ + 29, + 30 + ] }, { "type": "Identifier", "value": "arguments", - "range": [ - 30, - 39 - ], "loc": { "start": { "line": 2, @@ -536,15 +532,15 @@ module.exports = { "line": 2, "column": 22 } - } + }, + "range": [ + 30, + 39 + ] }, { "type": "Punctuator", "value": ")", - "range": [ - 39, - 40 - ], "loc": { "start": { "line": 2, @@ -554,15 +550,15 @@ module.exports = { "line": 2, "column": 23 } - } + }, + "range": [ + 39, + 40 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 40, - 41 - ], "loc": { "start": { "line": 2, @@ -572,15 +568,15 @@ module.exports = { "line": 2, "column": 24 } - } + }, + "range": [ + 40, + 41 + ] }, { "type": "Punctuator", "value": "}", - "range": [ - 42, - 43 - ], "loc": { "start": { "line": 3, @@ -590,15 +586,15 @@ module.exports = { "line": 3, "column": 1 } - } + }, + "range": [ + 42, + 43 + ] }, { "type": "Identifier", "value": "tag", - "range": [ - 44, - 47 - ], "loc": { "start": { "line": 4, @@ -608,15 +604,15 @@ module.exports = { "line": 4, "column": 3 } - } + }, + "range": [ + 44, + 47 + ] }, { "type": "Template", "value": "`a is ${", - "range": [ - 47, - 55 - ], "loc": { "start": { "line": 4, @@ -626,15 +622,15 @@ module.exports = { "line": 4, "column": 11 } - } + }, + "range": [ + 47, + 55 + ] }, { "type": "Identifier", "value": "a", - "range": [ - 55, - 56 - ], "loc": { "start": { "line": 4, @@ -644,15 +640,15 @@ module.exports = { "line": 4, "column": 12 } - } + }, + "range": [ + 55, + 56 + ] }, { "type": "Template", "value": "} while b is ${", - "range": [ - 56, - 71 - ], "loc": { "start": { "line": 4, @@ -662,15 +658,15 @@ module.exports = { "line": 4, "column": 27 } - } + }, + "range": [ + 56, + 71 + ] }, { "type": "Identifier", "value": "b", - "range": [ - 71, - 72 - ], "loc": { "start": { "line": 4, @@ -680,15 +676,15 @@ module.exports = { "line": 4, "column": 28 } - } + }, + "range": [ + 71, + 72 + ] }, { "type": "Template", "value": "}.`", - "range": [ - 72, - 75 - ], "loc": { "start": { "line": 4, @@ -698,15 +694,15 @@ module.exports = { "line": 4, "column": 31 } - } + }, + "range": [ + 72, + 75 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 75, - 76 - ], "loc": { "start": { "line": 4, @@ -716,7 +712,11 @@ module.exports = { "line": 4, "column": 32 } - } + }, + "range": [ + 75, + 76 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/unicodeCodePointEscapes/basic-string-literal.result.js b/tests/fixtures/ecma-features/unicodeCodePointEscapes/basic-string-literal.result.js index bb73fc4e..e7d4cba5 100644 --- a/tests/fixtures/ecma-features/unicodeCodePointEscapes/basic-string-literal.result.js +++ b/tests/fixtures/ecma-features/unicodeCodePointEscapes/basic-string-literal.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], "expression": { "type": "Literal", - "value": "煎茶", - "raw": "\"\\u{714E}\\u{8336}\"", - "range": [ - 0, - 18 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 18 } - } - }, - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 19 - } + "range": [ + 0, + 18 + ], + "value": "煎茶", + "raw": "\"\\u{714E}\\u{8336}\"" } } ], "sourceType": "script", - "range": [ - 0, - 19 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, "tokens": [ { "type": "String", "value": "\"\\u{714E}\\u{8336}\"", - "range": [ - 0, - 18 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 18 } - } + }, + "range": [ + 0, + 18 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 18, - 19 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 19 } - } + }, + "range": [ + 18, + 19 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/unicodeCodePointEscapes/complex-string-literal.result.js b/tests/fixtures/ecma-features/unicodeCodePointEscapes/complex-string-literal.result.js index 0f76fbb8..a83ca4e1 100644 --- a/tests/fixtures/ecma-features/unicodeCodePointEscapes/complex-string-literal.result.js +++ b/tests/fixtures/ecma-features/unicodeCodePointEscapes/complex-string-literal.result.js @@ -1,16 +1,38 @@ module.exports = { "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "body": [ { "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], "expression": { "type": "Literal", - "value": "𠮷􏿿\u0001", - "raw": "\"\\u{20BB7}\\u{10FFFF}\\u{1}\"", - "range": [ - 0, - 26 - ], "loc": { "start": { "line": 1, @@ -20,47 +42,21 @@ module.exports = { "line": 1, "column": 26 } - } - }, - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 }, - "end": { - "line": 1, - "column": 27 - } + "range": [ + 0, + 26 + ], + "value": "𠮷􏿿\u0001", + "raw": "\"\\u{20BB7}\\u{10FFFF}\\u{1}\"" } } ], "sourceType": "script", - "range": [ - 0, - 27 - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, "tokens": [ { "type": "String", "value": "\"\\u{20BB7}\\u{10FFFF}\\u{1}\"", - "range": [ - 0, - 26 - ], "loc": { "start": { "line": 1, @@ -70,15 +66,15 @@ module.exports = { "line": 1, "column": 26 } - } + }, + "range": [ + 0, + 26 + ] }, { "type": "Punctuator", "value": ";", - "range": [ - 26, - 27 - ], "loc": { "start": { "line": 1, @@ -88,7 +84,11 @@ module.exports = { "line": 1, "column": 27 } - } + }, + "range": [ + 26, + 27 + ] } ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-empty-escape.result.js b/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-empty-escape.result.js index 6081eafe..7ddaf935 100644 --- a/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-empty-escape.result.js +++ b/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-empty-escape.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 4, "lineNumber": 1, "column": 5, - "description": "Unexpected token ILLEGAL" + "message": "Bad character escape sequence" }; \ No newline at end of file diff --git a/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-too-large-escape.result.js b/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-too-large-escape.result.js index 0c1c4871..c8a3a66d 100644 --- a/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-too-large-escape.result.js +++ b/tests/fixtures/ecma-features/unicodeCodePointEscapes/invalid-too-large-escape.result.js @@ -1,6 +1,6 @@ module.exports = { - "index": 11, + "index": 4, "lineNumber": 1, - "column": 12, - "description": "Unexpected token ILLEGAL" + "column": 5, + "message": "Code point out of bounds" }; \ No newline at end of file diff --git a/tests/lib/attach-comments.js b/tests/lib/attach-comments.js index 6d047711..53710f88 100644 --- a/tests/lib/attach-comments.js +++ b/tests/lib/attach-comments.js @@ -46,6 +46,10 @@ var testFiles = shelljs.find("./tests/fixtures/attach-comments").filter(function return filename.substring(0, filename.length - 7); // strip off ".src.js" }); +function getRaw(ast) { + return JSON.parse(JSON.stringify(ast)); +} + //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ @@ -78,7 +82,7 @@ describe("attachComment: true", function() { }); } - assert.deepEqual(result, output); + assert.deepEqual(getRaw(result), output); }); }); diff --git a/tests/lib/ecma-features.js b/tests/lib/ecma-features.js index 0ee1bb87..0ce3c434 100644 --- a/tests/lib/ecma-features.js +++ b/tests/lib/ecma-features.js @@ -48,6 +48,8 @@ var testFiles = shelljs.find(FIXTURES_DIR).filter(function(filename) { return filename.indexOf(".src.js") > -1; }).map(function(filename) { return filename.substring(FIXTURES_DIR.length - 1, filename.length - 7); // strip off ".src.js" +// }).filter(function(filename) { +// return /simple-new-target/.test(filename); }); var moduleTestFiles = testFiles.filter(function(filename) { @@ -58,11 +60,17 @@ var mixFiles = shelljs.find(FIXTURES_MIX_DIR).filter(function(filename) { return filename.indexOf(".src.js") > -1; }).map(function(filename) { return filename.substring(FIXTURES_MIX_DIR.length - 1, filename.length - 7); // strip off ".src.js" +// }).filter(function(filename) { +// return /template/.test(filename); }); // console.dir(moduleTestFiles); // return; +function getRaw(ast) { + return JSON.parse(JSON.stringify(ast)); +} + //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ @@ -93,22 +101,17 @@ describe("ecmaFeatures", function() { try { result = espree.parse(code, config); + result = getRaw(result); } catch (ex) { // if the result is an error, create an error object so deepEqual works if (expected.message || expected.description) { - - var expectedError = new Error(expected.message || expected.description); - Object.keys(expected).forEach(function(key) { - expectedError[key] = expected[key]; - }); - expected = expectedError; + result = getRaw(ex); + result.message = ex.message; } else { throw ex; } - result = ex; // if an error is thrown, match the error - } assert.deepEqual(result, expected); }); @@ -141,24 +144,19 @@ describe("ecmaFeatures", function() { } try { - result = espree.parse(code, config); + result = getRaw(espree.parse(code, config)); } catch (ex) { // if the result is an error, create an error object so deepEqual works if (expected.message || expected.description) { - - var expectedError = new Error(expected.message || expected.description); - Object.keys(expected).forEach(function(key) { - expectedError[key] = expected[key]; - }); - expected = expectedError; + result = getRaw(ex); + result.message = ex.message; } else { throw ex; } - result = ex; // if an error is thrown, match the error - } + assert.deepEqual(result, expected); }); @@ -180,17 +178,16 @@ describe("ecmaFeatures", function() { try { result = espree.parse(code, config); + result = getRaw(result); } catch (ex) { // if the result is an error, create an error object so deepEqual works - if (expected.message) { - var expectedError = new Error(expected.message); - Object.keys(expected).forEach(function(key) { - expectedError[key] = expected[key]; - }); - expected = expectedError; + if (expected.message || expected.description) { + result = getRaw(ex); + result.message = ex.message; + } else { + throw ex; } - result = ex; // if an error is thrown, match the error } assert.deepEqual(result, expected); diff --git a/tests/lib/tokenize.js b/tests/lib/tokenize.js index 0fbb3a93..cb9f7ffd 100644 --- a/tests/lib/tokenize.js +++ b/tests/lib/tokenize.js @@ -34,30 +34,18 @@ var assert = require("chai").assert, espree = require("../../espree"); //------------------------------------------------------------------------------ -// Tests +// Helpers //------------------------------------------------------------------------------ -describe("tokenize()", function() { - - describe("ECMAScript 5 mode", function() { - - it("should throw when using regular expression u flag", function() { - - assert.throws(function() { - espree.tokenize("var foo = /foo/u;"); - }, /Invalid regular expression flag/); - - }); - - it("should throw when using regular expression y flag", function() { +function getRaw(ast) { + return JSON.parse(JSON.stringify(ast)); +} - assert.throws(function() { - espree.tokenize("var foo = /foo/y;"); - }, /Invalid regular expression flag/); - - }); +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ - }); +describe("tokenize()", function() { it("should produce tokens when using let", function() { var tokens = espree.tokenize("let foo = bar;", { @@ -65,7 +53,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/let-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/let-result.tokens.js")); }); it("should produce tokens when using const", function() { @@ -74,7 +62,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/const-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/const-result.tokens.js")); }); it("should produce tokens when using regular expression u flag", function() { @@ -83,7 +71,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/regexp-u-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/regexp-u-result.tokens.js")); }); it("should produce tokens when using regular expression y flag", function() { @@ -92,7 +80,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/regexp-y-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/regexp-y-result.tokens.js")); }); @@ -103,7 +91,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/template-string-simple-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/template-string-simple-result.tokens.js")); }); it("should produce tokens when tokenizing template string with embedded variable", function() { @@ -112,7 +100,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/template-string-embedded-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/template-string-embedded-result.tokens.js")); }); it("should produce tokens when tokenizing template string with embedded variable in function call", function() { @@ -122,7 +110,7 @@ describe("tokenize()", function() { range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/template-string-embedded2-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/template-string-embedded2-result.tokens.js")); }); it("should produce tokens when parsing template string with embedded variable in function call and with tokens options on", function() { @@ -133,7 +121,7 @@ describe("tokenize()", function() { range: true }); - assert.deepEqual(ast.tokens, require("../fixtures/tokenize/template-string-embedded2-result.tokens.js")); + assert.deepEqual(getRaw(ast.tokens), require("../fixtures/tokenize/template-string-embedded2-result.tokens.js")); }); it("should produce tokens when tokenizing template string with embedded expressions", function() { @@ -142,7 +130,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/template-string-expressions-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/template-string-expressions-result.tokens.js")); }); @@ -154,7 +142,7 @@ describe("tokenize()", function() { loc: true, range: true }); - assert.deepEqual(tokens, require("../fixtures/tokenize/regex-in-parens-result.tokens.js")); + assert.deepEqual(getRaw(tokens), require("../fixtures/tokenize/regex-in-parens-result.tokens.js")); }); it("should produce tokens when using regular expression wrapped in parens using parse()", function() { @@ -163,7 +151,7 @@ describe("tokenize()", function() { range: true, tokens: true }); - assert.deepEqual(ast.tokens, require("../fixtures/tokenize/regex-in-parens-result.tokens.js")); + assert.deepEqual(getRaw(ast.tokens), require("../fixtures/tokenize/regex-in-parens-result.tokens.js")); }); }); diff --git a/tools/update-tests.js b/tools/update-tests.js index 855c8d9c..901a0032 100644 --- a/tools/update-tests.js +++ b/tools/update-tests.js @@ -45,11 +45,17 @@ var shelljs = require("shelljs"), // Helpers //------------------------------------------------------------------------------ +function getRaw(ast) { + return JSON.parse(JSON.stringify(ast)); +} + function getExpectedResult(code, config) { try { - return espree.parse(code, config); + return getRaw(espree.parse(code, config)); } catch (ex) { - return ex; // if an error is thrown, match the error + var raw = getRaw(ex); + raw.message = ex.message; + return raw; } } @@ -111,21 +117,21 @@ testFiles.forEach(function(filename) { }); // update all tests in ecma-features-mix -mixFiles.forEach(function(filename) { +// mixFiles.forEach(function(filename) { - var feature = path.dirname(filename), - code = shelljs.cat(path.resolve(FIXTURES_MIX_DIR, filename) + ".src.js"), - config = { - loc: true, - range: true, - tokens: true, - ecmaFeatures: {} - }; +// var feature = path.dirname(filename), +// code = shelljs.cat(path.resolve(FIXTURES_MIX_DIR, filename) + ".src.js"), +// config = { +// loc: true, +// range: true, +// tokens: true, +// ecmaFeatures: {} +// }; - config.ecmaFeatures = require(path.resolve(__dirname, "../", FIXTURES_MIX_DIR, filename) + ".config.js"); +// config.ecmaFeatures = require(path.resolve(__dirname, "../", FIXTURES_MIX_DIR, filename) + ".config.js"); - var testResultFilename = path.resolve(__dirname, "..", FIXTURES_MIX_DIR, filename) + ".result.js", - result = getExpectedResult(code, config); +// var testResultFilename = path.resolve(__dirname, "..", FIXTURES_MIX_DIR, filename) + ".result.js", +// result = getExpectedResult(code, config); - outputResult(result, testResultFilename); -}); +// outputResult(result, testResultFilename); +// });