use lsts::tlc::TLC;
#[test]
fn l1_literals() {
let mut tlc = TLC::new();
let l1 = tlc.import_file(None, "preludes/l1.tlc").unwrap();
tlc.check(Some(l1), "0: I64;").unwrap();
tlc.check(Some(l1), "0: I64;").unwrap();
tlc.check(Some(l1), "1: I64;").unwrap();
tlc.check(Some(l1), "1: I64;").unwrap();
tlc.check(Some(l1), "-1: I64;").unwrap();
tlc.check(Some(l1), "-1: U64;").unwrap_err();
}
#[test]
fn l1_functions() {
let mut tlc = TLC::new();
let l1 = tlc.import_file(None, "preludes/l1.tlc").unwrap();
tlc.check(Some(l1), "let f(x:I64): I64 = x; f(1:I64);").unwrap();
tlc.check(Some(l1), "let f(x:I64): I64 = x; f(1:I64);").unwrap();
tlc.check(Some(l1), "let f(x:I64): I64 = x; f(-1);").unwrap();
tlc.check(Some(l1), "let f(x:I64): I64 = x; f(-1);").unwrap();
tlc.check(Some(l1), "let f(x:I64): I64 = x; f(-1);").unwrap();
}
#[test]
fn l1_dot_functions() {
let mut tlc = TLC::new();
let l1 = tlc.import_file(None, "preludes/l1.tlc").unwrap();
tlc.check(Some(l1), "let .f(x:I64): I64 = x; (1:I64).f: I64;").unwrap();
tlc.check(Some(l1), "let .f(x:I64, y:I64): I64 = x; (1:I64).f(2:I64): I64;").unwrap();
tlc.check(Some(l1), "let .f(x:I64, y:I64, z:I64): I64 = x; (1:I64).f(2:I64,3:I64): I64;").unwrap();
}
#[test]
fn l1_reduce() {
let mut tlc = TLC::new();
let l1 = tlc.import_file(None, "preludes/l1.tlc").unwrap();
tlc.check(Some(l1), "- 0 @reduce;").unwrap();
tlc.check(Some(l1), "- 1 @reduce;").unwrap();
tlc.check(Some(l1), "-1 @reduce;").unwrap();
tlc.check(Some(l1), "- -1 @reduce;").unwrap();
}
#[test]
fn l1_homogenous_tuples() {
let mut tlc = TLC::new();
let l1 = tlc.import_file(None, "preludes/l1.tlc").unwrap();
tlc.check(Some(l1), "(): I64[0];").unwrap();
tlc.check(Some(l1), "(1): I64[0];").unwrap_err();
tlc.check(Some(l1), "(1): I64;").unwrap();
tlc.check(Some(l1), "(1,): I64[0];").unwrap_err();
tlc.check(Some(l1), "(1,): I64[1];").unwrap();
tlc.check(Some(l1), "(1,2): I64[1];").unwrap_err();
tlc.check(Some(l1), "(1,2): I64[];").unwrap();
tlc.check(Some(l1), "(1,2): I64[2];").unwrap();
tlc.check(Some(l1), "(1,2,3): I64[2];").unwrap_err();
tlc.check(Some(l1), "(1,2,3): I64[3];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3]).0 @reduce :[1];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3]).1 @reduce :[2];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3]).2 @reduce :[3];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3])[0] @reduce :[1];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3])[1] @reduce :[2];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[3])[2] @reduce :[3];").unwrap();
tlc.check(Some(l1), "((1,2,3): I64[])[2] @reduce :[3];").unwrap();
tlc.check(Some(l1), "().length @reduce :[0];").unwrap();
tlc.check(Some(l1), "(3,).length @reduce :[1];").unwrap();
tlc.check(Some(l1), "(3,4).length @reduce :[2];").unwrap();
tlc.check(Some(l1), "(3,4,7).length @reduce :[3];").unwrap();
tlc.check(Some(l1), "((3,4,7): I64[]).length @reduce :[3];").unwrap();
}