Tone.js/test/signal/Add.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-05-18 16:07:20 +00:00
define(["helper/ConstantOutput", "helper/Basic", "Tone/signal/Add", "Tone/signal/Signal", "helper/Test"],
function(ConstantOutput, Basic, Add, Signal, Test){
2017-12-30 16:26:29 +00:00
describe("Add", function(){
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
Basic(Add);
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
context("Addition", function(){
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +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
2017-12-30 16:26:29 +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
2017-12-30 16:26:29 +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
2017-12-30 16:26:29 +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
});