zigler v0.3.0-pre Zigler.Unit 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 Zigler, otp_app: :my_app

  ~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 Zigler.Unit

  zigtest MyZigModule
end

Scope

This module will run tests in all zig code that resides in the same code directory as the base module (or overridden directory, if applicable). Zig code in subdirectories will not be subjected to test conversion, so if you would like to run a subset of tests using the Zig test facility (and without the support of a BEAM VM), you should put them in subdirectories.

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

Link to this macro

zigtest(mod, options \\ [])

View Source (macro)

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 Zigler