Tone.js/test/signal/Abs.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-10-26 04:48:51 +00:00
define(["Test", "Tone/signal/Abs", "helper/Basic", "Tone/signal/Signal", "helper/ConstantOutput"],
2017-12-30 16:26:29 +00:00
function (Test, Abs, BasicTest, Signal, ConstantOutput) {
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
describe("Abs", function(){
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
BasicTest(Abs);
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
context("Absolute Value", function(){
2015-08-24 15:17:21 +00:00
2017-12-30 16:26:29 +00:00
it("handles input and output connections", function(){
2017-10-26 04:48:51 +00:00
var abs = new Abs();
2017-12-30 16:26:29 +00:00
Test.connect(abs);
abs.connect(Test);
abs.dispose();
});
it("outputs the same value for positive values", function(){
return ConstantOutput(function(){
var signal = new Signal(0.4);
var abs = new Abs();
signal.connect(abs);
abs.toMaster();
}, 0.4);
});
it("outputs 0 when the input is 0", function(){
return ConstantOutput(function(){
var signal = new Signal(0);
var abs = new Abs();
signal.connect(abs);
abs.toMaster();
}, 0);
});
it("outputs the absolute value for negative numbers", function(){
return ConstantOutput(function(){
var signal = new Signal(-0.3);
var abs = new Abs();
signal.connect(abs);
abs.toMaster();
}, 0.3);
});
2015-08-24 15:17:21 +00:00
});
});
});