vitest-pool-assemblyscript 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -160,7 +160,7 @@ export default defineConfig({
160
160
  ### vitest 3.2.x Multiple-Project Config:
161
161
  ```typescript
162
162
  import { defineConfig, defineProject } from 'vitest/config';
163
- import { defineAssemblyScriptProject } from 'vitest-pool-assemblyscript/config';
163
+ import { defineAssemblyScriptProject } from 'vitest-pool-assemblyscript/v3/config';
164
164
 
165
165
  export default defineConfig({
166
166
  test: {
@@ -193,7 +193,7 @@ export default defineConfig({
193
193
 
194
194
  ### vitest 3.2.x Single-Project Config:
195
195
  ```typescript
196
- import { defineAssemblyScriptConfig } from 'vitest-pool-assemblyscript/config';
196
+ import { defineAssemblyScriptConfig } from 'vitest-pool-assemblyscript/v3/config';
197
197
 
198
198
  export default defineAssemblyScriptConfig({
199
199
  test: {
@@ -396,6 +396,8 @@ expect(1 + 1).toBe(2);
396
396
  expect("hello").toBe("hello");
397
397
  ```
398
398
 
399
+ > ⚠️ IMPORTANT: this matcher is currently too permissive with type comparison - it deems some numeric values of different types to be the same when they shouldn't actually be. The `toEqual()` matcher is more appropriate for these permissive sementics. Fix coming soon!
400
+
399
401
  ### `toBeCloseTo()`
400
402
  Checks if a floating point value is close to what you expect. Using exact equality with floating point numbers often doesn't work correctly, because small internal rounding occurs to be able to represent floats in binary. This rounding means intuitive comparisons will often fail.
401
403
 
@@ -412,7 +414,8 @@ Checks that two values have the same value (deep equality). Currently supports c
412
414
 
413
415
  Primitives, strings, and other object references are compared with `toBe()` rules.
414
416
 
415
- > ⚠️ Warning: Does not yet support user-defined object deep equality checking
417
+ > ⚠️ IMPORTANT: Does not yet support user-defined object deep equality checking. Coming soon!
418
+
416
419
  ```typescript
417
420
  expect([1, 2, 3]).toEqual([1, 2, 3]);
418
421
  expect(["one", "two", "three"]).toEqual(["one", "two", "three"]);
@@ -428,15 +431,22 @@ Alias for `toEqual()`. Currently no differences in AssemblyScript.
428
431
 
429
432
  ### `toBeTruthy()` & `toBeFalsey()`
430
433
  Check that a value is truthy or falsey. Falsey values are `0`, `false`, `""`, and `null`.
434
+
431
435
  ```typescript
432
436
  expect(1).toBeTruthy();
433
- expect(0).toBeFalsey();
434
437
  expect("hello").toBeTruthy();
435
- expect("").toBeFalsey();
438
+ expect("").toBeTruthy(); // <-- Empty String is TRUTHY in AS!
439
+
440
+ expect(0).toBeFalsey();
441
+ expect(NaN).toBeFalsey();
442
+ expect(null).toBeFalsey();
436
443
  ```
437
444
 
445
+ >⚠️ AS Quirk: Unlike in JavaScript, empty string is truthy in AssemblyScript because it is an object reference, not a primitive. An empty string is still an allocated object with a non-zero address, so it evaluates as truthy!
446
+
438
447
  ### `toBeNull()`
439
448
  Checks that a value is null (`usize(0)` in AssemblyScript).
449
+
440
450
  ```typescript
441
451
  const val: string | null = null;
442
452
  expect(val).toBeNull();
@@ -447,6 +457,7 @@ expect(false).not.toBeNull();
447
457
 
448
458
  ### `toBeNullable()`
449
459
  Checks that the type of the value is nullable (can hold `null`). This is a type-level check, not a value check — use `toBeNull()` to check if a value *is* null.
460
+
450
461
  ```typescript
451
462
  const val: string | null = null;
452
463
  expect(val).toBeNullable();
@@ -455,6 +466,7 @@ expect("hello").not.toBeNullable();
455
466
 
456
467
  ### `toBeNaN()`
457
468
  Checks that a floating point value is `NaN`.
469
+
458
470
  ```typescript
459
471
  expect(NaN).toBeNaN();
460
472
  expect(1.0).not.toBeNaN();
@@ -462,6 +474,7 @@ expect(1.0).not.toBeNaN();
462
474
 
463
475
  ### `toHaveLength()`
464
476
  Checks that an array or array-like value has the expected length.
477
+
465
478
  ```typescript
466
479
  expect([1, 2, 3]).toHaveLength(3);
467
480
  expect([]).toHaveLength(0);
@@ -471,14 +484,15 @@ expect("hello world").toHaveLength(11);
471
484
  ### `toThrowError()`
472
485
  Checks that a function throws an error when called. Optionally checks that the error message matches the provided string. Also available as `toThrow()`.
473
486
 
474
- >⚠️ Important: You must provide a void callback to expect() when using `toThrowError()`
475
-
476
- >ℹ️ Note: `toThrowError()` does not accept inversion using `expect().not.toThrowError()`
477
487
  ```typescript
478
488
  expect(() => { throw new Error("boom"); }).toThrowError();
479
489
  expect(() => { throw new Error("boom"); }).toThrowError("boom");
480
490
  ```
481
491
 
492
+ >⚠️ AS Quirk: You must provide a callback with a non-inferred type to expect() when using `toThrowError()`, e.g. `expect(() => { returnsNumber(); })` (definitely void) or `expect((): i32 => returnsNumber())` (explicit type)
493
+
494
+ >ℹ️ Note: `toThrowError()` does not accept inversion using `expect().not.toThrowError()`
495
+
482
496
  ### Planned Matchers
483
497
  `toBeDefined`, `toBeUndefined`, `toBeGreaterThan`, `toBeGreaterThanOrEqual`, `toBeLessThan`, `toBeLessThanOrEqual`, `toContain`, `toContainEqual`
484
498
 
@@ -190,7 +190,7 @@ export function equals<T, U>(actual: T, expected: U): bool {
190
190
  }
191
191
 
192
192
  export function truthyOrFalsey<T>(actual: T, expected: bool): bool {
193
- return !!actual == expected;
193
+ return actual ? expected == true : expected == false;
194
194
  }
195
195
 
196
196
  export function isNull<T>(value: T): bool {
@@ -33,7 +33,7 @@ declare function __end_expect_throw(): void;
33
33
 
34
34
 
35
35
  function itemMessageString<T>(item: T): string {
36
- if (isNull(item)) return "<null>";
36
+ if (isNull(item)) return "null";
37
37
  if (nan(item)) return "NaN";
38
38
 
39
39
  if (isReference<T>()) {
@@ -53,7 +53,7 @@ function itemMessageString<T>(item: T): string {
53
53
 
54
54
  function arrayMessageString<T extends ArrayLike<unknown>>(array: T): string {
55
55
  if (isNullable<T>(array) && array == null) {
56
- return "<null>";
56
+ return "null";
57
57
  }
58
58
 
59
59
  let str = "[";
@@ -1,5 +1,5 @@
1
- import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-8KKo9Hbf.mjs";
2
- import "../custom-provider-options-CF5C1kXb.mjs";
1
+ import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-DasF0_PX.mjs";
2
+ import "../custom-provider-options-CVLz0nAp.mjs";
3
3
  import { ConfigEnv, UserWorkspaceConfig, ViteUserConfig } from "vitest/config";
4
4
 
5
5
  //#region src/config/config-helpers-v3.d.ts
@@ -1,4 +1,4 @@
1
- import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-8KKo9Hbf.mjs";
2
- import "../custom-provider-options-CF5C1kXb.mjs";
3
- import { createAssemblyScriptPool } from "../pool-runner-init-CEwLyNI3.mjs";
1
+ import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-DasF0_PX.mjs";
2
+ import "../custom-provider-options-CVLz0nAp.mjs";
3
+ import { createAssemblyScriptPool } from "../pool-runner-init-8vx-5Pb4.mjs";
4
4
  export { type AssemblyScriptPoolOptions, type WasmImportsFactory, type WasmImportsFactoryInfo, createAssemblyScriptPool };
@@ -1,4 +1,4 @@
1
- import { HybridProviderOptions } from "./types-8KKo9Hbf.mjs";
1
+ import { HybridProviderOptions } from "./types-DasF0_PX.mjs";
2
2
  import { CoverageV8Options } from "vitest/node";
3
3
 
4
4
  //#region src/config/custom-provider-options.d.ts
@@ -23,4 +23,4 @@ declare module "vitest/node" {
23
23
  customProviderModule: string;
24
24
  }
25
25
  }
26
- //# sourceMappingURL=custom-provider-options-CF5C1kXb.d.mts.map
26
+ //# sourceMappingURL=custom-provider-options-CVLz0nAp.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-provider-options-CF5C1kXb.d.mts","names":[],"sources":["../src/config/custom-provider-options.ts"],"mappings":";;;;;;AAE2C;;;;;;;;;;;;;YAiB/B,qBAAA,SAA8B,qBAAA,EAAuB,IAAA,CAAK,iBAAA;IAClE,QAAA;IAGD;IAAA,oBAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"custom-provider-options-CVLz0nAp.d.mts","names":[],"sources":["../src/config/custom-provider-options.ts"],"mappings":";;;;;;AAE2C;;;;;;;;;;;;;YAiB/B,qBAAA,SAA8B,qBAAA,EAAuB,IAAA,CAAK,iBAAA;IAClE,QAAA;IAGD;IAAA,oBAAA;EAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { AssemblyScriptCompilerOptions, AssemblyScriptCompilerResult, AssemblyScriptPoolOptions } from "./types-8KKo9Hbf.mjs";
1
+ import { AssemblyScriptCompilerOptions, AssemblyScriptCompilerResult, AssemblyScriptPoolOptions } from "./types-DasF0_PX.mjs";
2
2
 
3
3
  //#region src/compiler/index.d.ts
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import "./types-8KKo9Hbf.mjs";
2
- import { createAssemblyScriptPool } from "./pool-runner-init-CEwLyNI3.mjs";
1
+ import "./types-DasF0_PX.mjs";
2
+ import { createAssemblyScriptPool } from "./pool-runner-init-8vx-5Pb4.mjs";
3
3
  export { createAssemblyScriptPool };
@@ -1,8 +1,8 @@
1
- import { AssemblyScriptPoolOptions } from "./types-8KKo9Hbf.mjs";
1
+ import { AssemblyScriptPoolOptions } from "./types-DasF0_PX.mjs";
2
2
  import { PoolRunnerInitializer } from "vitest/node";
3
3
 
4
4
  //#region src/pool/pool-runner-init.d.ts
5
5
  declare function createAssemblyScriptPool(userPoolOptions?: AssemblyScriptPoolOptions): PoolRunnerInitializer;
6
6
  //#endregion
7
7
  export { createAssemblyScriptPool };
8
- //# sourceMappingURL=pool-runner-init-CEwLyNI3.d.mts.map
8
+ //# sourceMappingURL=pool-runner-init-8vx-5Pb4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool-runner-init-8vx-5Pb4.d.mts","names":[],"sources":["../src/pool/pool-runner-init.ts"],"mappings":";;;;iBAUgB,wBAAA,CAAyB,eAAA,GAAkB,yBAAA,GAA4B,qBAAA"}
@@ -1,4 +1,4 @@
1
- import { RunCompileAndDiscoverTask, ThreadSpec } from "../types-8KKo9Hbf.mjs";
1
+ import { RunCompileAndDiscoverTask, ThreadSpec } from "../types-DasF0_PX.mjs";
2
2
 
3
3
  //#region src/pool-thread/compile-worker-thread.d.ts
4
4
  declare function runCompileAndDisoverSpec(data: RunCompileAndDiscoverTask): Promise<ThreadSpec>;
@@ -1,4 +1,4 @@
1
- import { RunTestsTask } from "../types-8KKo9Hbf.mjs";
1
+ import { RunTestsTask } from "../types-DasF0_PX.mjs";
2
2
 
3
3
  //#region src/pool-thread/test-worker-thread.d.ts
4
4
  declare function runFileSpec(data: RunTestsTask): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { ProcessPoolRunFileTask } from "../types-8KKo9Hbf.mjs";
1
+ import { ProcessPoolRunFileTask } from "../types-DasF0_PX.mjs";
2
2
 
3
3
  //#region src/pool-thread/v3-tinypool-thread.d.ts
4
4
  declare function runTestFile(taskData: ProcessPoolRunFileTask): Promise<void>;
@@ -1,7 +1,6 @@
1
1
  import "tinyrainbow";
2
2
  import { MessagePort } from "node:worker_threads";
3
3
  import "birpc";
4
- import "vitest/node";
5
4
  import "@vitest/utils";
6
5
  import { SerializedConfig } from "vitest";
7
6
  import { File, Test } from "@vitest/runner/types";
@@ -225,4 +224,4 @@ interface ProcessPoolRunFileTask {
225
224
  }
226
225
  //#endregion
227
226
  export { AssemblyScriptCompilerOptions, AssemblyScriptCompilerResult, AssemblyScriptPoolOptions, HybridProviderOptions, ProcessPoolRunFileTask, RunCompileAndDiscoverTask, RunTestsTask, ThreadSpec, WasmImportsFactory, WasmImportsFactoryInfo };
228
- //# sourceMappingURL=types-8KKo9Hbf.d.mts.map
227
+ //# sourceMappingURL=types-DasF0_PX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DasF0_PX.d.mts","names":[],"sources":["../src/types/types.ts"],"mappings":";;;;;;;;AAqHA;;;AAAA,UA3DiB,yBAAA;;EAEf,KAAA;;;;;;;;;;EAUA,WAAA;EAuDU;;;;;;;EA9CV,YAAA;EAEA,0BAAA;EACA,sBAAA;EAEA,sBAAA;EACA,kBAAA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AAAA;AAAA,UA2Ne,eAAA;EACf,QAAA;EACA,MAAA,EAAQ,UAAA;EACR,SAAA;EACA,SAAA,GAAY,eAAA;AAAA;AAAA,UASG,UAAA;EACf,IAAA,EAAM,IAAA;EACN,WAAA,GAAc,eAAA;AAAA;AAAA,UAGC,yBAAA;EACf,aAAA;EACA,QAAA;EACA,IAAA,EAAM,WAAA;EACN,IAAA,EAAM,IAAA;EACN,MAAA,EAAQ,gBAAA;EACR,kBAAA;AAAA;AAAA,UAGe,YAAA;EACf,aAAA;EACA,QAAA;EACA,IAAA,EAAM,WAAA;EACN,IAAA,EAAM,IAAA;EACN,WAAA,EAAa,eAAA;EACb,MAAA,EAAQ,gBAAA;EACR,kBAAA;EACA,YAAA,GAAe,IAAA;AAAA;AAAA,UAGA,sBAAA;EACf,aAAA;EACA,IAAA,EAAM,WAAA;EACN,IAAA,EAAM,IAAA;EACN,MAAA,EAAQ,gBAAA;EACR,kBAAA;EACA,YAAA,GAAe,IAAA;EACf,mBAAA,GAAsB,eAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-pool-assemblyscript",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "AssemblyScript testing with Vitest - Simple, fast, familiar, AS-native, with full coverage output",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -1 +0,0 @@
1
- {"version":3,"file":"pool-runner-init-CEwLyNI3.d.mts","names":[],"sources":["../src/pool/pool-runner-init.ts"],"mappings":";;;;iBAUgB,wBAAA,CAAyB,eAAA,GAAkB,yBAAA,GAA4B,qBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-8KKo9Hbf.d.mts","names":[],"sources":["../src/types/types.ts"],"mappings":";;;;;;;;;;AAqHA;;UA3DiB,yBAAA;EA6DK;EA3DpB,KAAA;;;;;;;;;;EAUA,WAAA;EAuDF;;;;;;;EA9CE,YAAA;EAEA,0BAAA;EACA,sBAAA;EAEA,sB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