Tone.js/test/signal/Add.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-02-20 21:40:41 +00:00
define(["helper/ConstantOutput", "helper/Basic", "Tone/signal/Add", "Tone/signal/Signal", "Test"],
function (ConstantOutput, Basic, Add, Signal, Test) {
2015-08-24 15:17:21 +00:00
describe("Add", function(){
Basic(Add);
context("Addition", function(){
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();
});
2017-02-20 21:40:41 +00:00
it("correctly sums a signal and a number", function(){
return ConstantOutput(function(){
var signal = new Signal(0);
var adder = new Add(3);
2015-08-24 15:17:21 +00:00
signal.connect(adder);
2017-02-20 21:40:41 +00:00
adder.toMaster();
}, 3);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
it("can handle negative values", function(){
return ConstantOutput(function(){
var signal = new Signal(10);
var adder = new Add(-1);
2015-08-24 15:17:21 +00:00
signal.connect(adder);
2017-02-20 21:40:41 +00:00
adder.toMaster();
}, 9);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +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();
2015-08-24 15:17:21 +00:00
sigA.connect(adder, 0, 0);
sigB.connect(adder, 0, 1);
2017-02-20 21:40:41 +00:00
adder.toMaster();
}, 5);
2015-08-24 15:17:21 +00:00
});
});
2017-02-20 21:40:41 +00:00
});
2015-08-24 15:17:21 +00:00
});