From c629fac4297b8f13bdab00100f3b05549174154e Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 5 Aug 2025 11:40:00 +0300 Subject: Added boilerplate and tests for booleans, integer comparisons and boolean operators. --- src/type/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/type/mod.rs') 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, Box), List(Vec), @@ -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(()); -- cgit v1.2.3