OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html><head> |
| 3 <meta charset="utf-8"> |
| 4 <link rel="stylesheet" type="text/css" href="../unit.css" /> |
| 5 <script type="application/x-javascript" src="../unit.js"></script> |
| 6 <script type="application/x-javascript" src="../util.js"></script> |
| 7 <script type="application/x-javascript" src="quickCheckAPI.js"></script> |
| 8 <script type="application/x-javascript" src="argGenerators-C.js"></script> |
| 9 |
| 10 <script type="application/x-javascript"> |
| 11 |
| 12 // Test that all GL functions specified in ArgGenerators work |
| 13 // when called with randomly generated valid arguments |
| 14 Tests.testValidArgs = function() { |
| 15 var randomTestCount = 100; |
| 16 for (var name in ArgGenerators) { |
| 17 try { |
| 18 if (!GL[name]) |
| 19 throw (new Error(name + " is missing from the WebGL context")); |
| 20 var argGen = ArgGenerators[name]; |
| 21 var alreadyTriedArgs = {}; |
| 22 if (!argGen.generate) continue; |
| 23 // test each GL function with randomTestCount randomly generated valid arg
s |
| 24 argGeneratorTestRunner(argGen, function(args, gen, setupVars) { |
| 25 if (!gen.noAlreadyTriedCheck) { |
| 26 var src = Object.toSource(args); |
| 27 if (alreadyTriedArgs[src]) |
| 28 return true; |
| 29 |
| 30 alreadyTriedArgs[src] = true; |
| 31 } |
| 32 var ok = false; |
| 33 // if we have an validity checker, assert that the generated args are va
lid |
| 34 if (gen.checkArgValidity) |
| 35 assert("Valid args: "+name+"("+args.map(function(a){return Object.toSo
urce(a)}).join(",")+")", |
| 36 gen.checkArgValidity.apply(gen, args)); |
| 37 var rv; |
| 38 // assert that GL function works when called with valid args |
| 39 assertOk("This should work: "+name+"("+args.map(function(a){return Objec
t.toSource(a)}).join(",")+")", |
| 40 function(){rv = GL[name].apply(GL, args); ok = true;}); |
| 41 // if we need to cleanup the return value, do it here |
| 42 // e.g. calling gl.deleteBuffer(rv) after testing gl.createBuffer() abov
e |
| 43 if (gen.returnValueCleanup) |
| 44 assertOk("Cleaning up return value after "+name+"("+args.map(function(
a){return Object.toSource(a)}).join(",")+")", |
| 45 function() { gen.returnValueCleanup(rv); }); |
| 46 return ok; |
| 47 }, argGen.testCount || randomTestCount); |
| 48 } catch(e) { |
| 49 testFailed(name, e.name, formatError(e)); |
| 50 } |
| 51 } |
| 52 } |
| 53 |
| 54 </script> |
| 55 <style>canvas{position:absolute;}</style> |
| 56 </head><body> |
| 57 </body></html> |
OLD | NEW |