mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
testing changes.
This commit is contained in:
parent
0270b3c9e0
commit
a38f50fd70
4 changed files with 104 additions and 69 deletions
|
@ -7,6 +7,7 @@
|
|||
* new PWMOscillator
|
||||
* OmniOscillator which combines PWMOscillator, Oscillator, and PulseOscillator into one
|
||||
* Build cleans up global which it defined - leave no trace
|
||||
* Deprecated Tone.Threshold - new class Tone.GreaterThanZero
|
||||
|
||||
|
||||
### r2 - Getting Physical
|
||||
|
|
|
@ -16,7 +16,7 @@ var maxTimeout = 1000;
|
|||
|
||||
var allTests = ["tests/Core", "tests/Timing", "tests/Signal", "tests/SignalComparison",
|
||||
"tests/SignalMath", "tests/Transport", "tests/Sources", "tests/Components", "tests/Effect", "tests/Instruments"];
|
||||
// var allTests = ["tests/Core", "tests/Transport", "tests/Sources"];
|
||||
// var allTests = ["tests/Core", "tests/SignalComparison"];
|
||||
|
||||
require(allTests, function(){
|
||||
mocha.run();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* global it, describe, maxTimeout */
|
||||
|
||||
define(["tests/Core", "chai", "Tone/signal/Signal", "Tone/source/Oscillator",
|
||||
"Tone/signal/Threshold", "Tone/signal/Switch", "Tone/signal/Route", "Tone/signal/Select", "tests/Common"],
|
||||
function(core, chai, Signal, Oscillator, Threshold, Switch, Route, Select, Test){
|
||||
"Tone/signal/Switch", "Tone/signal/Route", "Tone/signal/Select", "tests/Common"],
|
||||
function(core, chai, Signal, Oscillator, Switch, Route, Select, Test){
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
|
@ -92,64 +92,6 @@ function(core, chai, Signal, Oscillator, Threshold, Switch, Route, Select, Test)
|
|||
});
|
||||
});
|
||||
|
||||
describe("Tone.Threshold", function(){
|
||||
this.timeout(maxTimeout);
|
||||
|
||||
it("can be created and disposed", function(){
|
||||
var thresh = new Threshold();
|
||||
thresh.dispose();
|
||||
Test.wasDisposed(thresh, expect);
|
||||
});
|
||||
|
||||
it("thresholds an incoming signal to 0 when it is below the thresh", function(done){
|
||||
var signal, thresh;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0.1);
|
||||
thresh = new Threshold(0.5);
|
||||
signal.connect(thresh);
|
||||
thresh.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(0);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
thresh.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("thresholds an incoming signal to 1 when it is above the thresh", function(done){
|
||||
var signal, thresh;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0.8);
|
||||
thresh = new Threshold(0.75);
|
||||
signal.connect(thresh);
|
||||
thresh.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(1);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
thresh.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("outputs 1 when the values are the same", function(done){
|
||||
var signal, thresh;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0.8);
|
||||
thresh = new Threshold(0.8);
|
||||
signal.connect(thresh);
|
||||
thresh.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(1);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
thresh.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tone.Switch", function(){
|
||||
this.timeout(maxTimeout);
|
||||
|
||||
|
|
|
@ -1,18 +1,93 @@
|
|||
/* global it, describe, maxTimeout */
|
||||
|
||||
define(["tests/Core", "chai", "Tone/signal/Signal", "Tone/signal/EqualZero",
|
||||
"Tone/signal/Equal", "Tone/signal/GreaterThan", "Tone/signal/LessThan", "tests/Common"],
|
||||
function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
||||
"Tone/signal/Equal", "Tone/signal/GreaterThan", "Tone/signal/LessThan",
|
||||
"tests/Common", "Tone/signal/GreaterThanZero"],
|
||||
function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test, GreaterThanZero){
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("Tone.GreaterThanZero", function(){
|
||||
this.timeout(maxTimeout);
|
||||
|
||||
it("can be created and disposed", function(){
|
||||
var gtz = new GreaterThanZero(2);
|
||||
gtz.dispose();
|
||||
Test.wasDisposed(gtz);
|
||||
});
|
||||
|
||||
it("outputs 0 when the incoming signal is equal to zero", function(done){
|
||||
var signal, gtz;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0);
|
||||
gtz = new GreaterThanZero();
|
||||
signal.connect(gtz);
|
||||
gtz.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(0);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
gtz.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("outputs 0 when the incoming signal is less than zero", function(done){
|
||||
var signal, gtz;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(-1);
|
||||
gtz = new GreaterThanZero();
|
||||
signal.connect(gtz);
|
||||
gtz.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(0);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
gtz.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("outputs 1 when the incoming signal is greater than zero", function(done){
|
||||
var signal, gtz;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0.5);
|
||||
gtz = new GreaterThanZero();
|
||||
signal.connect(gtz);
|
||||
gtz.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(1);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
gtz.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("can handle values very close to 0", function(done){
|
||||
var signal, gtz;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(0.00001);
|
||||
gtz = new GreaterThanZero();
|
||||
signal.connect(gtz);
|
||||
gtz.connect(dest);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(1);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
gtz.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tone.EqualZero", function(){
|
||||
this.timeout(maxTimeout);
|
||||
|
||||
it("can be created and disposed", function(){
|
||||
var ez = new EqualZero();
|
||||
ez.dispose();
|
||||
Test.wasDisposed(ez, expect);
|
||||
Test.wasDisposed(ez);
|
||||
});
|
||||
|
||||
it("outputs 1 when the incoming signal is 0", function(done){
|
||||
|
@ -70,7 +145,7 @@ function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
|||
it("can be created and disposed", function(){
|
||||
var eq = new Equal(3);
|
||||
eq.dispose();
|
||||
Test.wasDisposed(eq, expect);
|
||||
Test.wasDisposed(eq);
|
||||
});
|
||||
|
||||
it("outputs 1 when the incoming signal is equal to the value", function(done){
|
||||
|
@ -126,9 +201,9 @@ function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
|||
this.timeout(maxTimeout);
|
||||
|
||||
it("can be created and disposed", function(){
|
||||
var gt = new GreaterThan();
|
||||
var gt = new GreaterThan(0);
|
||||
gt.dispose();
|
||||
Test.wasDisposed(gt, expect);
|
||||
Test.wasDisposed(gt);
|
||||
});
|
||||
|
||||
it("outputs 1 when the incoming signal is greater than the value", function(done){
|
||||
|
@ -179,7 +254,7 @@ function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
|||
});
|
||||
});
|
||||
|
||||
it("set be set to a new value", function(done){
|
||||
it("can be set to a new value", function(done){
|
||||
var signal, gt;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(100);
|
||||
|
@ -203,7 +278,7 @@ function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
|||
it("can be created and disposed", function(){
|
||||
var lt = new LessThan(2);
|
||||
lt.dispose();
|
||||
Test.wasDisposed(lt, expect);
|
||||
Test.wasDisposed(lt);
|
||||
});
|
||||
|
||||
it("outputs 1 when the incoming signal is less than the value", function(done){
|
||||
|
@ -253,5 +328,22 @@ function(core, chai, Signal, EqualZero, Equal, GreaterThan, LessThan, Test){
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("can be set to a new value", function(done){
|
||||
var signal, lt;
|
||||
Test.offlineTest(0.2, function(dest){
|
||||
signal = new Signal(100);
|
||||
lt = new LessThan(200);
|
||||
signal.connect(lt);
|
||||
lt.connect(dest);
|
||||
lt.setValue(50);
|
||||
}, function(sample){
|
||||
expect(sample).to.equal(0);
|
||||
}, function(){
|
||||
signal.dispose();
|
||||
lt.dispose();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue