#![allow(non_snake_case)]
use proptest_derive::*;
use un_algebra::tests::*;
use un_algebra::prelude::*;
#[derive(Copy, Clone, PartialEq, Debug, Arbitrary)]
pub enum RPS {
R, P, S
}
impl Magma for RPS {
fn op(&self, other: &Self) -> Self {
match (self, other) {
(RPS::R, RPS::R) => RPS::R,
(RPS::R, RPS::P) => RPS::P,
(RPS::R, RPS::S) => RPS::R,
(RPS::P, RPS::R) => RPS::P,
(RPS::P, RPS::P) => RPS::P,
(RPS::P, RPS::S) => RPS::S,
(RPS::S, RPS::R) => RPS::R,
(RPS::S, RPS::P) => RPS::S,
(RPS::S, RPS::S) => RPS::S
}
}
}
proptest! {
#![proptest_config(config::standard())]
#[test]
fn closure((x, y) in any::<(RPS, RPS)>()) {
prop_assert!(MagmaLaws::closure(&x, &y))
}
#[test]
fn closure_t2([xs, ys] in any::<[(RPS, RPS); 2]>()) {
prop_assert!(MagmaLaws::closure(&xs, &ys))
}
#[test]
fn closure_a2([xs, ys] in any::<[[RPS; 2]; 2]>()) {
prop_assert!(MagmaLaws::closure(&xs, &ys))
}
#[test]
fn commutivity((x, y) in any::<(RPS, RPS)>()) {
prop_assert!(x.op(&y) == y.op(&x))
}
#[test]
fn commutivity_t1((x, y) in any::<(RPS, RPS)>()) {
prop_assert!((x,).op(&(y,)) == (y,).op(&(x,)))
}
#[test]
fn commutivity_a1((x, y) in any::<(RPS, RPS)>()) {
prop_assert!([x].op(&[y]) == [y].op(&[x]))
}
}
fn main() {
}