-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate tests to Orb.Import.register/2
- Loading branch information
1 parent
960ffa1
commit cb0a94e
Showing
5 changed files
with
64 additions
and
63 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,60 @@ | ||
defmodule ImportTest do | ||
use ExUnit.Case, async: true | ||
|
||
test "Orb.Import.register/1" do | ||
defmodule ImportsExample do | ||
use Orb | ||
|
||
defmodule Echo do | ||
use Orb.Import, name: :echo | ||
|
||
defw(int32(a: I32), I32) | ||
defw(int64(a: I64), I64) | ||
end | ||
|
||
defmodule Log do | ||
use Orb.Import | ||
|
||
defw(int32(a: I32)) | ||
defw(int64(a: I64)) | ||
end | ||
|
||
defmodule Time do | ||
use Orb.Import | ||
|
||
defw(unix_time(), I64) | ||
end | ||
|
||
# TODO: | ||
# use Orb.Import, name: :echo | ||
# Echo.import() | ||
# Log.import() | ||
# Time.import() | ||
|
||
Orb.Import.register(Echo, :echo) | ||
Orb.Import.register(Log, :log) | ||
Orb.Import.register(Time, :time) | ||
|
||
defw test() do | ||
Echo.int32(42) |> Orb.Stack.drop() | ||
Echo.int64(42) |> Orb.Stack.drop() | ||
end | ||
end | ||
|
||
assert """ | ||
(module $ImportsExample | ||
(import "echo" "int32" (func $ImportTest.ImportsExample.Echo.int32 (param $a i32) (result i32))) | ||
(import "echo" "int64" (func $ImportTest.ImportsExample.Echo.int64 (param $a i64) (result i64))) | ||
(import "log" "int32" (func $ImportTest.ImportsExample.Log.int32 (param $a i32))) | ||
(import "log" "int64" (func $ImportTest.ImportsExample.Log.int64 (param $a i64))) | ||
(import "time" "unix_time" (func $ImportTest.ImportsExample.Time.unix_time (result i64))) | ||
(func $test (export "test") | ||
(call $ImportTest.ImportsExample.Echo.int32 (i32.const 42)) | ||
drop | ||
(call $ImportTest.ImportsExample.Echo.int64 (i64.const 42)) | ||
drop | ||
) | ||
) | ||
""" = Orb.to_wat(ImportsExample) | ||
end | ||
end |
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