From b4174515360a7f9ee6cabd629b43e284f595c0ab Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 9 Oct 2017 12:26:25 -0700 Subject: [PATCH] Basic typing test --- src/schala_lang/type_check.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/schala_lang/type_check.rs b/src/schala_lang/type_check.rs index 7775d20..6541c89 100644 --- a/src/schala_lang/type_check.rs +++ b/src/schala_lang/type_check.rs @@ -211,3 +211,25 @@ impl TypeContext { } } +#[cfg(test)] +mod tests { + use super::{TypeContext, TypeVariable, UVar}; + use super::TypeVariable::*; + use schala_lang::parsing::{parse, tokenize}; + + macro_rules! type_test { + ($input:expr, $correct:expr) => { + { + let mut tc = TypeContext::new(); + let ast = parse(tokenize($input)).0.unwrap() ; + assert_eq!($correct, tc.type_check(&ast).unwrap()) + } + } + } + + #[test] + fn basic_inference() { + type_test!("30", Univ(UVar::Integer)) + } +} +