Skip to content

Commit

Permalink
Test that loop local can be read
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalIcing committed Dec 15, 2023
1 parent bf343ab commit b21077e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/loop_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule LoopTest do
use ExUnit.Case, async: true

import Orb, only: [to_wat: 1]
alias OrbWasmtime.Wasm

test "loop through chars manually" do
defmodule FileNameSafe do
Expand Down Expand Up @@ -61,8 +62,7 @@ defmodule LoopTest do
)
"""

assert wasm_source == to_wat(FileNameSafe)
# assert Wasm.call(FileNameSafe, "body") == 100
assert wasm_source = to_wat(FileNameSafe)

Check warning on line 65 in test/loop_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (26.0.2, 1.15.2)

variable "wasm_source" is unused (there is a variable with the same name in the context, use the pin operator (^) to match on it or prefix this variable with underscore if it is not meant to be used)

Check warning on line 65 in test/loop_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (25.3.2, 1.15.2)

variable "wasm_source" is unused (there is a variable with the same name in the context, use the pin operator (^) to match on it or prefix this variable with underscore if it is not meant to be used)
end

test "loop 1..10" do
Expand All @@ -71,7 +71,7 @@ defmodule LoopTest do

defw sum1to10(), I32, sum: I32 do
loop i <- 1..10 do
sum = sum
sum = sum + i
end

sum
Expand All @@ -86,7 +86,7 @@ defmodule LoopTest do
(i32.const 1)
(local.set $i)
(loop $i
(local.get $sum)
(i32.add (local.get $sum) (local.get $i))
(local.set $sum)
(i32.add (local.get $i) (i32.const 1))
(local.set $i)
Expand All @@ -98,7 +98,7 @@ defmodule LoopTest do
)
"""

assert wasm_source == to_wat(Loop1To10)
# assert Wasm.call(FileNameSafe, "body") == 100
assert wasm_source = to_wat(Loop1To10)

Check warning on line 101 in test/loop_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (26.0.2, 1.15.2)

variable "wasm_source" is unused (there is a variable with the same name in the context, use the pin operator (^) to match on it or prefix this variable with underscore if it is not meant to be used)

Check warning on line 101 in test/loop_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (25.3.2, 1.15.2)

variable "wasm_source" is unused (there is a variable with the same name in the context, use the pin operator (^) to match on it or prefix this variable with underscore if it is not meant to be used)
assert 55 = Wasm.call(Loop1To10, :sum1to10)
end
end

0 comments on commit b21077e

Please sign in to comment.