diff options
| author | David Czihak <git@dcz.at> | 2026-05-09 13:01:50 +0200 |
|---|---|---|
| committer | David Czihak <git@dcz.at> | 2026-05-09 13:01:50 +0200 |
| commit | 4b6f66fd512c254b5a82220dc77411fe391dd258 (patch) | |
| tree | 7d77d7966e9ad2e296986ea8cfeb607088028195 /examples/monorepo/packages/alpha | |
| parent | 64e9c56fc665972fdde5234c4fb2f2a882e237dc (diff) | |
Chore: Rework examples for thorough extension testing
Diffstat (limited to 'examples/monorepo/packages/alpha')
| -rw-r--r-- | examples/monorepo/packages/alpha/build.zig | 17 | ||||
| -rw-r--r-- | examples/monorepo/packages/alpha/build.zig.zon | 8 | ||||
| -rw-r--r-- | examples/monorepo/packages/alpha/src/lib.zig | 23 |
3 files changed, 48 insertions, 0 deletions
diff --git a/examples/monorepo/packages/alpha/build.zig b/examples/monorepo/packages/alpha/build.zig new file mode 100644 index 0000000..9ec9553 --- /dev/null +++ b/examples/monorepo/packages/alpha/build.zig @@ -0,0 +1,17 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const lib_tests = b.addTest(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path("src/lib.zig"), + .target = target, + .optimize = optimize, + }), + }); + const run_tests = b.addRunArtifact(lib_tests); + const test_step = b.step("test", "Run alpha tests"); + test_step.dependOn(&run_tests.step); +} diff --git a/examples/monorepo/packages/alpha/build.zig.zon b/examples/monorepo/packages/alpha/build.zig.zon new file mode 100644 index 0000000..b5b32fc --- /dev/null +++ b/examples/monorepo/packages/alpha/build.zig.zon @@ -0,0 +1,8 @@ +.{ + .name = .alpha, + .version = "0.1.0", + .fingerprint = 0xd0e0396aca382c40, + .minimum_zig_version = "0.16.0", + .dependencies = .{}, + .paths = .{ "build.zig", "build.zig.zon", "src" }, +} diff --git a/examples/monorepo/packages/alpha/src/lib.zig b/examples/monorepo/packages/alpha/src/lib.zig new file mode 100644 index 0000000..2aa7716 --- /dev/null +++ b/examples/monorepo/packages/alpha/src/lib.zig @@ -0,0 +1,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)); +} |
