Skip to content

Fixture-based test harness with 331 suites and type system gap tracking#26

Merged
wolfy-j merged 10 commits intomainfrom
feature/fixture-harness
Apr 3, 2026
Merged

Fixture-based test harness with 331 suites and type system gap tracking#26
wolfy-j merged 10 commits intomainfrom
feature/fixture-harness

Conversation

@wolfy-j
Copy link
Copy Markdown
Contributor

@wolfy-j wolfy-j commented Apr 3, 2026

Summary

  • Canonical fixture-based test harness for type system testing, execution verification, and benchmarking
  • 331 fixture suites across 8 categories with 407 files changed (+4007 -4794 lines)
  • 14 Go test files removed, replaced by .lua fixtures under testdata/fixtures/
  • 19 real-world multi-file stress tests reproducing production wippy patterns
  • 117 tracked type system errors across 14 gap fixtures as hardening targets

Harness features

  • fixture_harness_test.go (~400 lines) + fixture_test.go (~45 lines)
  • Inline -- expect-error / -- expect-warning annotations for line-precise assertions
  • Optional manifest.json with file ordering, system packages, error counts
  • Mini-require runtime for multi-module execution
  • Golden output comparison with FIXTURE_UPDATE=1 regeneration
  • Recursive discovery with go test -run TestFixtures/category/name filtering
  • BenchmarkFixtures for performance testing from the same data

Fixture categories

Category Count Description
core 65 Expressions, control flow, stdlib, narrowing, modules
narrowing 59 Type guards, unions, assertions, error patterns
types 61 Type definitions, casts, generics
functions 65 Calls, methods, closures, variadics, string methods
generics 19 Type params, constraints, instantiation
flow 17 Control flow, callbacks, higher-order functions
regression 21 Alias equivalence, nil narrowing, generics
realworld 19 Multi-file production patterns (see below)

Real-world stress tests

Fixture Files Errors Pattern
channel-select-pattern 3 0 Event/timer select with narrowing
error-handling-chain 3 0 Discriminated union Result types
trait-registry 3 0 Union normalization (string or table)
multi-return-error-chain 4 0 Chained (value, err) narrowing
discriminated-tool-dispatch 3 0 Tagged union dispatch per variant
typed-callback-chain 3 29 Interface fields, callback struct matching
service-locator 4 14 Cross-module type resolution
generic-registry 3 12 Cross-module methods
iterator-pipeline 2 11 Generic map/filter/reduce
lookup-table-cast 3 11 Typed map initialization
+ 9 more ... ... Builder patterns, OOP, SQL repos, enums

Derived from analyzing 687 :: any casts across 93 production Lua files.

Test plan

  • go test -v -run TestFixtures ./... — all 331 suites pass
  • go test -bench BenchmarkFixtures ./... — benchmark suite works
  • go test -count=10 -run TestFixtures . — deterministic (0 flakes in 10 runs)
  • go test ./... — full suite passes, no regressions
  • Negative tests (44 with -- expect-error, 14 with error counts) correctly catch type errors

wolfy-j added 10 commits April 3, 2026 15:31
Canonical path for multi-file type system testing, execution verification,
and benchmarking. Fixtures are directories under testdata/fixtures/ with
.lua files and optional manifest.json. Inline expect-error/expect-warning
annotations in source files for diagnostic assertions.

Includes mini-require runtime for multi-module fixture execution, golden
file comparison with FIXTURE_UPDATE=1 support, and recursive discovery
with go test -run filtering by category path.
Migrate narrowing_test.go (18 cases) and minimal_narrowing_test.go (3 cases)
to testdata/fixtures/narrowing/. Migrate typedef_test.go (22 cases) to
testdata/fixtures/types/. Remove original Go test files.

Also fixes BenchFixtures -> BenchmarkFixtures naming and replaces
PreloadModule approach with installRequire mini-runtime for proper
require() support in multi-module fixtures.
Migrate generics_test.go (19 cases), functions_test.go (26 cases),
control_flow_test.go (17 cases), and wippy_suite_test.go easy cases
(21 cases) to fixture harness. Remove original Go files.

