BurntSushi / quickcheck

Automated property based testing for Rust (with shrinking).
The Unlicense
2.4k stars 149 forks source link

Add support for emscripten (wasm32-unknown-emscripten target) #272

Open Spoonbender opened 3 years ago

Spoonbender commented 3 years ago

I'm unable to build quickcheck when targeting the wasm32-unknown-emscripten build target. Please consider adding support for wasm as a 1st class citizen!

Repro: Using master at defde6fb0ce20b0c8c4e672aa9ae821f7d1f5b38, Perform the following steps:

  1. Setup: add the wasm-emscripten target by running rustup target add wasm32-unknown-emscripten
  2. Attempt to build quickcheck for this target using cargo build --target wasm32-unknown-emscripten

Expected result: quickcheck is successfully built for the wasm target

Actual result: Compilation fails with the following message:

error[E0277]: the trait bound `Standard: Distribution<u128>` is not satisfied
   --> src\arbitrary.rs:785:32
    |
785 |                           _ => g.gen()
    |                                  ^^^ the trait `Distribution<u128>` is not implemented for `Standard`
...
797 | / unsigned_arbitrary! {
798 | |     usize, u8, u16, u32, u64, u128
799 | | }
    | |_- in this macro invocation
    |
    = help: the following implementations were found:
              <Standard as Distribution<()>>
              <Standard as Distribution<(A, B)>>
              <Standard as Distribution<(A, B, C)>>
              <Standard as Distribution<(A, B, C, D)>>
            and 63 others
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Notes:

BurntSushi commented 3 years ago

Perhaps quickcheck should also exclude support for these types when targeting emscripten?

If doing so is simple, easy to maintain and testable in CI, then sure. A PR is welcome.

Spoonbender commented 3 years ago

@BurntSushi great, I'll try to tackle this

Spoonbender commented 3 years ago

@BurntSushi after taking an initial stab at this, I see there are multiple, distinct issues to resolve. I will open separate bugs and PRs for each as each could be accepted or rejected individually, and each provides value by itself. I'll rename this bug to add support for wasm32-unknown-emscripten target.