/**
 * Interface for registering benchmark suites
 */
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "./object", "../BenchmarkTest", "../BenchmarkSuite", "../../intern"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var object_1 = require("./object");
    var BenchmarkTest_1 = require("../BenchmarkTest");
    var BenchmarkSuite_1 = require("../BenchmarkSuite");
    var intern_1 = require("../../intern");
    /**
     * Importable interface that uses the currently installed global executor
     */
    function registerSuite(name, descriptorOrFactory) {
        return _registerSuite(intern_1.default(), name, descriptorOrFactory);
    }
    exports.default = registerSuite;
    /**
     * Interface factory used by Executor
     */
    function getInterface(executor) {
        return {
            registerSuite: function (name, descriptorOrFactory) {
                return _registerSuite(executor, name, descriptorOrFactory);
            },
            async: BenchmarkTest_1.default.async
        };
    }
    exports.getInterface = getInterface;
    function _registerSuite(executor, name, descriptorOrFactory) {
        // Only register benchmark suites if we're in benchmark mode
        if (!executor.config.benchmark) {
            executor.log('Not registering benchmark suite ' + name + ' because benchmarking is disabled');
            return;
        }
        executor.addSuite(function (parent) {
            // Enable per-suite closure, to match feature parity with other interfaces like tdd/bdd more closely;
            // without this, it becomes impossible to use the object interface for functional tests since there is no
            // other way to create a closure for each main suite
            var descriptor;
            if (object_1.isSuiteDescriptorFactory(descriptorOrFactory)) {
                descriptor = descriptorOrFactory();
            }
            else {
                descriptor = descriptorOrFactory;
            }
            parent.add(object_1.createSuite(name, parent, descriptor, BenchmarkSuite_1.default, BenchmarkTest_1.default));
        });
    }
});
//# sourceMappingURL=benchmark.js.map