Zig.Unit (zigler v0.7.3) View Source
Hooks your zig code into ExUnit, by converting zig tests into ExUnit tests.
Usage
Example
Inside your zig code (dependent.zig
):
const beam = @import("beam.zig");
const assert = beam.assert;
fn one() i64 {
return 1;
}
test "the one function returns one" {
assert(one() == 1);
}
Inside your elixir code:
defmodule MyZigModule do
use Zig
~Z"""
const dependent = @import("dependent.zig");
/// nif: some_nif_fn/1
...
"""
end
Inside your test module:
defmodule MyZigTest do
use ExUnit.Case, async: true
use Zig.Unit
zigtest MyZigModule
end
Scope
zigtest will run tests from the following sources:
- any tests inside of a sigil Z or sigil z construction
- any tests inside
pub
@import
zig sources. - any tests inside
pub usingnamespace
zig sources. - recursively discovered
pub
structs.
Link to this section Summary
Functions
loads a module that wraps a zigler NIF, consults the corresponding zig code, generating the corresponding zig tests.
Link to this section Functions
loads a module that wraps a zigler NIF, consults the corresponding zig code, generating the corresponding zig tests.
Must be called from within a module that has use ExUnit.Case
and use Zig