diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-05 11:40:00 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-05 11:40:00 +0300 |
commit | c629fac4297b8f13bdab00100f3b05549174154e (patch) | |
tree | cadc8f0c9b16021338134a9c7a90478bcd8f2bdc /src/type/mod.rs | |
parent | 0d9c5b7fd7dec374ec357581f721f5cdc828b7ae (diff) | |
download | myslip-c629fac4297b8f13bdab00100f3b05549174154e.tar.gz myslip-c629fac4297b8f13bdab00100f3b05549174154e.zip |
Added boilerplate and tests for booleans, integer comparisons and boolean operators.
Diffstat (limited to 'src/type/mod.rs')
-rw-r--r-- | src/type/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/type/mod.rs b/src/type/mod.rs index 8761cee..8977d85 100644 --- a/src/type/mod.rs +++ b/src/type/mod.rs @@ -14,6 +14,8 @@ pub enum Type { Integer, + Boolean, + Arrow(Box<Type>, Box<Type>), List(Vec<Type>), @@ -63,19 +65,21 @@ impl Type { /// use myslip::r#type::{*, Type::*, TypeError::*, util::*}; /// /// assert_eq!(Integer.is_concrete(), Ok(())); + /// assert_eq!(Boolean.is_concrete(), Ok(())); /// assert_eq!( /// VarType("a".to_string()).is_concrete(), /// Err("a".to_string()) /// ); /// /// assert_eq!(arr(Integer, Integer).is_concrete(), Ok(())); + /// assert_eq!(arr(Integer, Boolean).is_concrete(), Ok(())); /// assert_eq!( /// arr(VarType("b".to_string()), Integer).is_concrete(), /// Err("b".to_string()) /// ); /// /// assert_eq!( - /// List(vec![Integer, Integer, arr(Integer, Integer)]).is_concrete(), + /// List(vec![Integer, Boolean, arr(Integer, Integer)]).is_concrete(), /// Ok(()) /// ); /// assert_eq!( @@ -87,6 +91,7 @@ impl Type { pub fn is_concrete(&self) -> Result<(), String> { match self { Integer => Ok(()), + Boolean => todo!(), Arrow(a, b) => b.is_concrete().and_then(|_ok| a.is_concrete()), List(v) => { let mut res = Ok(()); |