mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
ed71d8141b
no longer using AMD (require.js) style imports, and beginning to move to es6 "import/export" statements everywhere.
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import Test from "helper/Test";
|
|
import Abs from "Tone/signal/Abs";
|
|
import BasicTest from "helper/Basic";
|
|
import Signal from "Tone/signal/Signal";
|
|
import ConstantOutput from "helper/ConstantOutput";
|
|
|
|
describe("Abs", function(){
|
|
|
|
BasicTest(Abs);
|
|
|
|
context("Absolute Value", function(){
|
|
|
|
it("handles input and output connections", function(){
|
|
var abs = new Abs();
|
|
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);
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|