(expected, run, msg)
| 39 | }; |
| 40 | |
| 41 | function assertEqualsAsync(expected, run, msg) { |
| 42 | var actual; |
| 43 | var hadValue = false; |
| 44 | var hadError = false; |
| 45 | var promise = run(); |
| 46 | |
| 47 | if (typeof promise !== "object" || typeof promise.then !== "function") { |
| 48 | throw new MjsUnitAssertionError( |
| 49 | "Expected " + run.toString() + |
| 50 | " to return a Promise, but it returned " + PrettyPrint(promise)); |
| 51 | } |
| 52 | |
| 53 | promise.then(function(value) { hadValue = true; actual = value; }, |
| 54 | function(error) { hadError = true; actual = error; }); |
| 55 | |
| 56 | assertFalse(hadValue || hadError); |
| 57 | |
| 58 | %PerformMicrotaskCheckpoint(); |
| 59 | |
| 60 | if (hadError) throw actual; |
| 61 | |
| 62 | assertTrue( |
| 63 | hadValue, "Expected '" + run.toString() + "' to produce a value"); |
| 64 | |
| 65 | assertEquals(expected, actual, msg); |
| 66 | }; |
| 67 | |
| 68 | function resolveLater(value) { |
| 69 | return new Promise(function(resolve) { |
no test coverage detected