From c3be34b914421bf4989de213f72e534a5150d3a7 Mon Sep 17 00:00:00 2001 From: Douglas Wilson Date: Thu, 2 May 2024 13:07:40 +0100 Subject: [PATCH] testing roundtrip serialisation for (most) ops --- hugr/src/extension/op_def.rs | 7 ++----- hugr/src/hugr/serialize/test.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hugr/src/extension/op_def.rs b/hugr/src/extension/op_def.rs index 1b605b86f..4be5110e7 100644 --- a/hugr/src/extension/op_def.rs +++ b/hugr/src/extension/op_def.rs @@ -465,13 +465,10 @@ impl Extension { #[cfg(test)] mod test { - - - use std::num::NonZeroU64; - + use std::num::NonZeroU64; - use super::{SignatureFromArgs}; + use super::SignatureFromArgs; use crate::builder::{DFGBuilder, Dataflow, DataflowHugr}; use crate::extension::op_def::LowerFunc; use crate::extension::prelude::USIZE_T; diff --git a/hugr/src/hugr/serialize/test.rs b/hugr/src/hugr/serialize/test.rs index 94be5928b..c3c15a188 100644 --- a/hugr/src/hugr/serialize/test.rs +++ b/hugr/src/hugr/serialize/test.rs @@ -9,7 +9,7 @@ use crate::extension::{EMPTY_REG, PRELUDE_REGISTRY}; use crate::hugr::hugrmut::sealed::HugrMutInternals; use crate::hugr::NodeType; use crate::ops::custom::{ExtensionOp, OpaqueOp}; -use crate::ops::{Value}; +use crate::ops::Value; use crate::ops::{dataflow::IOTrait, Input, Module, Noop, Output, DFG}; use crate::std_extensions::arithmetic::float_ops::FLOAT_OPS_REGISTRY; use crate::std_extensions::arithmetic::float_types::{ConstF64, FLOAT64_TYPE}; @@ -370,7 +370,7 @@ fn serialize_types_roundtrip() { proptest! { #[test] - fn prop_roundtrip_type(t: Type) { + fn prop_roundtrip_type(t: Type) { check_testing_roundtrip(t) } @@ -383,4 +383,9 @@ proptest! { fn prop_roundtrip_value(t: Value) { check_testing_roundtrip(t) } + + #[test] + fn prop_roundtrip_optype(op in ((0..(std::u32::MAX / 2) as usize).prop_map(|x| portgraph::NodeIndex::new(x).into()), any::>(), any::()).prop_map(|(parent, input_extensions, op)| NodeSer { parent, input_extensions, op })) { + check_testing_roundtrip(op) + } }