From b1c3ed6d2d21176fcf34d5ceebb379a8f2a5c44c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 30 Jul 2015 23:47:59 +0100 Subject: [PATCH] fix linting error and add missing tests --- src/plugins/flow.js | 2 +- .../literal-types/boolean-false/expected.json | 114 ++++++++++++++++++ .../literal-types/boolean-true/expected.json | 114 ++++++++++++++++++ 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/flow/literal-types/boolean-false/expected.json create mode 100644 test/fixtures/flow/literal-types/boolean-true/expected.json diff --git a/src/plugins/flow.js b/src/plugins/flow.js index 4eb8851c73..550446ad10 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -494,7 +494,7 @@ pp.flowParsePrimaryType = function () { return this.finishNode(node, "StringLiteralTypeAnnotation"); case tt._true: case tt._false: - node.value = this.match(tt._true) + node.value = this.match(tt._true); this.next(); return this.finishNode(node, "BooleanLiteralTypeAnnotation"); diff --git a/test/fixtures/flow/literal-types/boolean-false/expected.json b/test/fixtures/flow/literal-types/boolean-false/expected.json new file mode 100644 index 0000000000..6cc01d01a9 --- /dev/null +++ b/test/fixtures/flow/literal-types/boolean-false/expected.json @@ -0,0 +1,114 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "foo", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 7, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "typeAnnotation": { + "type": "BooleanLiteralTypeAnnotation", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": true + } + } + }, + "init": null + } + ], + "kind": "var" + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/literal-types/boolean-true/expected.json b/test/fixtures/flow/literal-types/boolean-true/expected.json new file mode 100644 index 0000000000..b05db87966 --- /dev/null +++ b/test/fixtures/flow/literal-types/boolean-true/expected.json @@ -0,0 +1,114 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "name": "foo", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "typeAnnotation": { + "type": "BooleanLiteralTypeAnnotation", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": false + } + } + }, + "init": null + } + ], + "kind": "var" + } + ] + } +} \ No newline at end of file