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. Changes will be documented in the changelog.

Examples

Associative binary operation

```rust use diceprop::{props, Fun2, Set}; use dicetest::prelude::*;

[test]

fn addisassociativeforsmall_f32() { Dicetest::repeatedly().run(|mut fate| { let set = Set::new("f32 ∩ [-100,100]", dice::f32(-100.0..=100.0)); let vars = fate.roll(set.vars(["x", "y", "z"])); let add = Fun2::infix("+", |x, y| x + y); props::binop::associative(vars, add); }) } ```

The test fails with the following output:

``` The test failed after 12 passes.

Config

Counterexample

Left inverse function

```rust use diceprop::{props, Fun1, Set}; use dicetest::prelude::*;

[test]

fn sqrtisleftinverseofsqfornonnegativef32() { Dicetest::repeatedly().run(|mut fate| { let set = Set::new("f32 ∩ [0,+∞]", dice::f32(0.0..)); let vars = fate.roll(set.vars(["x"])); let sq = Fun1::postfix("²", |x| x * x); let sqrt = Fun1::new("√", |x: f32| x.sqrt()); props::fun::leftinverse(vars, sq, sqrt); }) } ```

The test fails with the following output:

``` The test failed after 0 passes.

Config

Counterexample

Partial order

```rust use diceprop::{props, Fun2, Set}; use dicetest::prelude::*;

[test]

fn gtispartialorderforanyf32() { Dicetest::repeatedly().run(|mut fate| { let set = Set::new("f32", dice::anyf32()); let vars = fate.roll(set.vars(["x", "y", "z"])); let gt = Fun2::infix("≤", |x, y| x <= y); props::binrel::partialorder(vars, 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.