module-test.d.ts 1.1 KB

123456789101112131415161718192021222324252627
  1. import type { QuickJSContext } from "./context";
  2. import type { ModuleEvalOptions, QuickJSWASMModule } from "./module";
  3. import type { QuickJSRuntime } from "./runtime";
  4. import type { ContextOptions, RuntimeOptions } from "./types";
  5. /**
  6. * A test wrapper of [[QuickJSWASMModule]] that keeps a reference to each
  7. * context or runtime created.
  8. *
  9. * Call [[disposeAll]] to reset these sets and calls `dispose` on any left alive
  10. * (which may throw an error).
  11. *
  12. * Call [[assertNoMemoryAllocated]] at the end of a test, when you expect that you've
  13. * freed all the memory you've ever allocated.
  14. */
  15. export declare class TestQuickJSWASMModule implements Pick<QuickJSWASMModule, keyof QuickJSWASMModule> {
  16. private parent;
  17. contexts: Set<QuickJSContext>;
  18. runtimes: Set<QuickJSRuntime>;
  19. constructor(parent: QuickJSWASMModule);
  20. newRuntime(options?: RuntimeOptions): QuickJSRuntime;
  21. newContext(options?: ContextOptions): QuickJSContext;
  22. evalCode(code: string, options?: ModuleEvalOptions): unknown;
  23. disposeAll(): void;
  24. assertNoMemoryAllocated(): void;
  25. /** @private */
  26. getFFI(): any;
  27. }