Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed Dec 27, 2024
1 parent bc7385a commit 7a68bf3
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions tket2-hseries/src/extension/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl HasConcrete for WasmOpDef {
}))?
};

let Some(outputs) = type_arg_into_type_row_rv(inputs_arg.clone()) else {
let Some(outputs) = type_arg_into_type_row_rv(outputs_arg.clone()) else {
Err(SignatureError::from(TypeArgError::TypeMismatch {
param: INPUTS_PARAM.to_owned(),
arg: outputs_arg,
Expand Down Expand Up @@ -513,7 +513,7 @@ impl HasConcrete for WasmOpDef {
}))?
};

let Some(outputs) = type_arg_into_type_row_rv(inputs_arg.clone()) else {
let Some(outputs) = type_arg_into_type_row_rv(outputs_arg.clone()) else {
Err(SignatureError::from(TypeArgError::TypeMismatch {
param: INPUTS_PARAM.to_owned(),
arg: outputs_arg,
Expand Down Expand Up @@ -751,6 +751,60 @@ mod test {

use super::*;

#[test]
fn const_wasm_module() {
let m1 = ConstWasmModule {
name: "test_mod".to_string(),
hash: 1,
};
let m2 = ConstWasmModule {
name: "test_mod".to_string(),
hash: 1,
};
assert_eq!(m1.name(), "wasm:test_mod");
assert!(m1.equal_consts(&m2));
assert_eq!(m1.extension_reqs(), ExtensionSet::singleton(EXTENSION_ID));
}

#[test]
fn wasm_op_def_instantiate() {
assert_eq!(
WasmOpDef::get_context.instantiate(&[]),
Ok(WasmOp::GetContext)
);
assert_eq!(
WasmOpDef::dispose_context.instantiate(&[]),
Ok(WasmOp::DisposeContext)
);
assert_eq!(
WasmOpDef::lookup.instantiate(&[
"lookup_name".into(),
TypeArg::new_var_use(
0,
TypeParam::List {
param: Box::new(TypeBound::Any.into())
}
),
vec![].into()
]),
Ok(WasmOp::Lookup {
name: "lookup_name".to_string(),
inputs: vec![TypeRV::new_row_var_use(0, TypeBound::Any)].into(),
outputs: TypeRowRV::from(Vec::<TypeRV>::new())
})
);
assert_eq!(
WasmOpDef::call.instantiate(&[
vec![Type::UNIT.into()].into(),
vec![].into()
]),
Ok(WasmOp::Call {
inputs: vec![Type::UNIT].into(),
outputs: vec![].into()
})
);
}

#[rstest]
#[case::concrete(type_row![], type_row![])]
#[case::row_vars1(
Expand Down

0 comments on commit 7a68bf3

Please sign in to comment.