"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 system_1 = require("../../util/system");
const spec = require('./RangeRec.json');
const Range = (0, fromSpec_1.fromSpec)(spec, _specs_1.default, {});
const range = new Range(system_1.system);
false && (0, debug_1.watchUnitAndLog)(range);
false && (0, debug_1.watchGraphAndLog)(range);
false && (0, debug_1.watchTreeAndLog)(range);
range.play();
range.push('a', 5);
range.push('b', 5);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 5);
range.push('b', 5);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 3);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 3);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 3);
range.push('b', 2);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 3);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 4);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), 3);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 5);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), 3);
assert.equal(range.take('i'), 4);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 2);
range.push('a', 1);
range.push('b', 1);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 2);
range.push('b', 4);
assert.equal(range.peakInput('a'), 2);
assert.equal(range.peakInput('b'), 4);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), 3);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', -2);
range.push('b', -1);
assert.equal(range.peakInput('a'), -2);
assert.equal(range.peakInput('b'), -1);
assert.equal(range.take('i'), -2);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 2);
assert.equal(range.peak('i'), 0);
range.push('a', 1);
assert.equal(range.take('i'), 1);
assert.equal(range.peak('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 2);
assert.equal(range.take('i'), 0);
range.push('b', 1);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 2);
assert.equal(range.peak('i'), 0);
range.push('a', 2);
assert.equal(range.peak('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 2);
assert.equal(range.take('i'), 0);
assert.equal(range.peakOutput('i'), 1);
assert.equal(range.takeInput('b'), 2);
assert.equal(range.take('i'), undefined);
assert.equal(range.takeInput('a'), 0);
assert.equal(range.peakInput('b'), undefined);
range.setInputConstant('a', true);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 2);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.take('i'), undefined);
range.setInputConstant('a', false);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), undefined);
range.push('b', 1);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), undefined);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
range.setInputConstant('a', true);
range.setInputConstant('b', true);
range.push('a', 0);
range.push('b', 1);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 1);
assert.equal(range.take('i'), 0);
assert.equal(range.peakInput('a'), 0);
assert.equal(range.peakInput('b'), 1);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 0);
range.setInputConstant('a', true);
range.setInputConstant('b', true);
range.push('a', 0);
range.push('b', 2);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
range.setInputConstant('a', true);
range.setInputConstant('b', true);
range.push('a', 0);
range.push('b', 3);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
assert.equal(range.take('i'), 2);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
assert.equal(range.take('i'), 2);
range.setInputConstant('a', false);
range.setInputConstant('b', false);
assert.equal(range.take('i'), 0);
assert.equal(range.take('i'), 1);
assert.equal(range.take('i'), 2);
assert.equal(range.peakInput('a'), undefined);
assert.equal(range.peakInput('b'), undefined);
// // infinite loop
// range.setInputConstant('a', true)
// range.setInputConstant('b', true)
// range.setOutputIgnored('i', true)
// range.push('a', 0)
// range.push('b', 2)
//# sourceMappingURL=RangeRec.js.map