aboutsummaryrefslogtreecommitdiff
path: root/examples/monorepo/packages/alpha
diff options
context:
space:
mode:
Diffstat (limited to 'examples/monorepo/packages/alpha')
-rw-r--r--examples/monorepo/packages/alpha/build.zig17
-rw-r--r--examples/monorepo/packages/alpha/build.zig.zon8
-rw-r--r--examples/monorepo/packages/alpha/src/lib.zig23
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));
+}