Skip to content

Conversation

saem
Copy link
Collaborator

@saem saem commented Jul 5, 2025

Summary

Introduces property based testing via the property_testing module under the experimental part of the standard library.

Details

  • info that couldn't fit into the summary
  • relevant details; tricky parts
  • anything else

Notes for Reviewers

  • clean-up of the api:
    • split into:
      • substitutable random number generation, with skipping, etc
      • arbitrary infrastructure and core definitions and mapping/filtering
      • create a test library with "manual" API, and possibly separately a test runner
  • allow for substituting rngs via an interface object
  • implement minimizing:
    • should we keep the shrinkable concept, or drop shrinking until later?
  • clean-up docs
  • write a proper commit message

@saem saem added the stdlib Standard library label Jul 5, 2025
@saem saem marked this pull request as draft July 5, 2025 22:11
@saem
Copy link
Collaborator Author

saem commented Aug 30, 2025

The output from the current tests looks as follows, each property has an id that should be useable to run it specifically in the future:

nim

1 uint32
- are >= 0 (id: 1) - status: success, totalRuns: 1000
- within the range[100000000, 4294967295] (id: 2) - status: success, totalRuns: 1000

1.1 enums
- are typically ordinals (id: 3) - status: success, totalRuns: 1000

1.2 characters
        1.2.1 are ordinals
        - forming a bijection with int values between 0..255 (inclusive) (id: 4) - status: success, totalRuns: 1000
        - have successors and predecessors or are at the end range (id: 5) - status: success, totalRuns: 1000

- ascii - are from 0 to 127 (id: 6) - status: success, totalRuns: 1000

1.3 strings
- concatenation - len is == the sum of the len of the parts (id: 7) - status: success, totalRuns: 1000

1.4 sets
- cannot contain more items than the enum itself (id: 8) - status: success, totalRuns: 1000
        1.4.1 union
        - a union of sets contain all elements of each (id: 9) - status: success, totalRuns: 1000
        - union is commutative (id: 10) - status: success, totalRuns: 1000

        1.4.2 intersection
        - an intersection is a subset of both operands (id: 11) - status: success, totalRuns: 1000
        - intersection is commutative (id: 12) - status: success, totalRuns: 1000

        1.4.3 difference (or relative complement)
        - a difference has no overlap with the second operand (id: 13) - status: success, totalRuns: 1000

@saem
Copy link
Collaborator Author

saem commented Sep 24, 2025

Using the following doc to discuss the CLI interface for PBT: https://gist.github.com/saem/3df20c8afa67bc4c266dbe2dfa21e2b5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant