Skip to content

Commit e0dcacf

Browse files
committed
feat: update tests
1 parent 4953837 commit e0dcacf

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,9 @@ async function runTests(): Promise<void> {
21242124
await beeThreads
21252125
.run(() => {
21262126
const cause = new Error('original cause');
2127-
throw new Error('wrapper error', { cause });
2127+
const wrapper = new Error('wrapper error');
2128+
(wrapper as any).cause = cause;
2129+
throw wrapper;
21282130
})
21292131
.execute();
21302132
assert.fail('Should have thrown');
@@ -3183,7 +3185,7 @@ async function runTests(): Promise<void> {
31833185

31843186
await test('turbo(arr).map(fn) processes Float64Array', async () => {
31853187
const data = new Float64Array([1, 2, 3, 4, 5]);
3186-
const result = await beeThreads.turbo(data as any, { force: true }).map((x: number) => x * x);
3188+
const result = await beeThreads.turbo(data as unknown as number[], { force: true }).map((x: number) => x * x);
31873189

31883190
assert.deepStrictEqual(result, [1, 4, 9, 16, 25]);
31893191
});
@@ -3207,7 +3209,7 @@ async function runTests(): Promise<void> {
32073209
for (let i = 0; i < 100; i++) data[i] = i;
32083210

32093211
const { data: result, stats } = await beeThreads
3210-
.turbo(data as any, { force: true })
3212+
.turbo(data as unknown as number[], { force: true })
32113213
.mapWithStats((x: number) => Math.sqrt(x));
32123214

32133215
assert.ok(Array.isArray(result), 'Result should be array');
@@ -3283,7 +3285,7 @@ async function runTests(): Promise<void> {
32833285
// Turbo mode
32843286
const turboStart = Date.now();
32853287
const { stats } = await beeThreads
3286-
.turbo(data as any, { force: true })
3288+
.turbo(data as unknown as number[], { force: true })
32873289
.mapWithStats((x: number) => Math.sqrt(x) * Math.sin(x));
32883290
const turboTime = Date.now() - turboStart;
32893291

@@ -3301,7 +3303,7 @@ async function runTests(): Promise<void> {
33013303
// Turbo mode
33023304
const turboStart = Date.now();
33033305
const { stats } = await beeThreads
3304-
.turbo(data as any)
3306+
.turbo(data as unknown as number[])
33053307
.mapWithStats((x: number) => Math.sqrt(x) * Math.sin(x));
33063308
const turboTime = Date.now() - turboStart;
33073309

@@ -3396,7 +3398,7 @@ async function runTests(): Promise<void> {
33963398

33973399
await test('ISOLATION: pool stats remain consistent after turbo', async () => {
33983400
const statsBefore = beeThreads.getPoolStats();
3399-
const workersBefore = statsBefore.workers;
3401+
const workersBefore = statsBefore.normal.size;
34003402

34013403
// Run turbo
34023404
await beeThreads.turbo([1, 2, 3, 4, 5], { force: true }).map((x: number) => x * 2);
@@ -3405,7 +3407,7 @@ async function runTests(): Promise<void> {
34053407
await bee((x: number) => x + 1)(5);
34063408

34073409
const statsAfter = beeThreads.getPoolStats();
3408-
const workersAfter = statsAfter.workers;
3410+
const workersAfter = statsAfter.normal.size;
34093411

34103412
assert.strictEqual(workersBefore, workersAfter, 'Worker count must remain stable');
34113413
});
@@ -3589,8 +3591,10 @@ async function runTests(): Promise<void> {
35893591
section('Turbo Mode - Coexistence with Other Features');
35903592

35913593
await test('COEXIST: turbo with context + normal bee with context', async () => {
3592-
const turboCtx = { multiplier: 5 };
3593-
const beeCtx = { offset: 100 };
3594+
const multiplier = 5;
3595+
const offset = 100;
3596+
const turboCtx = { multiplier };
3597+
const beeCtx = { offset };
35943598

35953599
const turboResult = await beeThreads
35963600
.turbo([1, 2, 3], { force: true, context: turboCtx })
@@ -3681,7 +3685,7 @@ async function runTests(): Promise<void> {
36813685
// Measure turbo
36823686
const turboStart = Date.now();
36833687
const { stats } = await beeThreads
3684-
.turbo(data as any)
3688+
.turbo(data as unknown as number[])
36853689
.mapWithStats((x: number) => Math.sqrt(x) * Math.sin(x));
36863690
const turboTime = Date.now() - turboStart;
36873691

@@ -4131,15 +4135,15 @@ async function runTests(): Promise<void> {
41314135

41324136
await test('max() handles Float64Array', async () => {
41334137
const data = new Float64Array([1.5, 2.5, 3.5, 4.5]);
4134-
const result = await beeThreads.max(data as any, { force: true }).map((x: number) => x * 2);
4138+
const result = await beeThreads.max(data as unknown as number[], { force: true }).map((x: number) => x * 2);
41354139

41364140
assert.strictEqual(result.length, 4, 'Float64Array processed');
41374141
assert.strictEqual(result[0], 3, 'First value correct');
41384142
assert.strictEqual(result[3], 9, 'Last value correct');
41394143
});
41404144

41414145
await test('STRESS: max() with concurrent operations', async () => {
4142-
const promises = [];
4146+
const promises: Promise<number[]>[] = [];
41434147

41444148
for (let i = 0; i < 5; i++) {
41454149
const data = new Array(10_000).fill(i);
@@ -4224,7 +4228,7 @@ async function runTests(): Promise<void> {
42244228

42254229
await test('worker() handles concurrent load', async () => {
42264230
const worker = beeThreads.worker('./test-workers/math-worker.js');
4227-
const promises = [];
4231+
const promises: Promise<unknown>[] = [];
42284232

42294233
for (let i = 0; i < 20; i++) {
42304234
promises.push(worker([i, i + 1, i + 2]));

0 commit comments

Comments
 (0)