Skip to content

Commit 09fd09c

Browse files
committed
Rename Math to Wasm
1 parent a473f89 commit 09fd09c

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

Diff for: lib/components_guide/rustler/math.ex renamed to lib/components_guide/rustler/wasm.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule ComponentsGuide.Rustler.Math do
1+
defmodule ComponentsGuide.Rustler.Wasm do
22
# if false and Mix.env() == :dev do
33
use Rustler, otp_app: :components_guide, crate: :componentsguide_rustler_math
44
# # use Rustler, otp_app: :components_guide, crate: :componentsguide_rustler_math, target_dir: System.tmp_dir!()

Diff for: native/componentsguide_rustler_math/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn wasm_example_n_i32_internal(wat_source: String, buffer: bool, f: String, args
187187
return Ok(result);
188188
}
189189

190-
rustler::init!("Elixir.ComponentsGuide.Rustler.Math", [
190+
rustler::init!("Elixir.ComponentsGuide.Rustler.Wasm", [
191191
add,
192192
reverse_string,
193193
wasm_example_n_i32,

Diff for: test/components_guide/rustler/math_test.exs renamed to test/components_guide/rustler/wasm_test.exs

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
defmodule ComponentsGuide.Rustler.MathTest do
1+
defmodule ComponentsGuide.Rustler.WasmTest do
22
use ExUnit.Case, async: true
33

4-
alias ComponentsGuide.Rustler.Math
4+
alias ComponentsGuide.Rustler.Wasm
55

66
test "add/2" do
7-
assert Math.add(3, 4) == 7
7+
assert Wasm.add(3, 4) == 7
88
end
99

1010
test "reverse_string/1" do
11-
assert Math.reverse_string("abcd") == "dcba"
11+
assert Wasm.reverse_string("abcd") == "dcba"
1212
end
1313

1414
test "wasm_example/2" do
@@ -20,7 +20,7 @@ defmodule ComponentsGuide.Rustler.MathTest do
2020
)
2121
"""
2222

23-
assert Math.wasm_example(wasm_source, "answer") == 42
23+
assert Wasm.wasm_example(wasm_source, "answer") == 42
2424
end
2525

2626
test "wasm_example/2 dsl" do
@@ -36,7 +36,7 @@ defmodule ComponentsGuide.Rustler.MathTest do
3636
)
3737
"""
3838

39-
assert Math.wasm_example(wasm_source, "answer") == 42
39+
assert Wasm.wasm_example(wasm_source, "answer") == 42
4040
end
4141

4242
test "wasm_example/4 adding two numbers" do
@@ -50,7 +50,7 @@ defmodule ComponentsGuide.Rustler.MathTest do
5050
)
5151
"""
5252

53-
assert Math.wasm_example(wasm_source, "add", 7, 5) == 12
53+
assert Wasm.wasm_example(wasm_source, "add", 7, 5) == 12
5454
end
5555

5656
test "wasm_example/4 multiplying two numbers" do
@@ -64,7 +64,7 @@ defmodule ComponentsGuide.Rustler.MathTest do
6464
)
6565
"""
6666

67-
assert Math.wasm_example(wasm_source, "multiply", 7, 5) == 35
67+
assert Wasm.wasm_example(wasm_source, "multiply", 7, 5) == 35
6868
end
6969

7070
test "wasm_example/4 checking a number is within a range" do
@@ -84,16 +84,16 @@ defmodule ComponentsGuide.Rustler.MathTest do
8484
)
8585
"""
8686

87-
assert Math.wasm_example(wasm_source, "validate", -1) == 0
88-
assert Math.wasm_example(wasm_source, "validate", 0) == 0
89-
assert Math.wasm_example(wasm_source, "validate", 1) == 1
90-
assert Math.wasm_example(wasm_source, "validate", 2) == 1
91-
assert Math.wasm_example(wasm_source, "validate", 10) == 1
92-
assert Math.wasm_example(wasm_source, "validate", 13) == 1
93-
assert Math.wasm_example(wasm_source, "validate", 255) == 1
94-
assert Math.wasm_example(wasm_source, "validate", 256) == 0
95-
assert Math.wasm_example(wasm_source, "validate", 257) == 0
96-
assert Math.wasm_example(wasm_source, "validate", 2000) == 0
87+
assert Wasm.wasm_example(wasm_source, "validate", -1) == 0
88+
assert Wasm.wasm_example(wasm_source, "validate", 0) == 0
89+
assert Wasm.wasm_example(wasm_source, "validate", 1) == 1
90+
assert Wasm.wasm_example(wasm_source, "validate", 2) == 1
91+
assert Wasm.wasm_example(wasm_source, "validate", 10) == 1
92+
assert Wasm.wasm_example(wasm_source, "validate", 13) == 1
93+
assert Wasm.wasm_example(wasm_source, "validate", 255) == 1
94+
assert Wasm.wasm_example(wasm_source, "validate", 256) == 0
95+
assert Wasm.wasm_example(wasm_source, "validate", 257) == 0
96+
assert Wasm.wasm_example(wasm_source, "validate", 2000) == 0
9797
end
9898

9999
test "wasm_example/4 spits out HTML strings" do
@@ -107,8 +107,8 @@ defmodule ComponentsGuide.Rustler.MathTest do
107107
)
108108
"""
109109

110-
assert Math.wasm_example(wasm_source, "main", 0, 0) == {256, 30}
111-
assert Math.wasm_string(wasm_source, "main", 0, 0) == "Know the length of this string"
110+
assert Wasm.wasm_example(wasm_source, "main", 0, 0) == {256, 30}
111+
assert Wasm.wasm_string(wasm_source, "main", 0, 0) == "Know the length of this string"
112112
end
113113

114114
# defwasm multiply(a, b) do

0 commit comments

Comments
 (0)