From 84adda7c205e88db8e39417f7bb784551ee132ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0pan=C4=9Bl?= Date: Thu, 16 Feb 2017 12:21:07 +0100 Subject: [PATCH] Test case for the fix. --- test/mocha/accessorTokens-1492.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/mocha/accessorTokens-1492.js diff --git a/test/mocha/accessorTokens-1492.js b/test/mocha/accessorTokens-1492.js new file mode 100644 index 00000000..0fccd431 --- /dev/null +++ b/test/mocha/accessorTokens-1492.js @@ -0,0 +1,22 @@ +var UglifyJS = require('../../'); +var assert = require("assert"); + +describe("Accessor tokens", function() { + it("Should fill the token information for accessors (issue #1492)", function() { + var ast = UglifyJS.parse("var obj = { get latest() { return undefined; } }"); + + /* a possible way to test, but walking through the whole tree seems more robust against possible AST changes + var accessor = ast.body["0"].definitions["0"].value.properties["0"].value; + assert(accessor instanceof UglifyJS.AST_Accessor); + assert(accessor.start !== undefined); + assert(accessor.end !== undefined); + */ + + // test there are no nodes without tokens + var checkWalker = new UglifyJS.TreeWalker(function(node, descend) { + assert(node.start !== undefined); + assert(node.end !== undefined); + }); + ast.walk(checkWalker); + }); +}); \ No newline at end of file