| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 41adb54 commit a49d543
83 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,8 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const common = require('../../common'); | |
| 4 | - const assert = require('assert'); | ||
| 5 | 4 | const { testResolveAsync } = require(`./build/${common.buildType}/binding`); | |
| 6 | 5 | ||
| 7 | 6 | // Checks that resolving promises from C++ works. | |
| 8 | 7 | ||
| 9 | - let called = false; | ||
| 10 | - testResolveAsync().then(() => { called = true; }); | ||
| 11 | - | ||
| 12 | - process.on('beforeExit', common.mustCall(() => { assert(called); })); | ||
| 8 | + testResolveAsync().then(common.mustCall()); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,6 +106,7 @@ function fireErr5() { | |||
| 106 | 106 | const makeOrphan = vm.compileFunction(`(${String(() => { | |
| 107 | 107 | async function main() { | |
| 108 | 108 | await null; | |
| 109 | + // eslint-disable-next-line node-core/must-call-assert | ||
| 109 | 110 | Promise.resolve().then(() => { | |
| 110 | 111 | throw new Error('err5'); | |
| 111 | 112 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,11 +11,11 @@ async function main() { | |||
| 11 | 11 | assert.strictEqual(asyncLocalStorage.getStore().get('a'), 1); | |
| 12 | 12 | throw err; | |
| 13 | 13 | }); | |
| 14 | - await assert.rejects(new Promise((resolve, reject) => { | ||
| 14 | + await assert.rejects(new Promise((resolve) => { | ||
| 15 | 15 | asyncLocalStorage.run(new Map(), () => { | |
| 16 | 16 | const store = asyncLocalStorage.getStore(); | |
| 17 | 17 | store.set('a', 1); | |
| 18 | - next().then(resolve, reject); | ||
| 18 | + resolve(next()); | ||
| 19 | 19 | }); | |
| 20 | 20 | }), err); | |
| 21 | 21 | assert.strictEqual(asyncLocalStorage.getStore(), undefined); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,6 @@ store.run(data, common.mustCall(() => { | |||
| 48 | 48 | // Returning a thenable in a then handler | |
| 49 | 49 | store.run(data, common.mustCall(() => { | |
| 50 | 50 | assert.strictEqual(store.getStore(), data); | |
| 51 | - Promise.resolve().then(() => thenable()); | ||
| 51 | + Promise.resolve().then(() => thenable()).then(common.mustCall()); | ||
| 52 | 52 | assert.strictEqual(store.getStore(), data); | |
| 53 | 53 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,9 +64,9 @@ function testPromise() { | |||
| 64 | 64 | assert.strictEqual(activeId, res.asyncId()); | |
| 65 | 65 | res.emitDestroy(); | |
| 66 | 66 | // Promise has higher prio than emit destroy | |
| 67 | - Promise.resolve().then(common.mustCall(() => | ||
| 68 | - assert.strictEqual(activeId, res.asyncId())), | ||
| 69 | - ); | ||
| 67 | + Promise.resolve().then(common.mustCall(() => { | ||
| 68 | + assert.strictEqual(activeId, res.asyncId()); | ||
| 69 | + })); | ||
| 70 | 70 | } | |
| 71 | 71 | ||
| 72 | 72 | async function testAwait() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ const p = new Promise(common.mustCall(function executor(resolve) { | |||
| 17 | 17 | p.then(function afterResolution(val) { | |
| 18 | 18 | assert.strictEqual(val, 5); | |
| 19 | 19 | return val; | |
| 20 | - }); | ||
| 20 | + }).then(common.mustCall()); | ||
| 21 | 21 | ||
| 22 | 22 | // Init hooks after chained promise is created | |
| 23 | 23 | const hooks = initHooks(); | |
@@ -34,7 +34,7 @@ process.on('exit', function onexit() { | |||
| 34 | 34 | const as = hooks.activitiesOfTypes('PROMISE'); | |
| 35 | 35 | const unknown = hooks.activitiesOfTypes('Unknown'); | |
| 36 | 36 | assert.strictEqual(as.length, 0); | |
| 37 | - assert.strictEqual(unknown.length, 1); | ||
| 37 | + assert.strictEqual(unknown.length, 2); | ||
| 38 | 38 | ||
| 39 | 39 | const a0 = unknown[0]; | |
| 40 | 40 | assert.strictEqual(a0.type, 'Unknown'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,14 +16,14 @@ const hooks = initHooks(); | |||
| 16 | 16 | hooks.enable(); | |
| 17 | 17 | ||
| 18 | 18 | const p = new Promise(common.mustCall(executor)); | |
| 19 | - p.then(function afterResolution(val) { | ||
| 19 | + p.then(common.mustCall(function afterResolution(val) { | ||
| 20 | 20 | assert.strictEqual(val, 5); | |
| 21 | 21 | const as = hooks.activitiesOfTypes('PROMISE'); | |
| 22 | 22 | assert.strictEqual(as.length, 2); | |
| 23 | 23 | checkInvocations(as[0], { init: 1 }, 'after resolution parent promise'); | |
| 24 | 24 | checkInvocations(as[1], { init: 1, before: 1 }, | |
| 25 | 25 | 'after resolution child promise'); | |
| 26 | - }); | ||
| 26 | + })); | ||
| 27 | 27 | ||
| 28 | 28 | function executor(resolve) { | |
| 29 | 29 | const as = hooks.activitiesOfTypes('PROMISE'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,18 +16,18 @@ hooks.enable(); | |||
| 16 | 16 | p.then(function afterResolution(val) { | |
| 17 | 17 | assert.strictEqual(val, 5); | |
| 18 | 18 | const as = hooks.activitiesOfTypes('PROMISE'); | |
| 19 | - assert.strictEqual(as.length, 1); | ||
| 19 | + assert.strictEqual(as.length, 2); | ||
| 20 | 20 | checkInvocations(as[0], { init: 1, before: 1 }, | |
| 21 | 21 | 'after resolution child promise'); | |
| 22 | 22 | return val; | |
| 23 | - }); | ||
| 23 | + }).then(common.mustCall()); | ||
| 24 | 24 | ||
| 25 | 25 | process.on('exit', function onexit() { | |
| 26 | 26 | hooks.disable(); | |
| 27 | 27 | hooks.sanityCheck('PROMISE'); | |
| 28 | 28 | ||
| 29 | 29 | const as = hooks.activitiesOfTypes('PROMISE'); | |
| 30 | - assert.strictEqual(as.length, 1); | ||
| 30 | + assert.strictEqual(as.length, 2); | ||
| 31 | 31 | ||
| 32 | 32 | const a0 = as[0]; | |
| 33 | 33 | assert.strictEqual(a0.type, 'PROMISE'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ const server = http.createServer(common.mustCall((req, res) => { | |||
| 20 | 20 | console.log('Responding to /first'); | |
| 21 | 21 | res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| 22 | 22 | res.end('Response for /first'); | |
| 23 | - }); | ||
| 23 | + }).then(common.mustCall()); | ||
| 24 | 24 | } else if (req.url === '/second') { | |
| 25 | 25 | // Respond immediately for the second request | |
| 26 | 26 | res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ const server = https.createServer({ | |||
| 31 | 31 | console.log('Responding to /first'); | |
| 32 | 32 | res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| 33 | 33 | res.end('Response for /first'); | |
| 34 | - }); | ||
| 34 | + }).then(common.mustCall()); | ||
| 35 | 35 | } else if (req.url === '/second') { | |
| 36 | 36 | // Respond immediately for the second request | |
| 37 | 37 | res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments