Skip to content

Commit

Permalink
Add a ZIG test program.
Browse files Browse the repository at this point in the history
The zig compiler is way behing on opensuse.
I tried building zig from source but encountered many compile errors.

I'll wait until opensuse is updated.
  • Loading branch information
epasveer committed Oct 12, 2024
1 parent ddec770 commit 3a0aecd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/hellozig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello-zig
assignment
integers

16 changes: 16 additions & 0 deletions tests/hellozig/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: all
all: hello-world assignment integers

hello-world: hello-world.zig
zig build-exe -O Debug hello-world.zig

assignment: assignment.zig
zig build-exe -O Debug assignment.zig

integers: integers.zig
zig build-exe -O Debug integers.zig

.PHONY: clean
clean:
rm -f *.o hello-world assignment integers

18 changes: 18 additions & 0 deletions tests/hellozig/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Examples are from here:

https://zig-by-example.com/

Run Seer like this. The break-function is the name of the program and ".main".

$ /usr/local/bin/seergdb -s --bf=hello-world.main ./hello-world

Set the "Source" file configurations in Seer's config page.

o Add "*.zig" for valid source files.
o Add "/usr/lib/zig/" for "misc" files.

Zig resources:

https://github.com/ziglang/zig
https://github.com/zigcc/awesome-zig

17 changes: 17 additions & 0 deletions tests/hellozig/assignment.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const std = @import("std");

pub fn main() !void {

const c: bool = true;

var v: bool = false;
v = true;

const inferred = true;

var u: bool = undefined;
u = true;

_ = c;
_ = inferred;
}
5 changes: 5 additions & 0 deletions tests/hellozig/hello-world.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const std = @import("std");

pub fn main() !void {
std.debug.print("Hello, World!\n", .{});
}
19 changes: 19 additions & 0 deletions tests/hellozig/integers.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const std = @import("std");
const print = std.debug.print;

const a: u8 = 1;
const b: u32 = 10;
const c: i64 = 100;
const d: isize = 1_000;

const e: u21 = 10_000;
const f: i42 = 100_000;

const g: comptime_int = 1_000_000;
const h = 10_000_000;
const i = '💯';

pub fn main() !void {
print("integer: {d}\n", .{i});
print("unicode: {u}\n", .{i});
}

0 comments on commit 3a0aecd

Please sign in to comment.