From abd39d688ea98b8028ace78b9246c86903870071 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Sat, 6 Feb 2016 23:01:38 -0800 Subject: [PATCH] Add tests for class property ASI. --- .../class-properties/asi-failure/actual.js | 4 + .../class-properties/asi-failure/options.json | 4 + .../class-properties/asi-success/actual.js | 9 + .../asi-success/expected.json | 289 ++++++++++++++++++ .../class-properties/asi-success/options.json | 3 + 5 files changed, 309 insertions(+) create mode 100644 test/fixtures/experimental/class-properties/asi-failure/actual.js create mode 100644 test/fixtures/experimental/class-properties/asi-failure/options.json create mode 100644 test/fixtures/experimental/class-properties/asi-success/actual.js create mode 100644 test/fixtures/experimental/class-properties/asi-success/expected.json create mode 100644 test/fixtures/experimental/class-properties/asi-success/options.json diff --git a/test/fixtures/experimental/class-properties/asi-failure/actual.js b/test/fixtures/experimental/class-properties/asi-failure/actual.js new file mode 100644 index 0000000000..f2b5d0c2d1 --- /dev/null +++ b/test/fixtures/experimental/class-properties/asi-failure/actual.js @@ -0,0 +1,4 @@ +class Foo { + p = x + [m] () {} +} diff --git a/test/fixtures/experimental/class-properties/asi-failure/options.json b/test/fixtures/experimental/class-properties/asi-failure/options.json new file mode 100644 index 0000000000..0c58f8ded1 --- /dev/null +++ b/test/fixtures/experimental/class-properties/asi-failure/options.json @@ -0,0 +1,4 @@ +{ + "throws": "Unexpected token (3:9)", + "plugins": ["classProperties"] +} diff --git a/test/fixtures/experimental/class-properties/asi-success/actual.js b/test/fixtures/experimental/class-properties/asi-success/actual.js new file mode 100644 index 0000000000..2e57778bbb --- /dev/null +++ b/test/fixtures/experimental/class-properties/asi-success/actual.js @@ -0,0 +1,9 @@ +class Foo { + x + y +} + +class Foo { + p + [m] () {} +} diff --git a/test/fixtures/experimental/class-properties/asi-success/expected.json b/test/fixtures/experimental/class-properties/asi-success/expected.json new file mode 100644 index 0000000000..c78a521f9c --- /dev/null +++ b/test/fixtures/experimental/class-properties/asi-success/expected.json @@ -0,0 +1,289 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "computed": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "name": "x" + }, + "static": false, + "value": null + }, + { + "type": "ClassProperty", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "computed": false, + "key": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "name": "y" + }, + "static": false, + "value": null + } + ] + } + }, + { + "type": "ClassDeclaration", + "start": 23, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "computed": false, + "key": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "name": "p" + }, + "static": false, + "value": null + }, + { + "type": "ClassMethod", + "start": 41, + "end": 50, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "computed": true, + "key": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 8, + "column": 3 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "name": "m" + }, + "static": false, + "kind": "method", + "id": null, + "generator": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/class-properties/asi-success/options.json b/test/fixtures/experimental/class-properties/asi-success/options.json new file mode 100644 index 0000000000..9c27576d4a --- /dev/null +++ b/test/fixtures/experimental/class-properties/asi-success/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["classProperties"] +}