Fixes global numeric types to have max of signed encoding (#442)

This adjusts towards the exiting code which used int32/64 instead of
uint32/64. The reason is that the spec indicates intepretation as signed
numbers, which affects the maximum value.

See https://www.w3.org/TR/wasm-core-1/#value-types%E2%91%A2

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-04-06 06:35:31 +08:00
committed by GitHub
parent b1cffcc58e
commit f5598c9a8e
14 changed files with 153 additions and 62 deletions

View File

@@ -64,11 +64,11 @@ func TestEncodeDecodeF64(t *testing.T) {
} {
t.Run(fmt.Sprintf("%f", v), func(t *testing.T) {
encoded := EncodeF64(v)
binary := DecodeF64(encoded)
if math.IsNaN(binary) { // cannot use require.Equal as NaN by definition doesn't equal itself
require.True(t, math.IsNaN(binary))
val := DecodeF64(encoded)
if math.IsNaN(val) { // cannot use require.Equal as NaN by definition doesn't equal itself
require.True(t, math.IsNaN(val))
} else {
require.Equal(t, v, binary)
require.Equal(t, v, val)
}
})
}