Fix inline expect-error to absorb all diagnostics on annotated line,
not just the first match. Keeps manifest-based regression tests
(TestModuleGenericInstantiation, TestRegistryTypeLoss) in place.
Migrate scenarios_test.go (65 cases) to testdata/fixtures/core/,
type_cast_test.go (39 cases) to testdata/fixtures/types/cast-*, and
union_narrowing_test.go (12 cases) to testdata/fixtures/narrowing/union-*.
Remove original Go test files.

Fix harness: expect-error annotation now absorbs all diagnostics on
that line, not just the first match (handles multi-error lines).
Add "packages" field to manifest.json to declare system packages
(channel, funcs) that the type checker resolves via predefined manifests.

Create 5 real-world multi-file fixtures that exercise patterns found
in production wippy code:
- channel-select-pattern: event/timer select with narrowing (passes)
- error-handling-chain: discriminated union result types (passes)
- factory-constructor: OOP factory pattern (skipped - syntax gap)
- module-with-generics: generic collection type (skipped - parser gap)
- table-builder-pattern: fluent method chaining (skipped - return tracking)

Skipped fixtures mark type system hardening targets derived from
analyzing 687 :: any casts across 93 production Lua files.
Use check.errors count instead of skip for real-world fixtures with
known type system limitations. This ensures gaps are actively tracked
and tests fail when fixes reduce the error count, preventing regression
and making progress visible.
Migrate method_calls_test.go (39 cases) covering string methods, table
patterns, pcall/xpcall, goto/break, higher-order functions, closures,
and variadic functions to fixtures.

Migrate assert_narrowing_test.go (26 cases) covering assert narrowing,
custom assert libraries, error-return patterns, assert wrapper
propagation, and inferred contracts.

Remove optional_narrowing_test.go (duplicate of already-migrated cases).
Six new multi-file fixtures reproducing production patterns from wippy
framework code that currently require :: any casts:

- metatable-oop: EventEmitter + Counter with setmetatable, callbacks (5 errors)
- fluent-prompt-builder: method chaining with typed return self (4 errors)
- typed-callback-chain: StreamCallbacks with ToolCall/ErrorInfo payloads (29 errors)
- result-type-narrowing: Generic Result<T> with map/and_then combinators (4 errors)
- generic-registry: Handler registry with typed register/call/list (12 errors)
- context-merge-pipeline: Pipeline with fluent add + Context merging (3 errors)

These fixtures establish the hardening targets for the type system.
Combined with the 3 existing gap fixtures, we now track 9 real-world
patterns with a total of 68 known type errors to eliminate.
New fixtures reproducing production patterns:
- lookup-table-cast: typed map tables {[string]: string} (11 errors)
- service-locator: cross-module service resolution (14 errors)
- trait-registry: union type normalization (string | record) (0 errors - passes!)
- sql-repository: enum-keyed table access (4 errors)
- iterator-pipeline: generic map/filter/reduce (11 errors)
- typed-enum-constants: literal union types as enums (6 errors)
- multi-return-error-chain: chained (value, err) narrowing (0 errors - passes!)
- discriminated-tool-dispatch: tagged union dispatch (0 errors - passes!)

Fix error-handling-chain to export types as runtime values (M.AppError = AppError)
and use :is() for runtime validation. Cross-module :is() returns unknown - tracked
as expect-error, confirming this is a real type system gap.

Total: 331 fixtures, 117 tracked type errors across 14 gap fixtures.
Fix module iteration in check phase to use deterministic file order
instead of map iteration. This resolves flaky test results caused by
Go map randomization affecting checker fixpoint convergence.

Update error-handling-chain to demonstrate idiomatic type export
pattern (M.AppError = AppError) with runtime :is() validation.
Cross-module :is() returning unknown is tracked as expect-error.

Set error counts for multi-return-error-chain (was passing due to
lucky map ordering, now deterministically tracked).
@wolfy-j
Copy link
Copy Markdown
Contributor Author

wolfy-j commented Apr 3, 2026

This seems like massive PR but it's a lot of mechanical work around harness and canonization.

This is step 1 of new vm design port to wippy.

@wolfy-j wolfy-j merged commit 9ba0e19 into main Apr 3, 2026
@wolfy-j wolfy-j deleted the feature/fixture-harness branch April 9, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant