Skip to content

Commit 5312f76

Browse files
committed
Add test for rust module calls
1 parent c9f7d4e commit 5312f76

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
defmodule ComponentsGuide.Rustler.MathTest do
2+
use ExUnit.Case, async: true
3+
4+
alias ComponentsGuide.Rustler.Math
5+
6+
test "add/2" do
7+
assert Math.add(3, 4) == 7
8+
end
9+
10+
test "reverse_string/1" do
11+
assert Math.reverse_string("abcd") == "dcba"
12+
end
13+
14+
test "wasm_example/2" do
15+
wasm_source = """
16+
(module
17+
(func (export "answer") (result i32)
18+
i32.const 42
19+
)
20+
)
21+
"""
22+
23+
assert Math.wasm_example(wasm_source, "answer") == 42
24+
end
25+
end

0 commit comments

Comments
 (0)