"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const debug_1 = require("../../../debug");
const fromSpec_1 = require("../../../spec/fromSpec");
const _specs_1 = require("../../../system/_specs");
const util_1 = require("../../util");
const system_1 = require("../../util/system");
const spec = require('../../../system/core/control/IfElse/spec.json');
const IfElse = (0, fromSpec_1.fromSpec)(spec, _specs_1.default);
const ifElse = new IfElse(system_1.system);
false && (0, debug_1.watchGraphAndLog)(ifElse);
false && (0, debug_1.watchUnitAndLog)(ifElse);
const ifDataCounter = (0, util_1.countEvent)(ifElse.getOutput('if'), 'data');
const ifDropCounter = (0, util_1.countEvent)(ifElse.getOutput('if'), 'drop');
const elseDataCounter = (0, util_1.countEvent)(ifElse.getOutput('else'), 'data');
const elseDropCounter = (0, util_1.countEvent)(ifElse.getOutput('else'), 'drop');
ifElse.play();
ifElse.push('a', 1);
ifElse.push('b', true);
assert.equal(ifElse.take('if'), 1);
assert.equal(ifElse.take('if'), undefined);
assert.equal(ifElse.peakInput('a'), undefined);
assert.equal(ifElse.peakInput('b'), undefined);
ifElse.push('a', 1);
ifElse.push('b', false);
assert.equal(ifElse.take('if'), undefined);
assert.equal(ifElse.take('else'), 1);
assert.equal(ifElse.peakInput('a'), undefined);
assert.equal(ifElse.peakInput('b'), undefined);
ifDataCounter.reset();
ifDropCounter.reset();
elseDataCounter.reset();
elseDropCounter.reset();
ifElse.push('a', 2);
ifElse.push('b', true);
assert.equal(ifElse.peak('if'), 2);
assert.equal(ifDataCounter.count, 1);
assert.equal(ifDropCounter.count, 0);
assert.equal(elseDataCounter.count, 0);
assert.equal(elseDropCounter.count, 0);
assert.equal(ifElse.peakInput('a'), 2);
assert.equal(ifElse.peakInput('b'), true);
ifElse.push('b', false);
assert.equal(ifDataCounter.count, 1);
assert.equal(ifDropCounter.count, 1);
assert.equal(elseDataCounter.count, 1);
assert.equal(elseDropCounter.count, 0);
assert.equal(ifElse.peakInput('a'), 2);
assert.equal(ifElse.peakInput('b'), false);
assert.equal(ifElse.peak('if'), undefined);
assert.equal(ifElse.take('else'), 2);
assert.equal(ifElse.peakInput('a'), undefined);
assert.equal(ifElse.peakInput('b'), undefined);
ifDataCounter.reset();
ifDropCounter.reset();
elseDataCounter.reset();
elseDropCounter.reset();
ifElse.push('a', 2);
ifElse.push('b', false);
assert.equal(ifElse.peak('else'), 2);
assert.equal(ifDataCounter.count, 0);
assert.equal(ifDropCounter.count, 0);
assert.equal(elseDataCounter.count, 1);
assert.equal(elseDropCounter.count, 0);
assert.equal(ifElse.peakInput('a'), 2);
assert.equal(ifElse.peakInput('b'), false);
ifElse.push('b', true);
assert.equal(ifDataCounter.count, 1);
assert.equal(ifDropCounter.count, 0);
assert.equal(elseDataCounter.count, 1);
assert.equal(elseDropCounter.count, 1);
assert.equal(ifElse.peakInput('a'), 2);
assert.equal(ifElse.peakInput('b'), true);
assert.equal(ifElse.peak('else'), undefined);
assert.equal(ifElse.take('if'), 2);
assert.equal(ifElse.peakInput('a'), undefined);
assert.equal(ifElse.peakInput('b'), undefined);
ifElse.push('a', 2);
ifElse.push('b', true);
assert.equal(ifElse.peak('if'), 2);
assert.equal(ifElse.peakInput('a'), 2);
assert.equal(ifElse.peakInput('b'), true);
assert.equal(ifElse.takeInput('a'), 2);
assert.equal(ifElse.peak('if'), undefined);
assert.equal(ifElse.peak('else'), undefined);
assert.equal(ifElse.takeInput('b'), true);
ifElse.setInputConstant('a', true);
ifElse.setInputConstant('b', true);
ifElse.push('a', 1);
ifElse.push('b', false);
assert.equal(ifElse.take('if'), undefined);
assert.equal(ifElse.take('else'), 1);
assert.equal(ifElse.take('else'), 1);
assert.equal(ifElse.take('else'), 1);
assert.equal(ifElse.take('else'), 1);
assert.equal(ifElse.take('else'), 1);
//# sourceMappingURL=IfElse.js.map