From 2155d8bb7f995ee1dda7eb10bd594039b1fa76f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 11 Jun 2024 17:41:11 +0200 Subject: [PATCH] test: add mapExecute() test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/pools/abstract-pool.test.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index ec481d2c..fc346a64 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -1708,6 +1708,24 @@ describe('Abstract pool test suite', () => { await pool.destroy() }) + it('Verify mapExecute() is working', async () => { + const pool = new DynamicThreadPool( + Math.floor(numberOfWorkers / 2), + numberOfWorkers, + './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs' + ) + const results = await pool.mapExecute([{ n: 10 }, { n: 20 }, { n: 30 }, { n: 40 }], 'factorial') + expect(results).toStrictEqual([ + 3628800, + 2432902008176640000, + 2.6525285981219103e+32, + 8.159152832478977e+47, + ]) + expect(pool.info.executingTasks).toBe(0) + expect(pool.info.executedTasks).toBe(4) + await pool.destroy() + }) + it('Verify that task function objects worker is working', async () => { const pool = new DynamicThreadPool( Math.floor(numberOfWorkers / 2), -- 2.34.1