this repo has no description

zig init

altagos.dev 02d3631e

+110
+2
.gitignore
··· 1 + *zig-cache 2 + *zig-out
+52
build.zig
··· 1 + const std = @import("std"); 2 + 3 + pub fn build(b: *std.Build) void { 4 + const target = b.standardTargetOptions(.{}); 5 + const optimize = b.standardOptimizeOption(.{}); 6 + 7 + const mod = b.addModule("aether", .{ 8 + .root_source_file = b.path("src/root.zig"), 9 + .target = target, 10 + }); 11 + 12 + const exe = b.addExecutable(.{ 13 + .name = "aether", 14 + .root_module = b.createModule(.{ 15 + .root_source_file = b.path("src/main.zig"), 16 + .target = target, 17 + .optimize = optimize, 18 + .imports = &.{ 19 + .{ .name = "aether", .module = mod }, 20 + }, 21 + }), 22 + }); 23 + 24 + b.installArtifact(exe); 25 + 26 + const run_step = b.step("run", "Run the app"); 27 + 28 + const run_cmd = b.addRunArtifact(exe); 29 + run_step.dependOn(&run_cmd.step); 30 + 31 + run_cmd.step.dependOn(b.getInstallStep()); 32 + 33 + if (b.args) |args| { 34 + run_cmd.addArgs(args); 35 + } 36 + 37 + const mod_tests = b.addTest(.{ 38 + .root_module = mod, 39 + }); 40 + 41 + const run_mod_tests = b.addRunArtifact(mod_tests); 42 + 43 + const exe_tests = b.addTest(.{ 44 + .root_module = exe.root_module, 45 + }); 46 + 47 + const run_exe_tests = b.addRunArtifact(exe_tests); 48 + 49 + const test_step = b.step("test", "Run tests"); 50 + test_step.dependOn(&run_mod_tests.step); 51 + test_step.dependOn(&run_exe_tests.step); 52 + }
+13
build.zig.zon
··· 1 + .{ 2 + .name = .aether, 3 + .version = "0.0.0", 4 + .fingerprint = 0x27a0a7c00a5c2057, // Changing this has security and trust implications. 5 + .minimum_zig_version = "0.15.0-dev.695+041eedc1c", 6 + .dependencies = .{}, 7 + .paths = .{ 8 + "build.zig", 9 + "build.zig.zon", 10 + "src", 11 + // "LICENSE", 12 + }, 13 + }
+24
src/main.zig
··· 1 + const std = @import("std"); 2 + const aether = @import("aether"); 3 + 4 + pub fn main() !void { 5 + std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); 6 + try aether.advancedPrint(); 7 + } 8 + 9 + test "simple test" { 10 + var list = std.ArrayList(i32).init(std.testing.allocator); 11 + defer list.deinit(); // Try commenting this out and see if zig detects the memory leak! 12 + try list.append(42); 13 + try std.testing.expectEqual(@as(i32, 42), list.pop()); 14 + } 15 + 16 + test "fuzz example" { 17 + const Context = struct { 18 + fn testOne(context: @This(), input: []const u8) anyerror!void { 19 + _ = context; 20 + try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input)); 21 + } 22 + }; 23 + try std.testing.fuzz(Context{}, Context.testOne, .{}); 24 + }
+19
src/root.zig
··· 1 + const std = @import("std"); 2 + 3 + pub fn advancedPrint() !void { 4 + const stdout_file = std.io.getStdOut().writer(); 5 + var bw = std.io.bufferedWriter(stdout_file); 6 + const stdout = bw.writer(); 7 + 8 + try stdout.print("Run `zig build test` to run the tests.\n", .{}); 9 + 10 + try bw.flush(); // Don't forget to flush! 11 + } 12 + 13 + pub fn add(a: i32, b: i32) i32 { 14 + return a + b; 15 + } 16 + 17 + test "basic add functionality" { 18 + try std.testing.expect(add(3, 7) == 10); 19 + }