Tone.js/test/signal/Subtract.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-02-20 21:40:41 +00:00
define(["helper/ConstantOutput", "Tone/signal/Subtract", "helper/Basic",
2018-05-18 16:07:20 +00:00
"helper/Test", "Tone/source/Oscillator", "Tone/signal/Signal"],
function(ConstantOutput, Subtract, Basic, Test, Oscillator, Signal){
2015-08-24 15:17:21 +00:00
describe("Subtract", function(){
Basic(Subtract);
context("Subtraction", function(){
it("handles input and output connections", function(){
var subtract = new Subtract();
Test.connect(subtract, 0);
Test.connect(subtract, 1);
subtract.connect(Test);
subtract.dispose();
});
2017-02-20 21:40:41 +00:00
it("correctly subtracts a signal and a number", function(){
return ConstantOutput(function(){
var signal = new Signal(0);
var sub = new Subtract(3);
2015-08-24 15:17:21 +00:00
signal.connect(sub);
2017-02-20 21:40:41 +00:00
sub.toMaster();
}, -3);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
it("can set the scalar value after construction", function(){
return ConstantOutput(function(){
var signal = new Signal(-2);
var sub = new Subtract(0);
2015-08-24 15:17:21 +00:00
sub.value = 4;
signal.connect(sub);
2017-02-20 21:40:41 +00:00
sub.toMaster();
}, -6);
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(4);
var sub = new Subtract(-2);
2015-08-24 15:17:21 +00:00
signal.connect(sub);
2017-02-20 21:40:41 +00:00
sub.toMaster();
}, 6);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
it("can subtract two signals", function(){
return ConstantOutput(function(){
var sigA = new Signal(1);
var sigB = new Signal(4);
var sub = new Subtract();
2015-08-24 15:17:21 +00:00
sigA.connect(sub, 0, 0);
sigB.connect(sub, 0, 1);
2017-02-20 21:40:41 +00:00
sub.toMaster();
}, -3);
2015-08-24 15:17:21 +00:00
});
});
});
2017-12-30 16:26:29 +00:00
});