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