Tone.js/test/signal/Add.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

import ConstantOutput from "helper/ConstantOutput";
import Basic from "helper/Basic";
import Add from "Tone/signal/Add";
import Signal from "Tone/signal/Signal";
import Test from "helper/Test";
describe("Add", function(){
2015-08-24 15:17:21 +00:00
Basic(Add);
2015-08-24 15:17:21 +00:00
context("Addition", function(){
2015-08-24 15:17:21 +00:00
it("handles input and output connections", function(){
var add = new Add();
Test.connect(add);
Test.connect(add, 0);
Test.connect(add, 1);
add.connect(Test);
add.dispose();
});
2015-08-24 15:17:21 +00:00
it("correctly sums a signal and a number", function(){
return ConstantOutput(function(){
var signal = new Signal(0);
var adder = new Add(3);
signal.connect(adder);
adder.toMaster();
}, 3);
});
2015-08-24 15:17:21 +00:00
it("can handle negative values", function(){
return ConstantOutput(function(){
var signal = new Signal(10);
var adder = new Add(-1);
signal.connect(adder);
adder.toMaster();
}, 9);
});
2015-08-24 15:17:21 +00:00
it("can sum two signals", function(){
return ConstantOutput(function(){
var sigA = new Signal(1);
var sigB = new Signal(4);
var adder = new Add();
sigA.connect(adder, 0, 0);
sigB.connect(adder, 0, 1);
adder.toMaster();
}, 5);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
});
});