;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Alex Kost ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . ;;; ;;; Generate AUTHORS file for directory with the Guix git repository. ;;; (use-modules (ice-9 popen) (ice-9 rdelim) (ice-9 match) (srfi srfi-1) (guix config) (guix utils) (guix build utils)) (define %guix-dir (make-parameter #f)) (define-syntax-rule (append-maybe init-lst (test add-lst) ...) (let* ((lst init-lst) (lst (if test (append lst add-lst) lst)) ...) lst)) (define (command-output cmd . args) "Execute CMD with ARGS and return its output without trailing newspace." (let* ((port (apply open-pipe* OPEN_READ cmd args)) (output (read-string port))) (close-port port) (string-trim-right output #\newline))) (define (git-output . args) "Execute git command with ARGS and return its output without trailing newspace." (with-directory-excursion (%guix-dir) (apply command-output "git" args))) (define* (contributors-string #:optional (range "HEAD")) "Return a string with names of people contributed to commit RANGE." (git-output "shortlog" "--numbered" "--summary" "--email" range)) (define* (tags #:key pattern sort) "Return a list of the git repository tags. PATTERN is passed to '--list' and SORT is passed to '--sort' options of 'git tag' command." (let* ((args (append-maybe '("tag") (pattern (list "--list" pattern)) (sort (list "--sort" sort)))) (output (apply git-output args))) (string-split output #\newline))) (define (version-tags)
var assert = require("assert");
var exec = require("child_process").exec;
var fs = require("fs");
var run_code = require("../sandbox").run_code;
var to_ascii = require("../node").to_ascii;

function read(path) {
    return fs.readFileSync(path, "utf8");
}

describe("bin/uglifyjs", function() {
    var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
    it("Should produce a functional build when using --self", function(done) {
        this.timeout(30000);
        var command = uglifyjscmd + ' --self -cm --wrap WrappedUglifyJS';
        exec(command, {
            maxBuffer: 1048576
        }, function(err, stdout) {
            if (err) throw err;
            eval(stdout);
            assert.strictEqual(typeof WrappedUglifyJS, "object");
            var result = WrappedUglifyJS.minify("foo([true,,2+3]);");
            assert.strictEqual(result.error, undefined);
            assert.strictEqual(result.code, "foo([!0,,5]);");
            done();
        });
    });
    it("Should be able to filter comments correctly with `--comments all`", function(done) {
        var command = uglifyjscmd + ' test/input/comments/filter.js --comments all';
        exec(command, function(err, stdout) {
            if (err) throw err;
            assert.strictEqual(stdout, "// foo\n/*@preserve*/\n// bar\n");
            done();
        });
    });