slige/tests/generics.slg

24 lines
418 B
Plaintext
Raw Normal View History

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