Skip to content

Commit

Permalink
add tests for Signature
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Nov 6, 2023
1 parent dfed7ea commit 9d6a3a3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ impl Display for Signature {

#[cfg(test)]
mod test {
use crate::{extension::prelude::USIZE_T, type_row};
use crate::{
extension::{prelude::USIZE_T, ExtensionId},
type_row,
};

use super::*;
#[test]
Expand All @@ -258,4 +261,24 @@ mod test {
assert_eq!(f_type.input_types(), &[Type::UNIT]);
assert_eq!(f_type.output_types(), &[USIZE_T]);
}

#[test]
fn test_signature() {
let f_type = FunctionType::new(type_row![Type::UNIT], type_row![USIZE_T]);

let sig: Signature = f_type.pure();

assert_eq!(sig.input(), &type_row![Type::UNIT]);
assert_eq!(sig.output(), &type_row![USIZE_T]);
}

#[test]
fn test_display() {
let f_type = FunctionType::new(type_row![Type::UNIT], type_row![USIZE_T]);
assert_eq!(f_type.to_string(), "[Tuple([])] -> [[]][usize([])]");
let sig: Signature = f_type.with_input_extensions(ExtensionSet::singleton(
&ExtensionId::new("Example").unwrap(),
));
assert_eq!(sig.to_string(), "[Tuple([])] -> [[]][usize([])]");
}
}

0 comments on commit 9d6a3a3

Please sign in to comment.