diff options
author | Ondřej Španěl <OndrejSpanel@users.noreply.github.com> | 2017-02-20 17:14:53 +0800 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2017-02-21 13:32:16 +0800 |
commit | d48a3080ac873ae531a2d87679a26c5941814843 (patch) | |
tree | bdb4f67b4bc427726013132f88c0d907515a8ba1 /test | |
parent | 26fbeece1c385a0e63efe3a6683af8459f4e495a (diff) | |
download | tracifyjs-d48a3080ac873ae531a2d87679a26c5941814843.tar.gz tracifyjs-d48a3080ac873ae531a2d87679a26c5941814843.zip |
Fix: AST_Accessor missing start / end tokens
fixes #1492
closes #1493
Diffstat (limited to 'test')
-rw-r--r-- | test/mocha/accessorTokens-1492.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/mocha/accessorTokens-1492.js b/test/mocha/accessorTokens-1492.js new file mode 100644 index 00000000..861414ee --- /dev/null +++ b/test/mocha/accessorTokens-1492.js @@ -0,0 +1,32 @@ +var UglifyJS = require('../../'); +var assert = require("assert"); + +describe("Accessor tokens", function() { + it("Should fill the token information for accessors (issue #1492)", function() { + // location 0 1 2 3 4 + // 01234567890123456789012345678901234567890123456789 + var ast = UglifyJS.parse("var obj = { get latest() { return undefined; } }"); + + // test all AST_ObjectProperty tokens are set as expected + var checkedAST_ObjectProperty = false; + var checkWalker = new UglifyJS.TreeWalker(function(node, descend) { + if (node instanceof UglifyJS.AST_ObjectProperty) { + checkedAST_ObjectProperty = true; + + assert.equal(node.start.pos, 12); + assert.equal(node.end.endpos, 46); + + assert(node.key instanceof UglifyJS.AST_SymbolRef); + assert.equal(node.key.start.pos, 16); + assert.equal(node.key.end.endpos, 22); + + assert(node.value instanceof UglifyJS.AST_Accessor); + assert.equal(node.value.start.pos, 22); + assert.equal(node.value.end.endpos, 46); + + } + }); + ast.walk(checkWalker); + assert(checkedAST_ObjectProperty, "AST_ObjectProperty not found"); + }); +});
\ No newline at end of file |