aboutsummaryrefs
aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/accessorTokens-1492.js
blob: 861414eea8ca421fe098cb59a60c12d15291d151 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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");
    });
});
(ice-9 match) (ice-9 vlist) (guix packages) (guix profiles) (gnu packages)) (define (all-packages) "Return the list of all the packages, public or private, omitting only superseded packages." (fold-packages (lambda (package lst) (match (package-replacement package) (#f (cons package lst)) (replacement (append (list replacement package) lst)))) '() #:select? (negate package-superseded))) (define (upstream-origin source) "Return SOURCE without any patches or snippet." (origin (inherit source) (snippet #f) (patches '()))) (define (all-origins) "Return the list of origins referred to by all the packages." (let loop ((packages (all-packages)) (origins '()) (visited vlist-null)) (match packages ((head . tail) (let ((new (remove (cut vhash-assq <> visited) (package-direct-sources head)))) (loop tail (append new origins) (fold (cut vhash-consq <> #t <>) visited new)))) (() origins)))) ;; Return a manifest containing all the origins. (manifest (map (lambda (origin) (manifest-entry (name (or (origin-actual-file-name origin) "origin")) (version "0") (item (upstream-origin origin)))) (all-origins)))