"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const Graph_1 = require("../../Class/Graph");
const SELF_1 = require("../../constant/SELF");
const debug_1 = require("../../debug");
const _ids_1 = require("../../system/_ids");
const system_1 = require("../util/system");
const spec = system_1.system.emptySpec();
const graph = new Graph_1.Graph(spec, {}, system_1.system);
0 && (0, debug_1.watchUnitAndLog)(graph);
0 && (0, debug_1.watchGraphAndLog)(graph);
graph.play();
graph.addUnitSpec('throw', { unit: { id: _ids_1.ID_THROW } });
graph.addUnitSpec('catch', { unit: { id: _ids_1.ID_CATCH } });
const catchy = graph.getUnit('catch');
const throwy = graph.getUnit('throw');
throwy.pushInput('message', 'booom!');
assert.equal(throwy.peakInput('message'), 'booom!');
assert.equal(throwy.getErr(), 'booom!');
graph.addMerge({
    throw: {
        output: {
            [SELF_1.SELF]: true,
        },
    },
    catch: {
        input: {
            unit: true,
        },
    },
}, '0');
assert.equal(catchy.peakOutput('err'), 'booom!');
assert.equal(throwy.peakInput('message'), 'booom!');
assert.equal(catchy.takeOutput('err'), 'booom!');
assert.equal(throwy.peakInput('message'), undefined);
throwy.pushInput('message', 'kpop!');
assert.equal(catchy.peakOutput('err'), 'kpop!');
graph.removeMerge('0');
assert.equal(catchy.peakOutput('err'), undefined);
assert.equal(throwy.getErr(), 'kpop!');
graph.addMerge({
    throw: {
        output: {
            [SELF_1.SELF]: true,
        },
    },
    catch: {
        input: {
            unit: true,
        },
    },
}, '0');
assert.equal(catchy.peakOutput('err'), 'kpop!');
assert.equal(throwy.peakInput('message'), 'kpop!');
assert.equal(throwy.getErr(), null);
assert.equal(graph.getErr(), null);
throwy.setInputConstant('message', true);
assert.equal(catchy.takeOutput('err'), 'kpop!');
assert.equal(catchy.takeOutput('err'), 'kpop!');
assert.equal(catchy.takeOutput('err'), 'kpop!');
assert.equal(catchy.takeOutput('err'), 'kpop!');
assert.equal(catchy.takeOutput('err'), 'kpop!');
throwy.setInputConstant('message', false);
assert.equal(catchy.takeOutput('err'), 'kpop!');
assert.equal(catchy.takeOutput('err'), null);
throwy.push('message', 'xxx');
assert.equal(catchy.peakOutput('err'), 'xxx');
assert.equal(throwy.takeInput('message'), 'xxx');
assert.equal(catchy.peakOutput('err'), null);
//# sourceMappingURL=catch.js.map