Lines
100 %
Functions
Branches
use super::*;
use crate::ast::Number;
fn params(name: &str) -> LambdaParams {
LambdaParams::simple(vec![name.to_string()])
}
#[test]
fn equal_sources_intern_to_one_id() -> Result<()> {
let mut cache = MonomorphCache::default();
let first = cache.intern_source(params("k"), Expr::symbol("k"))?;
let again = cache.intern_source(params("k"), Expr::symbol("k"))?;
assert_eq!((first, again), (0, 0));
Ok(())
fn distinct_sources_intern_to_distinct_ids() -> Result<()> {
let second = cache.intern_source(params("k"), Expr::Number(Number::Index(2.into())))?;
assert_eq!((first, second), (0, 1));
assert_eq!(
cache.source(second).map(|(_, body)| body),
Some(&Expr::Number(Number::Index(2.into())))
);
assert!(cache.source(2).is_none());