| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>audit.js: basic tests</title> | 4 <title>audit.js: basic tests</title> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 7 <script src="../resources/audit.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <script> | 10 <script> |
| 11 var audit = Audit.createTaskRunner(); | 11 var audit = Audit.createTaskRunner({ requireResultFile: true }); |
| 12 |
| 12 | 13 |
| 13 // Basic assertion testing. | 14 // Basic assertion testing. |
| 14 audit.define('basic', function (task, should) { | 15 audit.define('basic', function (task, should) { |
| 15 task.describe('Simple unit tests for basic assertions.'); | 16 task.describe('Simple unit tests for basic assertions.'); |
| 16 | 17 |
| 17 should(OfflineAudioContext, 'OfflineAudioContext').exist(); | 18 should(OfflineAudioContext, 'OfflineAudioContext').exist(); |
| 18 should(function () { var foo = 0; }, 'Setting foo to 0').notThrow(); | 19 should(function () { var foo = 0; }, 'Setting foo to 0').notThrow(); |
| 19 should(function () { var foo = bar; }).throw('ReferenceError'); | 20 should(function () { var foo = bar; }).throw('ReferenceError'); |
| 20 should(3 < 5, '3 < 5').beTrue(); | 21 should(3 < 5, '3 < 5').beTrue(); |
| 21 should(false).beFalse(); | 22 should(false).beFalse(); |
| 22 should(1).beEqualTo(1) | 23 should(1).beEqualTo(1) |
| 23 should(1).notBeEqualTo(2) | 24 should(1).notBeEqualTo(2) |
| 24 should(typeof AudioContext.prototype).beEqualTo('object'); | 25 should(typeof AudioContext.prototype).beEqualTo('object'); |
| 25 should(2).beGreaterThan(1); | 26 should(2).beGreaterThan(1); |
| 26 should(2).beGreaterThanOrEqualTo(2); | 27 should(2).beGreaterThanOrEqualTo(2); |
| 27 should(1).beLessThan(2); | 28 should(1).beLessThan(2); |
| 28 should(1).beLessThanOrEqualTo(1); | 29 should(1).beLessThanOrEqualTo(1); |
| 29 | 30 |
| 30 let oac = new OfflineAudioContext(1, 128, 44100); | 31 let oac = new OfflineAudioContext(1, 128, 44100); |
| 31 Promise.all([ | 32 Promise.all([ |
| 32 should(oac.startRendering(), 'Start OAC rendering').beResolved(), | 33 should(oac.startRendering(), 'Start OAC rendering').beResolved(), |
| 33 should(oac.decodeAudioData()).beRejected() | 34 should(oac.decodeAudioData(), 'Decoding audio data with no argument') |
| 35 .beRejected() |
| 34 ]).then(task.done.bind(task)); | 36 ]).then(task.done.bind(task)); |
| 35 }); | 37 }); |
| 36 | 38 |
| 37 | 39 |
| 38 // Advanced, mostly array-based numerical testing. Note that some codes | 40 // Advanced, mostly array-based numerical testing. Note that some codes |
| 39 // are commented out to avoid the trybot failure. These failures are | 41 // are commented out to avoid the trybot failure. These failures are |
| 40 // intentional, to demonstrate how the detailed failure report works. | 42 // intentional, to demonstrate how the detailed failure report works. |
| 41 audit.define('numerical', function (task, should) { | 43 audit.define('numerical', function (task, should) { |
| 42 task.describe('Numerical assertion unit test.'); | 44 task.describe('Numerical assertion unit test.'); |
| 43 | 45 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 task.done(); | 63 task.done(); |
| 62 }); | 64 }); |
| 63 | 65 |
| 64 | 66 |
| 65 // You can enumerate tasks you want to execute in the order, or simply pass | 67 // You can enumerate tasks you want to execute in the order, or simply pass |
| 66 // no argument to run all the defined tasks. | 68 // no argument to run all the defined tasks. |
| 67 audit.run('numerical', 'basic'); | 69 audit.run('numerical', 'basic'); |
| 68 </script> | 70 </script> |
| 69 </body> | 71 </body> |
| 70 </html> | 72 </html> |
| OLD | NEW |