# HG changeset patch # User Simon Heath # Date 1726760149 14400 # Thu Sep 19 11:35:49 2024 -0400 # Branch devel # Node ID d630ce41e986fb068b6e99be30a28543419c3aa3 # Parent 963bbb7c8a8d824624e77ff23abb53d3970facf4 add a more thorough lambda test program diff --git a/tests/programs/test_lambda6.gt b/tests/programs/test_lambda6.gt new file mode 100644 --- /dev/null +++ b/tests/programs/test_lambda6.gt @@ -0,0 +1,36 @@ +-- Format: +-- status: success +-- Compile: +-- status: success +-- Run: +-- status: success +-- stdout: +-- true +-- 3 + +fn apply1(|In| f fn(In) In, arg In) In = + f(arg) +end + +fn apply2(|In, Out| f fn(In) Out, arg In) Out = + f(arg) +end + + +-- fn id(|T| val T) T = val end + +fn main() {} = + let f1 fn(Bool) Bool = fn(val Bool) Bool = val end + let f2 fn(Bool) I32 = fn(val Bool) I32 = 4 end + -- let f3 = fn(|T| val T) T = val end + let a1 Bool = apply1(f1, true) + let a2 Bool = apply2(f1, true) + -- let b I32 = apply(f2, true) + -- let c Bool = apply1(id, true) + -- let d I32 = apply(id, 3) + + -- let b1 Bool = apply1(f1, true) + -- let b2 Bool = apply1(id, true) + __println_bool(a1) + __println_bool(a2) +end