@executablemd/testing 0.3.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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/esm/core/mod.js +55 -0
  3. package/esm/core/src/api.js +31 -0
  4. package/esm/core/src/collect.js +24 -0
  5. package/esm/core/src/component-api.js +47 -0
  6. package/esm/core/src/content-context.js +23 -0
  7. package/esm/core/src/deno-compiler.js +51 -0
  8. package/esm/core/src/errors.js +13 -0
  9. package/esm/core/src/eval-context.js +13 -0
  10. package/esm/core/src/eval-handler.js +79 -0
  11. package/esm/core/src/eval-interpolate.js +63 -0
  12. package/esm/core/src/eval-transform.js +378 -0
  13. package/esm/core/src/execute.js +378 -0
  14. package/esm/core/src/expand.js +988 -0
  15. package/esm/core/src/frontmatter.js +98 -0
  16. package/esm/core/src/heal.js +29 -0
  17. package/esm/core/src/interpolate.js +39 -0
  18. package/esm/core/src/modifiers/daemon.js +60 -0
  19. package/esm/core/src/modifiers/persist.js +35 -0
  20. package/esm/core/src/modifiers/timeout.js +55 -0
  21. package/esm/core/src/modifiers.js +113 -0
  22. package/esm/core/src/output/normalize.js +33 -0
  23. package/esm/core/src/output/terminal.js +20 -0
  24. package/esm/core/src/render.js +30 -0
  25. package/esm/core/src/replay-stream.js +58 -0
  26. package/esm/core/src/sample-api.js +45 -0
  27. package/esm/core/src/scanner.js +632 -0
  28. package/esm/core/src/temp-file-compiler.js +68 -0
  29. package/esm/core/src/types.js +7 -0
  30. package/esm/core/src/validate.js +82 -0
  31. package/esm/durable-streams/combinators.js +227 -0
  32. package/esm/durable-streams/context.js +13 -0
  33. package/esm/durable-streams/divergence.js +56 -0
  34. package/esm/durable-streams/each.js +193 -0
  35. package/esm/durable-streams/effect.js +273 -0
  36. package/esm/durable-streams/ephemeral.js +80 -0
  37. package/esm/durable-streams/errors.js +92 -0
  38. package/esm/durable-streams/http-stream.js +207 -0
  39. package/esm/durable-streams/mod.js +34 -0
  40. package/esm/durable-streams/operations.js +88 -0
  41. package/esm/durable-streams/replay-guard.js +87 -0
  42. package/esm/durable-streams/replay-index.js +132 -0
  43. package/esm/durable-streams/run.js +137 -0
  44. package/esm/durable-streams/serialize.js +65 -0
  45. package/esm/durable-streams/stream.js +56 -0
  46. package/esm/durable-streams/types.js +10 -0
  47. package/esm/package.json +3 -0
  48. package/esm/runtime/apis.js +237 -0
  49. package/esm/runtime/find-free-port.js +33 -0
  50. package/esm/runtime/mod.js +20 -0
  51. package/esm/testing/npm/src/_dnt.polyfills.js +1 -0
  52. package/esm/testing/npm/src/_dnt.shims.js +57 -0
  53. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/almost_equals.js +47 -0
  54. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/array_includes.js +65 -0
  55. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/assert.js +23 -0
  56. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/assertion_error.js +30 -0
  57. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/equal.js +194 -0
  58. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/equals.js +61 -0
  59. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/exists.js +27 -0
  60. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/fail.js +20 -0
  61. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/false.js +23 -0
  62. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/greater.js +29 -0
  63. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.js +29 -0
  64. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/instance_of.js +52 -0
  65. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/is_error.js +53 -0
  66. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/less.js +28 -0
  67. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/less_or_equal.js +29 -0
  68. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/match.js +26 -0
  69. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/mod.js +45 -0
  70. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_equals.js +39 -0
  71. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_instance_of.js +29 -0
  72. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_match.js +26 -0
  73. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.js +32 -0
  74. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/object_match.js +177 -0
  75. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/rejects.js +53 -0
  76. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/strict_equals.js +58 -0
  77. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/string_includes.js +26 -0
  78. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/throws.js +44 -0
  79. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/unimplemented.js +20 -0
  80. package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/unreachable.js +20 -0
  81. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/build_message.js +116 -0
  82. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/diff.js +277 -0
  83. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/diff_str.js +181 -0
  84. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/format.js +70 -0
  85. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/styles.js +207 -0
  86. package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/types.js +3 -0
  87. package/esm/testing/npm/src/mod.js +27 -0
  88. package/esm/testing/npm/src/src/assertions.js +250 -0
  89. package/esm/testing/npm/src/src/handlers.js +245 -0
  90. package/esm/testing/npm/src/src/journal.js +152 -0
  91. package/esm/testing/npm/src/src/test-api.js +33 -0
  92. package/esm/testing/npm/src/src/use-testing.js +79 -0
  93. package/esm/testing/npm/src/src/vocabulary.js +111 -0
  94. package/package.json +35 -0
  95. package/types/_dnt.polyfills.d.ts +6 -0
  96. package/types/_dnt.shims.d.ts +1 -0
  97. package/types/deps/jsr.io/@std/assert/1.0.19/almost_equals.d.ts +29 -0
  98. package/types/deps/jsr.io/@std/assert/1.0.19/array_includes.d.ts +28 -0
  99. package/types/deps/jsr.io/@std/assert/1.0.19/assert.d.ts +16 -0
  100. package/types/deps/jsr.io/@std/assert/1.0.19/assertion_error.d.ts +25 -0
  101. package/types/deps/jsr.io/@std/assert/1.0.19/equal.d.ts +24 -0
  102. package/types/deps/jsr.io/@std/assert/1.0.19/equals.d.ts +36 -0
  103. package/types/deps/jsr.io/@std/assert/1.0.19/exists.d.ts +17 -0
  104. package/types/deps/jsr.io/@std/assert/1.0.19/fail.d.ts +14 -0
  105. package/types/deps/jsr.io/@std/assert/1.0.19/false.d.ts +18 -0
  106. package/types/deps/jsr.io/@std/assert/1.0.19/greater.d.ts +19 -0
  107. package/types/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.d.ts +19 -0
  108. package/types/deps/jsr.io/@std/assert/1.0.19/instance_of.d.ts +22 -0
  109. package/types/deps/jsr.io/@std/assert/1.0.19/is_error.d.ts +24 -0
  110. package/types/deps/jsr.io/@std/assert/1.0.19/less.d.ts +18 -0
  111. package/types/deps/jsr.io/@std/assert/1.0.19/less_or_equal.d.ts +19 -0
  112. package/types/deps/jsr.io/@std/assert/1.0.19/match.d.ts +17 -0
  113. package/types/deps/jsr.io/@std/assert/1.0.19/mod.d.ts +43 -0
  114. package/types/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts +26 -0
  115. package/types/deps/jsr.io/@std/assert/1.0.19/not_instance_of.d.ts +19 -0
  116. package/types/deps/jsr.io/@std/assert/1.0.19/not_match.d.ts +17 -0
  117. package/types/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.d.ts +22 -0
  118. package/types/deps/jsr.io/@std/assert/1.0.19/object_match.d.ts +28 -0
  119. package/types/deps/jsr.io/@std/assert/1.0.19/rejects.d.ts +41 -0
  120. package/types/deps/jsr.io/@std/assert/1.0.19/strict_equals.d.ts +23 -0
  121. package/types/deps/jsr.io/@std/assert/1.0.19/string_includes.d.ts +17 -0
  122. package/types/deps/jsr.io/@std/assert/1.0.19/throws.d.ts +44 -0
  123. package/types/deps/jsr.io/@std/assert/1.0.19/unimplemented.d.ts +14 -0
  124. package/types/deps/jsr.io/@std/assert/1.0.19/unreachable.d.ts +14 -0
  125. package/types/deps/jsr.io/@std/internal/1.0.14/build_message.d.ts +79 -0
  126. package/types/deps/jsr.io/@std/internal/1.0.14/diff.d.ts +139 -0
  127. package/types/deps/jsr.io/@std/internal/1.0.14/diff_str.d.ts +98 -0
  128. package/types/deps/jsr.io/@std/internal/1.0.14/format.d.ts +28 -0
  129. package/types/deps/jsr.io/@std/internal/1.0.14/styles.d.ts +158 -0
  130. package/types/deps/jsr.io/@std/internal/1.0.14/types.d.ts +24 -0
  131. package/types/mod.d.ts +29 -0
  132. package/types/src/assertions.d.ts +55 -0
  133. package/types/src/handlers.d.ts +18 -0
  134. package/types/src/journal.d.ts +29 -0
  135. package/types/src/test-api.d.ts +54 -0
  136. package/types/src/use-testing.d.ts +25 -0
  137. package/types/src/vocabulary.d.ts +34 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Test Api — contextual operations for testing mode (specs/testing-spec.md).
