Files
codebase-memory-mcp/tests
Jason Bowman c7cb8c4e33 test(nix): cover the root shapes, and assert defs rather than absence of error
`nix_function` was the only Nix extraction test, and it could not fail for the
bug the previous commit fixes. Three separate reasons:

  - its fixture is function-headed — the exact broken shape;
  - its binding, `hello = pkgs.writeShellScriptBin "hello" ''...''`, is an
    application, not a function, so no Function def is expected from it either
    way;
  - it asserts only ASSERT_NOT_NULL and ASSERT_FALSE(has_error), omitting the
    has_def check every adjacent language test makes.

So the suite reported green while definitions were being dropped for the
dominant file shape in the ecosystem.

This keeps `nix_function` as-is — it usefully pins the "parses, yields no def"
case — and adds one test per root shape, each asserting its own definitions so a
regression names the shape it broke:

  nix_defs_in_let_rooted_file               let ... in
  nix_defs_in_attrset_rooted_file           { ... }
  nix_defs_in_nested_let                    let inside let
  nix_defs_survive_function_header_let      { prelude }: let ... in
  nix_defs_survive_function_header_attrset  { prelude }: { ... }
  nix_defs_survive_curried_header           final: prev: { ... }
  nix_curried_lambda_mints_one_def          guards the other direction

The curried-header case is the nixpkgs overlay signature, the most common
multi-arm header in the ecosystem: two nested function_expressions sit between
the file root and the body. The last test exists because the fix descends past
the header — it pins that `iota = a: b: a + b` mints exactly one Function, so a
change that starts minting the inner arm as a second def is caught.

Verified as a negative control — with the previous commit's one-line change
reverted, the three function-header tests fail on their own assertions (gamma,
eta, iota) while the pre-existing shapes stay green. With it applied the
extraction suite is 260 passed, 0 failed.

Signed-off-by: Jason Bowman <jason@json64.dev>
2026-07-27 17:14:39 -07:00
..
2026-07-08 00:05:19 +05:30
2026-07-08 00:05:19 +05:30
2026-06-28 13:05:05 +02:00