MCPcopy Create free account
hub / github.com/nodejs/node / assertEqualsAsync

Function assertEqualsAsync

deps/v8/test/mjsunit/es8/async-function-try-finally.js:41–66  ·  view source on GitHub ↗
(expected, run, msg)

Source from the content-addressed store, hash-verified

39};
40
41function 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
68function resolveLater(value) {
69 return new Promise(function(resolve) {

Callers 1

Calls 7

runFunction · 0.70
PrettyPrintFunction · 0.50
assertFalseFunction · 0.50
assertTrueFunction · 0.50
assertEqualsFunction · 0.50
toStringMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected