mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
silencing warnings in API Tests
This commit is contained in:
parent
1559b8275a
commit
d9d7e4edcf
1 changed files with 35 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
|||
define(["Test", "Tone/type/Type", "Tone/core/Transport", "Tone/type/Time", "Tone/type/Frequency"],
|
||||
define(["Test", "Tone/type/Type", "Tone/core/Transport", "Tone/type/Time", "Tone/type/Frequency"],
|
||||
function (Test, Type, Transport, Time, Frequency) {
|
||||
|
||||
//modified from http://stackoverflow.com/questions/15298912/javascript-generating-combinations-from-n-arrays-with-m-elements
|
||||
|
@ -67,26 +67,37 @@ function (Test, Type, Transport, Time, Frequency) {
|
|||
}
|
||||
}
|
||||
|
||||
function silenceWarning(cb){
|
||||
var warning = console.warn;
|
||||
console.warn = function(){};
|
||||
cb();
|
||||
console.warn = warning;
|
||||
}
|
||||
|
||||
return {
|
||||
method : function(constructor, fn, args, consArgs){
|
||||
|
||||
it (fn+" ("+args.join(", ") + ")", function(){
|
||||
var permutations = generateArgs(args);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var instance = new constructor(consArgs);
|
||||
instance[fn].apply(instance, permutations[i]);
|
||||
instance.dispose();
|
||||
}
|
||||
silenceWarning(function(){
|
||||
var permutations = generateArgs(args);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var instance = new constructor(consArgs);
|
||||
instance[fn].apply(instance, permutations[i]);
|
||||
instance.dispose();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
member : function(constructor, member, param, consArgs){
|
||||
it (member+" = "+param, function(){
|
||||
var permutations = generateArgs([param]);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var instance = new constructor(consArgs);
|
||||
instance[member] = permutations[i];
|
||||
instance.dispose();
|
||||
}
|
||||
silenceWarning(function(){
|
||||
var permutations = generateArgs([param]);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var instance = new constructor(consArgs);
|
||||
instance[member] = permutations[i];
|
||||
instance.dispose();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
constructor : function(constructor, args){
|
||||
|
@ -99,15 +110,17 @@ function (Test, Type, Transport, Time, Frequency) {
|
|||
}
|
||||
|
||||
it ("constructor ( "+ argString + " )", function(){
|
||||
var permutations = generateArgs(args);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var Temp = function(){}; // temporary constructor
|
||||
Temp.prototype = constructor.prototype;
|
||||
var tmpInst = new Temp();
|
||||
constructor.apply(tmpInst, permutations[i]);
|
||||
tmpInst.dispose();
|
||||
}
|
||||
silenceWarning(function(){
|
||||
var permutations = generateArgs(args);
|
||||
for (var i = 0; i < permutations.length; i++){
|
||||
var Temp = function(){}; // temporary constructor
|
||||
Temp.prototype = constructor.prototype;
|
||||
var tmpInst = new Temp();
|
||||
constructor.apply(tmpInst, permutations[i]);
|
||||
tmpInst.dispose();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue