use lsts::tlc::TLC;
#[test]
fn check_simplytyped() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab; let a: Ab;").unwrap();
tlc.check(None, "let a: Ab;").unwrap_err();
tlc.check(None, "type Ab; type Bc; let a: (Ab,)->Bc; let b: Ab; a(b);").unwrap();
tlc.check(None, "type Ab; type Bc; let a: (Ab,)->Bc; let b: Bc; a(b);").unwrap_err();
}
#[test]
fn check_normalization() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab; type Bc; type Cd; let a: Ab+Bc*Cd; a:Cd*Bc+Ab;").unwrap();
}
#[test]
fn check_subtyping() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab; type Bc; type Cd; let a: Ab+Bc; a:Ab;").unwrap();
tlc.check(None, "type Ab; type Bc; type Cd; let a: Ab+Bc; a:Bc;").unwrap();
tlc.check(None, "type Ab; type Bc; type Cd; let a: Ab+Bc; a:Cd;").unwrap_err();
}
#[test]
fn check_narrow_implication() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab; type Bc: Ab; let a: Ab; a:Ab;").unwrap(); tlc.check(None, "type Ab; type Bc: Ab; let a: Ab; a:Bc;").unwrap_err(); tlc.check(None, "type Ab; type Bc: Ab; let a: Bc; a:Ab;").unwrap(); tlc.check(None, "type Ab; type Bc: Ab; let a: Bc; a:Bc;").unwrap(); }
#[test]
fn check_narrow_implication_with_parameters() {
let mut tlc = TLC::new();
tlc.check(None, "type Pt; type Ab<A>; type Bc<B>: Ab<B>; let a: Ab<Pt>; a:Ab<Pt>;").unwrap(); tlc.check(None, "type Pt; type Ab<A>; type Bc<B>: Ab<B>; let a: Ab<Pt>; a:Bc<Pt>;").unwrap_err(); tlc.check(None, "type Pt; type Ab<A>; type Bc<B>: Ab<B>; let a: Bc<Pt>; a:Ab<Pt>;").unwrap(); tlc.check(None, "type Pt; type Ab<A>; type Bc<B>: Ab<B>; let a: Bc<Pt>; a:Bc<Pt>;").unwrap(); }
#[test]
fn check_products_and_ratios() {
let mut tlc = TLC::new();
tlc.check(None, "type At; let a: At*At; a:At*At;").unwrap();
tlc.check(None, "type At; let a: At*At; a:?;").unwrap();
tlc.check(None, "type At; let a: At*At; a:?/();").unwrap();
tlc.check(None, "type At; let a: At*At; a:At;").unwrap_err();
tlc.check(None, "type At; let a: At*At/At; a:At;").unwrap();
tlc.check(None, "type At; let a: At*At/At; a:?;").unwrap();
tlc.check(None, "type At; let a: At*At/At; a:?/();").unwrap();
tlc.check(None, "type At; let a: At/At; a:();").unwrap();
tlc.check(None, "type At; let a: At/At; a:?;").unwrap();
tlc.check(None, "type At; let a: At/At; a:?/();").unwrap();
tlc.check(None, "type At; let a: At/At; a:At;").unwrap_err();
tlc.check(None, "type At; let a: At/At*At; a:At;").unwrap_err();
tlc.check(None, "type At; let a: At/At*At; a:()/At;").unwrap();
tlc.check(None, "type At; let a: At/At*At; a:()/At*At;").unwrap_err();
tlc.check(None, "type At; let a: At/At*At; a:?/();").unwrap_err();
}
#[test]
fn check_kinded_polymorphism() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Ab = a;").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Bc = b;").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Ab+Bc = a;").unwrap_err();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Ab+Bc = b;").unwrap_err();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Ab = b;").unwrap_err();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Bc; let c:Bc = a;").unwrap_err();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Ab+Bc; let c:Ab = a;").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Ab+Bc; let c:Bc = a;").unwrap_err();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Ab+Bc; let c:Ab = b;").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let a:Ab; let b:Ab+Bc; let c:Bc = b;").unwrap();
}
#[test]
fn check_kinded_parametric_polymorphism() {
let mut tlc = TLC::new();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:Ab::Term); let f(x:Bc::BKind); let x:Ab; f(x);").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:Ab::Term); let f(x:Bc::BKind); let x:Bc; f(x);").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:Ab::Term); let f(x:Bc::BKind); let x:Ab+Bc; f(x);").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:X::Term); let f(x:X::BKind); let x:Ab; f(x);").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:X::Term); let f(x:X::BKind); let x:Bc; f(x);").unwrap();
tlc.check(None, "type Ab::Term; type Bc::BKind; let f(x:X::Term); let f(x:X::BKind); let x:Ab+Bc; f(x);").unwrap(); }