const std = @import("std");
const c = @cImport(@cInclude("stdio.h")); // -lc
fn sum(comptime T: type, comptime a: T, b: T) T {
return a + b;
}
test "two + two is four" {
try std.testing.expectEqual(sum(i8, 2, 2), 4);
try std.testing.expectEqual(sum(i8, 2, 2), 5);
}
fn getrnd() i32 {
var rnd = std.Random.DefaultPrng.init(123);
return std.Random.int(rnd.random(), i32);
}
pub fn main() void {
const two: i8 = 1 + 1;
const three = comptime sum(i32, 1, getrnd());
const more = sum(i32, 1, c.fgetc(c.stdin));
std.debug.print("Hello, {} {} {} {}\n", .{ two, sum(i32, @as(i32, 2000), getrnd()), three, more });
}