Skip to content

Closure-Check

Seven chapters constructing a composable assertion system. Starting from typed check functions, the pattern evolves through collection builders, factory closures, inline checks, and composable navigators for nested output.

Chapters

  • chapter-05-typed-check-functions.md — Typed Check Functions — type checkFn func(t, result, error) enables composable, reusable assertion blocks
    Source: chapters/chapter-05-typed-check-functions/
  • chapter-06-check-collection-builder.md — Check Collection Builder — var check = func(fns...) collects multiple check functions into a single slice
    Source: chapters/chapter-06-check-collection-builder/
  • chapter-07-check-factory-closures.md — Check Factory Closures — checkStatus(want) returns a closure that captures the expected value
    Source: chapters/chapter-07-check-factory-closures/
  • chapter-08-error-message-verification.md — Error Message Verification — assert.Contains(err.Error(), "substring") for error message inspection
    Source: chapters/chapter-08-error-message-verification/
  • chapter-09-output-string-inspection.md — Output String Inspection — assert.Contains/NotContains on string output for content verification
    Source: chapters/chapter-09-output-string-inspection/
  • chapter-30-composable-check-navigation.md — Composable Check Navigation — navigator factories checkReportEntry(i, ...sub) descend into nested output, delegating assertions to sub-checks
    Source: chapters/chapter-30-composable-check-navigation/
  • chapter-31-inline-check-closures.md — Inline Check Closures — define assertions inline when a check is used once; no factory extraction needed
    Source: chapters/chapter-31-inline-check-closures/

Running the code

Each chapter is a standalone Go module. To run tests for a chapter:

cd <source-directory>
go test -v ./...