forked from bytecodealliance/wasmtime-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabletype_test.go
43 lines (39 loc) · 860 Bytes
/
tabletype_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package wasmtime
import "testing"
func TestTableType(t *testing.T) {
ty := NewTableType(NewValType(KindI32), 0, false, 0)
if ty.Element().Kind() != KindI32 {
panic("invalid kind")
}
if ty.Minimum() != 0 {
panic("invalid min")
}
present, _ := ty.Maximum()
if present {
panic("invalid max")
}
ty = NewTableType(NewValType(KindF64), 1, true, 129)
if ty.Element().Kind() != KindF64 {
panic("invalid kind")
}
if ty.Minimum() != 1 {
panic("invalid min")
}
present, max := ty.Maximum()
if !present || max != 129 {
panic("invalid max")
}
ty2 := ty.AsExternType().TableType()
if ty2 == nil {
panic("unexpected cast")
}
if ty.AsExternType().FuncType() != nil {
panic("working cast")
}
if ty.AsExternType().GlobalType() != nil {
panic("working cast")
}
if ty.AsExternType().MemoryType() != nil {
panic("working cast")
}
}