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/sexp/case.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/sexp/case.rs') diff --git a/src/sexp/case.rs b/src/sexp/case.rs index 4c2c7ba..cc643f3 100644 --- a/src/sexp/case.rs +++ b/src/sexp/case.rs @@ -52,6 +52,18 @@ impl SExp { * ]) * ); * ``` + * + * Coproducts must be handled individually: + * ```rust + * use myslip::r#type::Type::*; + * use myslip::sexp::{SExp::*, SLeaf::*, util::*}; + * + * assert_eq!( + * scons(Coprod, scons(Ty(Boolean), scons(2, Nil))) + * .matches_pat(&scons(Inr, scons(var("x"), Nil))), + * Some(vec![(Var("x".to_string()), Atom(Int(2)))]) + * ); + * ``` */ pub fn matches_pat(&self, pat: &SExp) -> Option> { match (self, pat) { -- cgit v1.2.3