From 3a0aecd81e0a4987151fceecda06c74ca90fffc8 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sat, 12 Oct 2024 10:54:33 -0500 Subject: [PATCH] Add a ZIG test program. 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. --- tests/hellozig/.gitignore | 4 ++++ tests/hellozig/Makefile | 16 ++++++++++++++++ tests/hellozig/README | 18 ++++++++++++++++++ tests/hellozig/assignment.zig | 17 +++++++++++++++++ tests/hellozig/hello-world.zig | 5 +++++ tests/hellozig/integers.zig | 19 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 tests/hellozig/.gitignore create mode 100644 tests/hellozig/Makefile create mode 100644 tests/hellozig/README create mode 100644 tests/hellozig/assignment.zig create mode 100644 tests/hellozig/hello-world.zig create mode 100644 tests/hellozig/integers.zig diff --git a/tests/hellozig/.gitignore b/tests/hellozig/.gitignore new file mode 100644 index 0000000..fd43876 --- /dev/null +++ b/tests/hellozig/.gitignore @@ -0,0 +1,4 @@ +hello-zig +assignment +integers + diff --git a/tests/hellozig/Makefile b/tests/hellozig/Makefile new file mode 100644 index 0000000..d244f3a --- /dev/null +++ b/tests/hellozig/Makefile @@ -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 + diff --git a/tests/hellozig/README b/tests/hellozig/README new file mode 100644 index 0000000..2b4135b --- /dev/null +++ b/tests/hellozig/README @@ -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 + diff --git a/tests/hellozig/assignment.zig b/tests/hellozig/assignment.zig new file mode 100644 index 0000000..7c08271 --- /dev/null +++ b/tests/hellozig/assignment.zig @@ -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; +} diff --git a/tests/hellozig/hello-world.zig b/tests/hellozig/hello-world.zig new file mode 100644 index 0000000..933ff9b --- /dev/null +++ b/tests/hellozig/hello-world.zig @@ -0,0 +1,5 @@ +const std = @import("std"); + +pub fn main() !void { + std.debug.print("Hello, World!\n", .{}); +} diff --git a/tests/hellozig/integers.zig b/tests/hellozig/integers.zig new file mode 100644 index 0000000..a991032 --- /dev/null +++ b/tests/hellozig/integers.zig @@ -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}); +}