aboutsummaryrefslogtreecommitdiff
path: root/examples/monorepo/packages/alpha/src/lib.zig
blob: 2aa7716d1973a8e198f951d8683014888c2ec0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const std = @import("std");

/// Double a value.
pub fn double(x: i32) i32 {
    return x * 2;
}

/// Square a value.
pub fn square(x: i32) i32 {
    return x * x;
}

test "alpha: double" {
    try std.testing.expectEqual(@as(i32, 8), double(4));
    try std.testing.expectEqual(@as(i32, -6), double(-3));
    try std.testing.expectEqual(@as(i32, 0), double(0));
}

test "alpha: square" {
    try std.testing.expectEqual(@as(i32, 9), square(3));
    try std.testing.expectEqual(@as(i32, 9), square(-3));
    try std.testing.expectEqual(@as(i32, 0), square(0));
}