Skip to content

Cross-compiled C# wasm tests #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ml-proto/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class RunTests(unittest.TestCase):
def _runTestFile(self, shortName, fileName, interpreterPath):
# HACK: Windows python compatibility
fileName = fileName.replace("\\", "/")

logPath = fileName.replace("test/", "test/output/").replace(".wasm", ".wasm.log")
try:
os.remove(logPath)
Expand Down Expand Up @@ -59,6 +62,8 @@ def rebuild_interpreter(path):

if __name__ == "__main__":
interpreterPath = os.path.abspath("src/main.native")
# HACK: Windows python compatibility
interpreterPath = interpreterPath.replace("\\", "/")

try:
os.makedirs("test/output/")
Expand Down
75 changes: 75 additions & 0 deletions ml-proto/test/countUp.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
;; CountUp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

(module

(func $Program_countUp
(param $outOffset i32) (param $count i32) (local $i i32)

(block

;; for (var (@<var System.Int32 i> = 0); ...)
(setlocal $i (const.i32 0))

(label $loop_0
(loop
;; for (...; (@<var System.Int32 i> < @<parameter System.Int32 count>); ...)

(if
(lts.i32
(getlocal $i)
(getlocal $count)
)
(nop)
(break $loop_0)
)

;; for (...) {
(stores.1.i32
(mul.i32
(add.i32
(getlocal $outOffset)
(getlocal $i)
)
(const.i32 4)
)
(getlocal $i)
)

;; for (...; ...; <!>)
(setlocal $i (add.i32
(getlocal $i)
(const.i32 1)
))
)
)
)
)

(func $Program_readI32
(param $base i32) (param $offset i32)
(result i32)

(return (loads.1.i32 (mul.i32
(add.i32
(getlocal $base)
(getlocal $offset)
)
(const.i32 4)
) ))
)

(export "countUp" $Program_countUp)
(export "readI32" $Program_readI32)

(memory 4096 4096)

)


(invoke "countUp" (const.i32 0) (const.i32 32) )
(invoke "countUp" (const.i32 16) (const.i32 4) )
(asserteq (invoke "readI32" (const.i32 0) (const.i32 0) ) (const.i32 0) )
(asserteq (invoke "readI32" (const.i32 0) (const.i32 2) ) (const.i32 2) )
(asserteq (invoke "readI32" (const.i32 0) (const.i32 31) ) (const.i32 31) )
(asserteq (invoke "readI32" (const.i32 16) (const.i32 0) ) (const.i32 0) )
(asserteq (invoke "readI32" (const.i32 16) (const.i32 3) ) (const.i32 3) )
Loading