gen.anything / gen.json: arbitrary Nix values #12

Closed
opened 2026-09-13 21:24:23 +09:00 by natsukium · 1 comment
Owner

Missing

gen.anything (an arbitrary Nix value: null, bool, int, float, string, list, attrset, recursively) and gen.json (the same without null-free restrictions and with JSON-safe floats).

Why

fast-check has fc.anything / fc.json; Hypothesis builds the same with st.recursive. Properties over nixpkgs lib functions (lib.isType, toJSON round trips, recursiveUpdate, ...) need "any value" and every example in examples/nixpkgs-lib-*.nix currently assembles a subset by hand.

Suggested shape

  • Built on gen.recursive (#5) and gen.attrsOf (#4); doubles as the dogfood test for both.
  • Options to exclude floats or functions, and to cap depth via size.
  • examples/nixpkgs-lib-comprehensive.nix should be checked for hand-rolled equivalents to replace.
## Missing `gen.anything` (an arbitrary Nix value: null, bool, int, float, string, list, attrset, recursively) and `gen.json` (the same without `null`-free restrictions and with JSON-safe floats). ## Why fast-check has `fc.anything` / `fc.json`; Hypothesis builds the same with `st.recursive`. Properties over nixpkgs `lib` functions (`lib.isType`, `toJSON` round trips, `recursiveUpdate`, ...) need "any value" and every example in `examples/nixpkgs-lib-*.nix` currently assembles a subset by hand. ## Suggested shape - Built on `gen.recursive` (#5) and `gen.attrsOf` (#4); doubles as the dogfood test for both. - Options to exclude floats or functions, and to cap depth via size. - `examples/nixpkgs-lib-comprehensive.nix` should be checked for hand-rolled equivalents to replace.
Author
Owner

Implemented in d153fd0, pushed to main.

Implemented in d153fd0, pushed to main.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/nixcheck#12
No description provided.