3
+ *
4
+ * `testing` is the activation switch: false by default, true beneath
5
+ * `<Testing>` (or root activation via a `useTesting()` session).
6
+ * Both perform the identical `Test.around({ testing: () => true })` install,
7
+ * which is what makes `xmd test` equivalent to wrapping the entrypoint in
8
+ * `<Testing>`.
9
+ *
10
+ * `record` delegates outward through nested collectors, so every enclosing
11
+ * `<Testing>` boundary and the run-level collector observe each completed
12
+ * test. `boundary` reports each `<Testing>` element's aggregate outcome.
13
+ */
14
+ import type { Operation } from "effection";
15
+ /** A completed test, in discovery order. Never holds rendered markdown. */
16
+ export interface TestResult {
17
+ status: "pass" | "fail";
18
+ name?: string;
19
+ /** "path:line:column" ("line:column" for dynamically scanned sources). */
20
+ location: string;
21
+ error?: {
22
+ kind: "assertion" | "timeout" | "teardown" | "error";
23
+ message: string;
24
+ actual?: string;
25
+ expected?: string;
26
+ };
27
+ }
28
+ /** Aggregate outcome of one `<Testing>` boundary. */
29
+ export interface BoundaryOutcome {
30
+ tests: number;
31
+ failed: number;
32
+ }
33
+ export interface TestApi {
34
+ /** Whether testing mode is active in the current scope. */
35
+ testing: boolean;
36
+ /** Whether expansion is currently inside a `<Test>` body. */
37
+ inTest: boolean;
38
+ /** Whether assertion diagnostics render during regular execution. */
39
+ verbose: boolean;
40
+ /** Whether a useTesting() session is already active in this scope. */
41
+ sessionActive: boolean;
42
+ /** Record a completed test. Collectors delegate outward via `next`. */
43
+ record(result: TestResult): Operation<void>;
44
+ /** Completed tests recorded by the nearest collector, discovery order. */
45
+ results(): Operation<TestResult[]>;
46
+ /** Report a `<Testing>` boundary's aggregate outcome. */
47
+ boundary(outcome: BoundaryOutcome): Operation<void>;
48
+ }
49
+ export declare const Test: import("@effectionx/context-api").Api<TestApi>;
50
+ export declare const testing: Operation<boolean>, inTest: Operation<boolean>, verbose: Operation<boolean>, sessionActive: Operation<boolean>, record: (result: TestResult) => Operation<void>, results: () => Operation<TestResult[]>, boundary: (outcome: BoundaryOutcome) => Operation<void>;
51
+ /** A document execution failed its testing outcome (test failures or zero tests). */
52
+ export declare class TestFailureError extends Error {
53
+ name: string;
54
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * useTesting — scope-local testing composition (specs/testing-spec.md).
3
+ *
4
+ * One `useTesting()` session per execution scope: it installs the testing
5
+ * vocabulary, the collection and completion-policy middleware, and root
6
+ * activation, then returns a session handle whose `results` operation
7
+ * snapshots completed tests in discovery order. Every install is removed
8
+ * with the session's Effection scope.
9
+ *
10
+ * ```ts
11
+ * const tests = yield* useTesting();
12
+ * const execution = yield* execute(options);
13
+ * const outcome = yield* execution; // Result<string>
14
+ * const results = yield* tests.results;
15
+ * ```
16
+ */
17
+ import type { Operation } from "effection";
18
+ import type { TestResult } from "./test-api.js";
19
+ export interface Testing {
20
+ /** Immutable snapshot of completed tests, in discovery order. */
21
+ readonly results: Operation<readonly TestResult[]>;
22
+ }
23
+ export declare function useTesting(options?: {
24
+ verbose?: boolean;
25
+ }): Operation<Testing>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Vocabulary registration (specs/testing-spec.md).
3
+ *
4
+ * Teaches the expansion loop the testing words — `<Testing>`, `<Test>`, and
5
+ * the assertion components — via the core `expandInvocation` hook, and
6
+ * decorates the core Execution Api so explicit `<Testing>` boundaries affect
7
+ * the execution outcome even when root testing is inactive.
8
+ *
9
+ * Registration is distinct from activation: installing the vocabulary
10
+ * leaves `testing` false, so `<Test>` skips and assertions stay usable.
11
+ * Root activation is `useTesting()`'s job.
12
+ *
13
+ * Installs are scope-local — call this inside a bounded scope (one CLI
14
+ * command invocation, one `scoped()` block).
15
+ */
16
+ import type { Operation } from "effection";
17
+ import type { DocumentExecution } from "@executablemd/core";
18
+ import type { TestHandlers } from "./handlers.js";
19
+ export declare function installTestingVocabulary(options?: {
20
+ verbose?: boolean;
21
+ }): Operation<void>;
22
+ /**
23
+ * Install a specific handler set. Internal seam: tests inject handlers built
24
+ * with a short timeout; the public path always uses the fixed 20 seconds.
25
+ */
26
+ export declare function installHandlers(handlers: TestHandlers, options?: {
27
+ verbose?: boolean;
28
+ }): Operation<void>;
29
+ /**
30
+ * Map an execution's completion: an `Ok` becomes `Err(failure())` when the
31
+ * policy reports one, after the inner completion — and therefore its closed
32
+ * output stream — settles. An existing `Err` passes through unchanged.
33
+ */
34
+ export declare function decorateCompletion(inner: DocumentExecution, failure: () => Error | undefined): DocumentExecution;