proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.63k stars 152 forks source link

add boxed union feature to circumvent stack overflow #406

Closed rexmas closed 6 months ago

rexmas commented 6 months ago

For enums with a lot of variants the Strategy synthesized by the #[derive(Arbitrary)] macro is a right-deep TupleUnion.

This commit adds a boxed_union feature, which when enabled will change the enum expansion to use Union<BoxedStrategy<Self>>.

see github issues: https://github.com/proptest-rs/proptest/issues/249 https://github.com/proptest-rs/proptest/issues/152

code included from https://github.com/proptest-rs/proptest/issues/249#issuecomment-1367820389

matthew-russo commented 6 months ago

fixes #152 (sort of. not as described in that issue)

i wouldn't mark this on as fixing #249 as I see that one being more about the internals of ValueTree itself. unless i'm misunderstanding something

rbtcollins commented 6 months ago

It fixes 249 as I intended to write it! With this, my openapi struct would be generated to heap, rather than stack, which would permit running the tests without --release.