Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Support closure proptests #21

@sunshowers

Description

@sunshowers

The API could look something like:

#[propfuzz_closure]
fn foo() {
    // set up initial state...

    #[propfuzz(name = "test1")]
    |param: Vec<u8>| {
        // ... test
    };

    #[propfuzz(name = "test2")]
    |#[propfuzz(strategy = "state.strategy()")] param: StateParam<'_>| {
        // ... test
    };
}

Internally, this could be modeled through:

  • the #[propfuzz_closure] attribute macro scanning through all the items and turning them into targets
  • instead of a &mut TestRunner, pass in a &mut __PROPFUZZ_CLOSURE__foo where __PROPFUZZ_CLOSURE__foo is an autogenerated type:
struct __PROPFUZZ_CLOSURE__foo {
    test1: Option<TestRunner>,
    test2: Option<TestRunner>,
}

test1 and test2 provide access to individual test runners -- the Option is so that we can disable a test from running in the fuzzing context.

This is a fair bit of complexity and accordingly not very high priority unless we end up needing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions