instrument tests

fixed dispose methods bc of tests.
This commit is contained in:
Yotam Mann 2014-09-09 15:30:36 -04:00
parent 040536a3b7
commit cc95ee6caf
7 changed files with 68 additions and 8 deletions

View file

@ -171,11 +171,13 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
} }
this.frequency.dispose(); this.frequency.dispose();
this.Q.dispose(); this.Q.dispose();
this.detune.dispose();
this.gain.dispose(); this.gain.dispose();
this._filters = null; this._filters = null;
this.frequency = null; this.frequency = null;
this.Q = null; this.Q = null;
this.gain = null; this.gain = null;
this.detune = null;
}; };
return Tone.Filter; return Tone.Filter;

View file

@ -220,7 +220,7 @@ function(Tone){
/** /**
* clean up * clean up
*/ */
Tone.DuoSynth.dispose = function(){ Tone.DuoSynth.prototype.dispose = function(){
Tone.Monophonic.prototype.dispose.call(this); Tone.Monophonic.prototype.dispose.call(this);
this.voice0.dispose(); this.voice0.dispose();
this.voice1.dispose(); this.voice1.dispose();

View file

@ -177,7 +177,7 @@ function(Tone){
/** /**
* clean up * clean up
*/ */
Tone.FMSynth.dispose = function(){ Tone.FMSynth.prototype.dispose = function(){
Tone.Monophonic.prototype.dispose.call(this); Tone.Monophonic.prototype.dispose.call(this);
this.carrier.dispose(); this.carrier.dispose();
this.modulator.dispose(); this.modulator.dispose();

View file

@ -155,14 +155,15 @@ function(Tone){
this.envelope.dispose(); this.envelope.dispose();
this.filterEnvelope.dispose(); this.filterEnvelope.dispose();
this.filter.dispose(); this.filter.dispose();
this.detune.dispose(); this._amplitude.disconnect();
this._unison.dispose();
this.oscillator = null; this.oscillator = null;
this.filterEnvelope = null; this.filterEnvelope = null;
this.envelope = null; this.envelope = null;
this.filter = null; this.filter = null;
this.detune = null; this.detune = null;
this._unison = null; this._amplitude = null;
this.frequency = null;
this.detune = null;
}; };
return Tone.MonoSynth; return Tone.MonoSynth;

View file

@ -122,12 +122,13 @@ function(Tone){
/** /**
* clean up * clean up
*/ */
Tone.MultiSampler.dispose = function(){ Tone.MultiSampler.prototype.dispose = function(){
Tone.prototype.dispose.call(this); Tone.prototype.dispose.call(this);
for (var samp in this.samples){ for (var samp in this.samples){
this.samples[samp].dispose(); this.samples[samp].dispose();
this.samples[samp] = null; this.samples[samp] = null;
} }
this.samples = null;
}; };
return Tone.MultiSampler; return Tone.MultiSampler;

View file

@ -30,8 +30,8 @@ function wasDisposed(obj, expect){
} }
var allTests = ["tests/Core", "tests/Timing", "tests/Signal", "tests/SignalComparison", var allTests = ["tests/Core", "tests/Timing", "tests/Signal", "tests/SignalComparison",
"tests/SignalMath", "tests/Transport", "tests/Sources", "tests/Components", "tests/Effect"]; "tests/SignalMath", "tests/Transport", "tests/Sources", "tests/Components", "tests/Effect", "tests/Instruments"];
// var allTests = ["tests/Core", "tests/SignalComparison"]; // var allTests = ["tests/Core", "tests/Instruments"];
require(allTests, function(){ require(allTests, function(){
mocha.run(); mocha.run();

56
test/tests/Instruments.js Normal file
View file

@ -0,0 +1,56 @@
/* global it, describe, wasDisposed */
define(["tests/Core", "chai", "Tone/instrument/DuoSynth", "Tone/instrument/MonoSynth", "Tone/instrument/FMSynth",
"Tone/instrument/PolySynth", "Tone/instrument/Sampler", "Tone/instrument/MultiSampler"],
function(Tone, chai, DuoSynth, MonoSynth, FMSynth, PolySynth, Sampler, MultiSampler){
var expect = chai.expect;
describe("Tone.MonoSynth", function(){
it("can be created and disposed", function(){
var ms = new MonoSynth();
ms.dispose();
wasDisposed(ms, expect);
});
});
describe("Tone.DuoSynth", function(){
it("can be created and disposed", function(){
var ds = new DuoSynth();
ds.dispose();
wasDisposed(ds, expect);
});
});
describe("Tone.FMSynth", function(){
it("can be created and disposed", function(){
var fms = new FMSynth();
fms.dispose();
wasDisposed(fms, expect);
});
});
describe("Tone.PolySynth", function(){
it("can be created and disposed", function(){
var ps = new PolySynth();
ps.dispose();
wasDisposed(ps, expect);
});
});
describe("Tone.Sampler", function(){
it("can be created and disposed", function(){
var samp = new Sampler();
samp.dispose();
wasDisposed(samp, expect);
});
});
describe("Tone.MultiSampler", function(){
it("can be created and disposed", function(){
var samp = new MultiSampler();
samp.dispose();
wasDisposed(samp, expect);
});
});
});