#![allow(clippy::unwrap_used, clippy::expect_used)]
use prism::pipeline::{validate_constrained_type, ConstrainedTypeShape};
use prism::std_types::{
E6FiltrationShape, E7AugmentationShape, E8EmbeddingShape, F4QuotientShape, G2ProductShape,
};
const SHA256_LABEL_BYTES: usize = 71;
const SHA3_256_LABEL_BYTES: usize = 73;
const KECCAK256_LABEL_BYTES: usize = 74;
#[test]
fn g2_product_shape_site_count_is_binary() {
const G_SHA256: usize = <G2ProductShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const G_SHA3: usize = <G2ProductShape<73> as ConstrainedTypeShape>::SITE_COUNT;
const G_KECCAK: usize = <G2ProductShape<74> as ConstrainedTypeShape>::SITE_COUNT;
assert_eq!(G_SHA256, 2 * SHA256_LABEL_BYTES);
assert_eq!(G_SHA3, 2 * SHA3_256_LABEL_BYTES);
assert_eq!(G_KECCAK, 2 * KECCAK256_LABEL_BYTES);
assert!(<G2ProductShape<71> as ConstrainedTypeShape>::CONSTRAINTS.is_empty(),);
}
#[test]
fn unary_shape_site_counts_per_adr_061_section_2() {
const F4: usize = <F4QuotientShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E6: usize = <E6FiltrationShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E7: usize = <E7AugmentationShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E8: usize = <E8EmbeddingShape<71> as ConstrainedTypeShape>::SITE_COUNT;
assert_eq!(F4, SHA256_LABEL_BYTES);
assert_eq!(E6, SHA256_LABEL_BYTES + 1);
assert_eq!(E7, SHA256_LABEL_BYTES);
assert_eq!(E8, SHA256_LABEL_BYTES);
}
#[test]
fn unary_shapes_widen_with_sigma_axis() {
assert_eq!(
<F4QuotientShape<74> as ConstrainedTypeShape>::SITE_COUNT,
KECCAK256_LABEL_BYTES,
);
assert_eq!(
<E6FiltrationShape<74> as ConstrainedTypeShape>::SITE_COUNT,
KECCAK256_LABEL_BYTES + 1,
);
assert_eq!(
<E8EmbeddingShape<73> as ConstrainedTypeShape>::SITE_COUNT,
SHA3_256_LABEL_BYTES,
);
}
#[test]
fn all_composition_shapes_share_the_closure_iri() {
const IRI: &str = "https://uor.foundation/type/ConstrainedType";
assert_eq!(<G2ProductShape<71> as ConstrainedTypeShape>::IRI, IRI);
assert_eq!(<F4QuotientShape<71> as ConstrainedTypeShape>::IRI, IRI);
assert_eq!(<E6FiltrationShape<71> as ConstrainedTypeShape>::IRI, IRI);
assert_eq!(<E7AugmentationShape<71> as ConstrainedTypeShape>::IRI, IRI);
assert_eq!(<E8EmbeddingShape<71> as ConstrainedTypeShape>::IRI, IRI);
}
#[test]
fn composition_shapes_admit_under_compile_time_admission() {
validate_constrained_type(G2ProductShape::<71>).expect("G2ProductShape<71> admits");
validate_constrained_type(G2ProductShape::<74>).expect("G2ProductShape<74> admits");
validate_constrained_type(F4QuotientShape::<71>).expect("F4QuotientShape<71> admits");
validate_constrained_type(F4QuotientShape::<73>).expect("F4QuotientShape<73> admits");
validate_constrained_type(E6FiltrationShape::<71>).expect("E6FiltrationShape<71> admits");
validate_constrained_type(E6FiltrationShape::<74>).expect("E6FiltrationShape<74> admits");
validate_constrained_type(E7AugmentationShape::<71>).expect("E7AugmentationShape<71> admits");
validate_constrained_type(E7AugmentationShape::<73>).expect("E7AugmentationShape<73> admits");
validate_constrained_type(E8EmbeddingShape::<71>).expect("E8EmbeddingShape<71> admits");
validate_constrained_type(E8EmbeddingShape::<74>).expect("E8EmbeddingShape<74> admits");
}
#[test]
fn composition_shapes_are_pairwise_distinct_types() {
const F4: usize = <F4QuotientShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E6: usize = <E6FiltrationShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E7: usize = <E7AugmentationShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const E8: usize = <E8EmbeddingShape<71> as ConstrainedTypeShape>::SITE_COUNT;
assert_eq!(F4, E7);
assert_eq!(E7, E8);
assert_eq!(
E6,
F4 + 1,
"E₆ is one byte wider than the operand-preserving unaries"
);
validate_constrained_type(F4QuotientShape::<71>).expect("F₄ admits");
validate_constrained_type(E6FiltrationShape::<71>).expect("E₆ admits");
validate_constrained_type(E7AugmentationShape::<71>).expect("E₇ admits");
validate_constrained_type(E8EmbeddingShape::<71>).expect("E₈ admits");
}
#[test]
fn g2_product_distinct_from_unary_shapes() {
const G2: usize = <G2ProductShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const F4: usize = <F4QuotientShape<71> as ConstrainedTypeShape>::SITE_COUNT;
const _: () = assert!(G2 > F4);
assert_eq!(G2, 2 * F4);
}