-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completes sensible errros for missing on_load callbacks
- Loading branch information
Showing
4 changed files
with
74 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule ZiglerTest.Callbacks.MissingOnLoadCallbackTest do | ||
# this is a test of the "automatic" on_load function. | ||
|
||
use ZiglerTest.IntegrationCase, async: true | ||
|
||
test "compiler error when on_load function is missing" do | ||
assert_raise CompileError, "nofile: on_load callback foo not found", fn -> | ||
Code.compile_quoted(quote do | ||
defmodule ZiglerTest.MissingOnloadCallback do | ||
use Zig, otp_app: :zigler, callbacks: [on_load: :foo] | ||
~Z""" | ||
pub fn bar() u8 { return 47; } | ||
""" | ||
end | ||
end) | ||
end | ||
end | ||
|
||
test "compiler error when on_load function is not pub" do | ||
assert_raise CompileError, "nofile:2: on_load callback foo must be declared `pub`", fn -> | ||
Code.compile_quoted(quote do | ||
defmodule ZiglerTest.NotPubOnloadCallback do | ||
use Zig, otp_app: :zigler, callbacks: [on_load: :foo] | ||
~Z""" | ||
const beam = @import("beam"); | ||
fn foo(_: [*c]?*anyopaque, _: beam.term) c_int { return 0; } | ||
pub fn bar() u8 { return 47; } | ||
""" | ||
end | ||
end) | ||
end | ||
end | ||
end |