From a70dcaa949f41c585f9aea5e79f2550053d8e857 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 19 Aug 2025 13:55:05 +0300 Subject: test: added boilerplate and tests for coproduct parsing, type checking and evaluation --- src/type/case.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/type/case.rs') diff --git a/src/type/case.rs b/src/type/case.rs index c53bbd0..d8871af 100644 --- a/src/type/case.rs +++ b/src/type/case.rs @@ -324,4 +324,22 @@ mod tests { Ok(vec![]) ); } + + #[test] + fn test_sumtype_match() { + assert_eq!( + scons(Inl, scons(var("x"), Nil)).matches_type(&sumtype(Integer, Boolean)), + Ok(vec![("x".to_string(), Integer)]) + ); + assert_eq!( + scons(Inr, scons(var("x"), Nil)).matches_type(&sumtype(Integer, Boolean)), + Ok(vec![("x".to_string(), Boolean)]) + ); + assert!( + scons(Inl, scons(True, Nil)).matches_type(&sumtype(Integer, Boolean)).is_err() + ); + assert!( + scons(Inr, scons(1, Nil)).matches_type(&sumtype(Integer, Boolean)).is_err() + ); + } } -- cgit v1.2.3