Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: oop.zig Unit Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
execute_unit_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Execute tests
shell: bash
run: |
curl https://raw.githubusercontent.com/tristanisham/zvm/master/install.sh | bash
export PATH="$HOME/.zvm/bin:$HOME/.zvm/self:$PATH"
./install_zig_with_zvm.sh
zig build test --summary all
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/zig-out/bin/test",
"cwd": "${workspaceRoot}",
}
]
}
3 changes: 3 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn build(b: *std.Build) !void {

const exe_tests = b.addTest(.{
.root_module = mod_tests,
.use_llvm = true,
});
exe_tests.root_module.addImport("interface", mod);

Expand All @@ -28,6 +29,8 @@ pub fn build(b: *std.Build) !void {
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_exe_tests.step);

b.installArtifact(exe_tests);

if (enable_examples) {
var iterable_dir = try std.fs.cwd().openDir("examples", .{ .iterate = true });
defer iterable_dir.close();
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .oop_zig,
.version = "0.0.1",
.fingerprint = 0x4d0368551b1ab249, // Changing this has security and trust implications.
.minimum_zig_version = "0.16.0-dev.233+a0ec4e270",
.minimum_zig_version = "0.15.2",
.dependencies = .{},
.paths = .{
"build.zig",
Expand Down
7 changes: 7 additions & 0 deletions install_zig_with_zvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

version=$(awk -F'"' '/\.minimum_zig_version/ { print $2 }' build.zig.zon)
echo "Installing Zig version $version using zvm..."

zvm install $version
zvm use $version
14 changes: 0 additions & 14 deletions src/interface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ pub fn DeriveFromBase(comptime BaseType: anytype, comptime Derived: type) type {
if (!@hasField(Derived, "base") or !(@FieldType(Derived, "base") == BaseType)) {
@compileError("Deriving from a base instead of an interface requires a 'base' field in the derived type.");
}
// // disallow fields override
// var base: ?type = BaseType;
// while (base != null) {
// for (std.meta.fields(Derived)) |field| {
// if (@hasField(base.?, field.name) and !std.mem.eql(u8, field.name, "base")) {
// @compileError("Field already exists in the base: " ++ field.name);
// }
// }
// base = base.?.Base;
// }
};

return struct {
Expand All @@ -331,10 +321,6 @@ pub fn DeriveFromBase(comptime BaseType: anytype, comptime Derived: type) type {
pub fn data(self: *Self) *Derived {
return &self.__data;
}

// pub fn __destructor(self: *Self) void {
// self.interface.__destructor(self.interface);
// }
};
}

Expand Down
Loading