OLD | NEW |
(Empty) | |
| 1 // ArgGenerators contains argument generators for WebGL functions. |
| 2 // The argument generators are used for running random tests against the WebGL |
| 3 // functions. |
| 4 // |
| 5 // ArgGenerators is an object consisting of functionName : argGen -properties. |
| 6 // |
| 7 // functionName is a WebGL context function name and the argGen is an argument |
| 8 // generator object that encapsulates the requirements to run |
| 9 // randomly generated tests on the WebGL function. |
| 10 // |
| 11 // An argGen object has the following methods: |
| 12 // - setup -- set up state for testing the GL function, returns values |
| 13 // that need cleanup in teardown. Run once before entering a |
| 14 // test loop. |
| 15 // - teardown -- do cleanup on setup's return values after testing is complete |
| 16 // - generate -- generate a valid set of random arguments for the GL function |
| 17 // - returnValueCleanup -- do cleanup on value returned by the tested GL funct
ion |
| 18 // - cleanup -- do cleanup on generated arguments from generate |
| 19 // - checkArgValidity -- check if passed args are valid. Has a call signature |
| 20 // that matches generate's return value. Returns true |
| 21 // if args are valid, false if not. |
| 22 // |
| 23 // Example test loop that demonstrates how the function args and return |
| 24 // values flow together: |
| 25 // |
| 26 // var setupArgs = argGen.setup(); |
| 27 // for (var i=0; i<numberOfTests; i++) { |
| 28 // var generatedArgs = argGen.generate.apply(argGen, setupArgs); |
| 29 // var validArgs = argGen.checkArgValidity.apply(argGen, generatedArgs); |
| 30 // var rv = call the GL function with generatedArgs; |
| 31 // argGen.returnValueCleanup(rv); |
| 32 // argGen.cleanup.apply(argGen, generatedArgs); |
| 33 // } |
| 34 // argGen.teardown.apply(argGen, setupArgs); |
| 35 // |
| 36 ArgGenerators = { |
| 37 |
| 38 // GL functions in alphabetical order |
| 39 |
| 40 // B-1 |
| 41 |
| 42 bindAttribLocation : { |
| 43 generate : function() { |
| 44 var program = GL.createProgram(); |
| 45 return [program, randomVertexAttribute(), randomName()]; |
| 46 }, |
| 47 checkArgValidity : function(program, index, name) { |
| 48 return GL.isProgram(program) && isVertexAttribute(index) && isValidName(na
me); |
| 49 }, |
| 50 cleanup : function(program, index, name) { |
| 51 try { GL.deleteProgram(program); } catch(e) {} |
| 52 } |
| 53 } |
| 54 |
| 55 }; |
OLD | NEW |