slige/tests/generics.slg
2025-01-17 11:50:14 +01:00

24 lines
418 B
Plaintext

fn exit(status_code: int) #[builtin(Exit)] {}
fn print(msg: string) #[builtin(Print)] {}
fn println(msg: string) { print(msg + "\n") }
fn id<T>(v: T) -> T {
v
}
fn main() {
println("calling with int");
if id::<int>(123) != 123 {
exit(1);
}
println("calling with bool");
if id::<bool>(true) != true {
exit(1);
}
println("all tests ran successfully");
exit(0);
}