-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp/wazero: corrections to encode/decode params
Signed-off-by: deadprogram <[email protected]>
- Loading branch information
1 parent
27c6d9d
commit ba9b59f
Showing
4 changed files
with
125 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package wazero | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
) | ||
|
||
//go:embed tester.wasm | ||
var wasmData []byte | ||
|
||
func TestInstance(t *testing.T) { | ||
i := Interpreter{} | ||
if err := i.Init(); err != nil { | ||
t.Errorf("Interpreter.Init() failed: %v", err) | ||
} | ||
|
||
if err := i.Load(wasmData); err != nil { | ||
t.Errorf("Interpreter.Load() failed: %v", err) | ||
} | ||
|
||
inst, err := i.Run() | ||
if err != nil { | ||
t.Errorf("Interpreter.Run() failed: %v", err) | ||
} | ||
|
||
t.Run("Call int32", func(t *testing.T) { | ||
results, err := inst.Call("test_int32", int32(1), int32(2)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if results != int32(3) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
|
||
t.Run("Call uint32", func(t *testing.T) { | ||
results, err := inst.Call("test_uint32", uint32(1), uint32(2)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if uint32(results.(int32)) != uint32(3) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
|
||
t.Run("Call int64", func(t *testing.T) { | ||
results, err := inst.Call("test_int64", int64(1), int64(2)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if int64(results.(int32)) != int64(3) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
|
||
t.Run("Call uint64", func(t *testing.T) { | ||
results, err := inst.Call("test_uint64", uint64(1), uint64(2)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if uint64(results.(int32)) != uint64(3) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
|
||
t.Run("Call float32", func(t *testing.T) { | ||
results, err := inst.Call("test_float32", float32(100.2), float32(300.8)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if results != float32(401.0) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
|
||
t.Run("Call float64", func(t *testing.T) { | ||
results, err := inst.Call("test_float64", float64(111.2), float64(333.8)) | ||
if err != nil { | ||
t.Errorf("Instance.Call() failed: %v", err) | ||
} | ||
if results != float64(445.0) { | ||
t.Errorf("Instance.Call() failed: %v", results) | ||
} | ||
}) | ||
} |
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,36 @@ | ||
package wazero | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestName(t *testing.T) { | ||
i := Interpreter{} | ||
if i.Name() != "wazero" { | ||
t.Errorf("Interpreter.Name() failed: %v", i.Name()) | ||
} | ||
} | ||
|
||
func TestInit(t *testing.T) { | ||
i := Interpreter{} | ||
err := i.Init() | ||
if err != nil { | ||
t.Errorf("Interpreter.Init() failed: %v", err) | ||
} | ||
} | ||
|
||
func TestLoad(t *testing.T) { | ||
t.Skip("TODO: implement TestLoad") | ||
} | ||
|
||
func TestRun(t *testing.T) { | ||
t.Skip("TODO: implement TestRun") | ||
} | ||
|
||
func TestHalt(t *testing.T) { | ||
t.Skip("TODO: implement TestHalt") | ||
} | ||
|
||
func TestDefineFunc(t *testing.T) { | ||
t.Skip("TODO: implement TestDefineFunc") | ||
} |
Binary file not shown.