39 lines
899 B
Rust
39 lines
899 B
Rust
use anyhow::{bail, Result};
|
|
|
|
use crate::{
|
|
bidir_debruijn::{app_ctx, synthesize},
|
|
convert_data::convert_term,
|
|
data_debruijn::Context,
|
|
data_debruijn::Term,
|
|
parser::TermParser,
|
|
};
|
|
|
|
fn term_of(str: &'static str) -> Result<Term> {
|
|
let term_parser = TermParser::new();
|
|
let term = term_parser.parse(str)?;
|
|
let converted = convert_term(&term);
|
|
Ok(converted)
|
|
}
|
|
|
|
#[test]
|
|
fn test_id() -> Result<()> {
|
|
let id = term_of(r"\x.x")?;
|
|
let ctx = Context::default();
|
|
let (ty, out_ctx) = synthesize(&ctx, &id)?;
|
|
bail!("Synthesized: {:?} (context = {:?})", ty, out_ctx);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_id_of_unit() -> Result<()> {
|
|
let id_of_unit = term_of(r"(\x.x) ()")?;
|
|
let ctx = Context::default();
|
|
|
|
let (ty, out_ctx) = synthesize(&ctx, &id_of_unit)?;
|
|
let wtf = app_ctx(&out_ctx, &ty);
|
|
println!("WTF: {wtf:?}");
|
|
bail!("Synthesized: {:?} (context = {:?})", ty, out_ctx);
|
|
Ok(())
|
|
}
|