silencing warnings in API Tests

This commit is contained in:
Yotam Mann 2017-09-15 17:46:22 -04:00
parent 1559b8275a
commit d9d7e4edcf

View file

@ -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) { function (Test, Type, Transport, Time, Frequency) {
//modified from http://stackoverflow.com/questions/15298912/javascript-generating-combinations-from-n-arrays-with-m-elements //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 { return {
method : function(constructor, fn, args, consArgs){ method : function(constructor, fn, args, consArgs){
it (fn+" ("+args.join(", ") + ")", function(){ it (fn+" ("+args.join(", ") + ")", function(){
var permutations = generateArgs(args); silenceWarning(function(){
for (var i = 0; i < permutations.length; i++){ var permutations = generateArgs(args);
var instance = new constructor(consArgs); for (var i = 0; i < permutations.length; i++){
instance[fn].apply(instance, permutations[i]); var instance = new constructor(consArgs);
instance.dispose(); instance[fn].apply(instance, permutations[i]);
} instance.dispose();
}
})
}); });
}, },
member : function(constructor, member, param, consArgs){ member : function(constructor, member, param, consArgs){
it (member+" = "+param, function(){ it (member+" = "+param, function(){
var permutations = generateArgs([param]); silenceWarning(function(){
for (var i = 0; i < permutations.length; i++){ var permutations = generateArgs([param]);
var instance = new constructor(consArgs); for (var i = 0; i < permutations.length; i++){
instance[member] = permutations[i]; var instance = new constructor(consArgs);
instance.dispose(); instance[member] = permutations[i];
} instance.dispose();
}
});
}); });
}, },
constructor : function(constructor, args){ constructor : function(constructor, args){
@ -99,15 +110,17 @@ function (Test, Type, Transport, Time, Frequency) {
} }
it ("constructor ( "+ argString + " )", function(){ it ("constructor ( "+ argString + " )", function(){
var permutations = generateArgs(args); silenceWarning(function(){
for (var i = 0; i < permutations.length; i++){ var permutations = generateArgs(args);
var Temp = function(){}; // temporary constructor for (var i = 0; i < permutations.length; i++){
Temp.prototype = constructor.prototype; var Temp = function(){}; // temporary constructor
var tmpInst = new Temp(); Temp.prototype = constructor.prototype;
constructor.apply(tmpInst, permutations[i]); var tmpInst = new Temp();
tmpInst.dispose(); constructor.apply(tmpInst, permutations[i]);
} tmpInst.dispose();
}
});
}); });
}, },
}; };
}); });