diceprop

A collection of mathematical properties for random testing.

It's based on dicetest.

Status of this crate

The author does not consider this crate as stable yet.

Examples

Associative binary operation

```rust use diceprop::{infixfun2, props, FateVarExt}; use dicetest::prelude::*;

[test]

fn addisassociativeforsmallf32() { Dicetest::repeatedly().run(|mut fate| { let smallf32die = dice::f32(-100.0..=100.0); let var = fate.rollvar3("f32 ∩ [-100,100]", ["x", "y", "z"], smallf32die); let add = infixfun_2("+", |x, y| x + y); props::binop::associative(var, add); }) } ```

The test fails with the following output:

``` The test failed after 22 passes.

Config

Counterexample

Left inverse function

```rust use diceprop::{fun1, postfixfun_1, props, FateVarExt}; use dicetest::prelude::*;

[test]

fn sqrtisleftinverseofsqfornonnegativef32() { Dicetest::repeatedly().run(|mut fate| { let nonnegativef32die = dice::f32(0.0..); let var = fate.rollvar1("f32 ∩ [0,+∞]", "x", nonnegativef32die); let sq = postfixfun1("²", |x| x * x); let sqrt = fun1("√", |x: f32| x.sqrt()); props::fun::left_inverse(var, sq, sqrt); }) } ```

The test fails with the following output:

``` The test failed after 0 passes.

Config

Counterexample

Partial order

```rust use diceprop::{infixfun2, props, FateVarExt}; use dicetest::prelude::*;

[test]

fn gtispartialorderforanyf32() { Dicetest::repeatedly().run(|mut fate| { let anyf32die = dice::anyf32(); let var = fate.rollvar3("f32", ["x", "y", "z"], anyf32die); let gt = infixfun2("≤", |x, y| x <= y); props::binrel::partialorder(var, gt); }) } ```

The test fails with the following output:

``` The test failed after 3 passes.

Config

Counterexample

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.