From 38c417e9710c0672eaea2e1ea66540095630fef0 Mon Sep 17 00:00:00 2001 From: Peeyush Kushwaha Date: Sun, 18 Jun 2017 01:25:54 +0530 Subject: [PATCH] Reorganize tests; camelCase plugin name --- src/index.js | 4 ++-- src/parser/expression.js | 4 ++-- src/parser/lval.js | 2 +- src/parser/statement.js | 8 ++++---- .../computed-member-expr-on-prop/options.json | 2 +- .../computed-member-expression/options.json | 2 +- .../actual.js | 0 .../options.json | 0 .../actual.js | 0 .../options.json | 2 +- .../actual.js | 0 .../options.json | 0 .../actual.js | 0 .../options.json | 0 .../actual.js | 0 .../options.json | 0 .../fixtures/experimental/decorators-stage-2/options.json | 2 +- 17 files changed, 13 insertions(+), 13 deletions(-) rename test/fixtures/experimental/decorators-stage-2/{class-method-parameter => no-class-method-parameter}/actual.js (100%) rename test/fixtures/experimental/decorators-stage-2/{class-method-parameter => no-class-method-parameter}/options.json (100%) rename test/fixtures/experimental/decorators-stage-2/{on-computed-name-prop => no-computed-name-prop}/actual.js (100%) rename test/fixtures/experimental/decorators-stage-2/{on-computed-name-prop => no-computed-name-prop}/options.json (61%) rename test/fixtures/experimental/decorators-stage-2/{export-decorators-on-class => no-export-decorators-on-class}/actual.js (100%) rename test/fixtures/experimental/decorators-stage-2/{export-decorators-on-class => no-export-decorators-on-class}/options.json (100%) rename test/fixtures/experimental/decorators-stage-2/{function-parameters => no-function-parameters}/actual.js (100%) rename test/fixtures/experimental/decorators-stage-2/{function-parameters => no-function-parameters}/options.json (100%) rename test/fixtures/experimental/decorators-stage-2/{object-method-parameter => no-object-method-parameters}/actual.js (100%) rename test/fixtures/experimental/decorators-stage-2/{object-method-parameter => no-object-method-parameters}/options.json (100%) diff --git a/src/index.js b/src/index.js index d8e41d389a..8ebcb0c7be 100755 --- a/src/index.js +++ b/src/index.js @@ -62,8 +62,8 @@ function getParserClass(pluginsFromOptions: $ReadOnlyArray): Class= 0 && pluginList.indexOf("decorators-stage-2") >= 0) { - throw new Error("Cannot use decorators and decorators-stage-2 plugin together"); + if (pluginList.indexOf("decorators") >= 0 && pluginList.indexOf("decoratorsStage2") >= 0) { + throw new Error("Cannot use decorators and decoratorsStage2 plugin together"); } const key = pluginList.join("/"); diff --git a/src/parser/expression.js b/src/parser/expression.js index b186920805..6b0f3464b3 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -848,8 +848,8 @@ export default class ExpressionParser extends LValParser { } if (this.match(tt.at)) { - if (this.hasPlugin("decorators-stage-2")) { - this.raise(this.state.start, "decorators-stage-2 disallows object literal property decorators"); + if (this.hasPlugin("decoratorsStage2")) { + this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators"); } else { // we needn't check if decorators (stage 0) plugin is enabled since it's checked by // the call to this.parseDecorator diff --git a/src/parser/lval.js b/src/parser/lval.js index 8e0f153cf7..f642b467c5 100644 --- a/src/parser/lval.js +++ b/src/parser/lval.js @@ -187,7 +187,7 @@ export default class LValParser extends NodeUtils { break; } else { const decorators = []; - if (this.match(tt.at) && this.hasPlugin("decorators-stage-2")) { + if (this.match(tt.at) && this.hasPlugin("decoratorsStage2")) { this.raise(this.state.start, "Stage 2 decorators cannot be used to decorate parameters"); } while (this.match(tt.at)) { diff --git a/src/parser/statement.js b/src/parser/statement.js index 726ed65922..2e887a7e85 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -157,7 +157,7 @@ export default class StatementParser extends ExpressionParser { } parseDecorators(allowExport?: boolean): void { - if (this.hasPlugin("decorators-stage-2")) { + if (this.hasPlugin("decoratorsStage2")) { allowExport = false; } @@ -176,14 +176,14 @@ export default class StatementParser extends ExpressionParser { } parseDecorator(): N.Decorator { - if (!(this.hasPlugin("decorators") || this.hasPlugin("decorators-stage-2"))) { + if (!(this.hasPlugin("decorators") || this.hasPlugin("decoratorsStage2"))) { this.unexpected(); } const node = this.startNode(); this.next(); - if (this.hasPlugin("decorators-stage-2")) { + if (this.hasPlugin("decoratorsStage2")) { const startPos = this.state.start; const startLoc = this.state.startLoc; let expr = this.parseIdentifier(false); @@ -714,7 +714,7 @@ export default class StatementParser extends ExpressionParser { this.parseClassMember(classBody, member, state); - if (this.hasPlugin("decorators-stage-2") && member.kind != "method" && member.decorators && member.decorators.length > 0) { + if (this.hasPlugin("decoratorsStage2") && member.kind != "method" && member.decorators && member.decorators.length > 0) { this.raise(member.start, "Stage 2 decorators may only be used with a class or a class method"); } } diff --git a/test/fixtures/experimental/decorators-stage-2/computed-member-expr-on-prop/options.json b/test/fixtures/experimental/decorators-stage-2/computed-member-expr-on-prop/options.json index d1e493e091..68c749fda9 100644 --- a/test/fixtures/experimental/decorators-stage-2/computed-member-expr-on-prop/options.json +++ b/test/fixtures/experimental/decorators-stage-2/computed-member-expr-on-prop/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators-stage-2", "classProperties"], + "plugins": ["decoratorsStage2", "classProperties"], "throws": "Unexpected token (2:12)" } diff --git a/test/fixtures/experimental/decorators-stage-2/computed-member-expression/options.json b/test/fixtures/experimental/decorators-stage-2/computed-member-expression/options.json index a4c63d917c..acf8362a77 100644 --- a/test/fixtures/experimental/decorators-stage-2/computed-member-expression/options.json +++ b/test/fixtures/experimental/decorators-stage-2/computed-member-expression/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators-stage-2", "classProperties"], + "plugins": ["decoratorsStage2", "classProperties"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:6)" } diff --git a/test/fixtures/experimental/decorators-stage-2/class-method-parameter/actual.js b/test/fixtures/experimental/decorators-stage-2/no-class-method-parameter/actual.js similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/class-method-parameter/actual.js rename to test/fixtures/experimental/decorators-stage-2/no-class-method-parameter/actual.js diff --git a/test/fixtures/experimental/decorators-stage-2/class-method-parameter/options.json b/test/fixtures/experimental/decorators-stage-2/no-class-method-parameter/options.json similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/class-method-parameter/options.json rename to test/fixtures/experimental/decorators-stage-2/no-class-method-parameter/options.json diff --git a/test/fixtures/experimental/decorators-stage-2/on-computed-name-prop/actual.js b/test/fixtures/experimental/decorators-stage-2/no-computed-name-prop/actual.js similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/on-computed-name-prop/actual.js rename to test/fixtures/experimental/decorators-stage-2/no-computed-name-prop/actual.js diff --git a/test/fixtures/experimental/decorators-stage-2/on-computed-name-prop/options.json b/test/fixtures/experimental/decorators-stage-2/no-computed-name-prop/options.json similarity index 61% rename from test/fixtures/experimental/decorators-stage-2/on-computed-name-prop/options.json rename to test/fixtures/experimental/decorators-stage-2/no-computed-name-prop/options.json index 481f6730cc..a22e3dad04 100644 --- a/test/fixtures/experimental/decorators-stage-2/on-computed-name-prop/options.json +++ b/test/fixtures/experimental/decorators-stage-2/no-computed-name-prop/options.json @@ -1,4 +1,4 @@ { - "plugins": ["classProperties", "decorators-stage-2"], + "plugins": ["classProperties", "decoratorsStage2"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:7)" } diff --git a/test/fixtures/experimental/decorators-stage-2/export-decorators-on-class/actual.js b/test/fixtures/experimental/decorators-stage-2/no-export-decorators-on-class/actual.js similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/export-decorators-on-class/actual.js rename to test/fixtures/experimental/decorators-stage-2/no-export-decorators-on-class/actual.js diff --git a/test/fixtures/experimental/decorators-stage-2/export-decorators-on-class/options.json b/test/fixtures/experimental/decorators-stage-2/no-export-decorators-on-class/options.json similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/export-decorators-on-class/options.json rename to test/fixtures/experimental/decorators-stage-2/no-export-decorators-on-class/options.json diff --git a/test/fixtures/experimental/decorators-stage-2/function-parameters/actual.js b/test/fixtures/experimental/decorators-stage-2/no-function-parameters/actual.js similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/function-parameters/actual.js rename to test/fixtures/experimental/decorators-stage-2/no-function-parameters/actual.js diff --git a/test/fixtures/experimental/decorators-stage-2/function-parameters/options.json b/test/fixtures/experimental/decorators-stage-2/no-function-parameters/options.json similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/function-parameters/options.json rename to test/fixtures/experimental/decorators-stage-2/no-function-parameters/options.json diff --git a/test/fixtures/experimental/decorators-stage-2/object-method-parameter/actual.js b/test/fixtures/experimental/decorators-stage-2/no-object-method-parameters/actual.js similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/object-method-parameter/actual.js rename to test/fixtures/experimental/decorators-stage-2/no-object-method-parameters/actual.js diff --git a/test/fixtures/experimental/decorators-stage-2/object-method-parameter/options.json b/test/fixtures/experimental/decorators-stage-2/no-object-method-parameters/options.json similarity index 100% rename from test/fixtures/experimental/decorators-stage-2/object-method-parameter/options.json rename to test/fixtures/experimental/decorators-stage-2/no-object-method-parameters/options.json diff --git a/test/fixtures/experimental/decorators-stage-2/options.json b/test/fixtures/experimental/decorators-stage-2/options.json index 80608cfffd..e46a0b346f 100644 --- a/test/fixtures/experimental/decorators-stage-2/options.json +++ b/test/fixtures/experimental/decorators-stage-2/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators-stage-2"] + "plugins": ["decoratorsStage2"] }