Skip to content

Commit

Permalink
exe main lib main
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 12, 2024
1 parent 84b49fa commit 80fb281
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const std = @import("std");

const WhileRange = @import("root.zig").WhileRange;
const lib_main = @import("root.zig").lib_main;
const lib_main = @import("root.zig").main;

pub fn main() !void {
// Integer range (forward)
try lib_main();
std.debug.print("{s}\n", .{"Hello, world!"});
}

test "test_exe_main" {
std.debug.print("Running tests in src/main.zig \"main\"\n", .{});

try main();
}

test "test_lib_main_within_exe" {
try lib_main();
}
6 changes: 6 additions & 0 deletions src/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ test "test_lib_main" {
try main();
}

const exe_main = @import("main.zig").main;

test "test exe main() within lib" {
try exe_main();
}

test "signed/unsigned int cast" {
const signed: i8 = -1;
const unsigned: u8 = @as(u8, @bitCast(signed)); // Cast -1 i8 to 255 u8
Expand Down

0 comments on commit 80fb281

Please sign in to comment.