Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Sep 14, 2021
1 parent d7c7c56 commit 8a1f515
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`prints information for debugging AST --debug-print-comments (stdout) 1`] = `"{\\"text\\":\\"const foo = 'foo';\\",\\"ast\\":{\\"type\\":\\"File\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"errors\\":[],\\"program\\":{\\"type\\":\\"Program\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"sourceType\\":\\"module\\",\\"interpreter\\":null,\\"body\\":[{\\"type\\":\\"VariableDeclaration\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"declarations\\":[{\\"type\\":\\"VariableDeclarator\\",\\"start\\":6,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[6,17],\\"id\\":{\\"type\\":\\"Identifier\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9},\\"identifierName\\":\\"foo\\"},\\"range\\":[6,9],\\"name\\":\\"foo\\"},\\"init\\":{\\"type\\":\\"StringLiteral\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[12,17],\\"extra\\":{\\"rawValue\\":\\"foo\\",\\"raw\\":\\"'foo'\\"},\\"value\\":\\"foo\\"}}],\\"kind\\":\\"const\\"}],\\"directives\\":[]},\\"comments\\":[],\\"tokens\\":[{\\"type\\":{\\"label\\":\\"const\\",\\"keyword\\":\\"const\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"const\\",\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":5}}},{\\"type\\":{\\"label\\":\\"name\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9}}},{\\"type\\":{\\"label\\":\\"=\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":true,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"=\\",\\"start\\":10,\\"end\\":11,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":10},\\"end\\":{\\"line\\":1,\\"column\\":11}}},{\\"type\\":{\\"label\\":\\"string\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}}},{\\"type\\":{\\"label\\":\\";\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":17,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":17},\\"end\\":{\\"line\\":1,\\"column\\":18}}},{\\"type\\":{\\"label\\":\\"eof\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":18,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":18},\\"end\\":{\\"line\\":1,\\"column\\":18}}}]}}"`;

exports[`prints information for debugging AST --debug-print-comments (write) 1`] = `Array []`;
12 changes: 12 additions & 0 deletions tests/integration/__tests__/debug-print-ast.js
@@ -0,0 +1,12 @@
"use strict";

const runPrettier = require("../runPrettier.js");

describe("prints information for debugging AST --debug-print-comments", () => {
runPrettier("cli/with-shebang", ["--debug-print-ast", "--parser", "babel"], {
input: "const foo = 'foo';",
}).test({
stderr: "",
status: 0,
});
});

0 comments on commit 8a1f515

Please sign in to comment.