Use correct pattern for table tests everywhere (#582)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDecodeConstantExpression(t *testing.T) {
|
||||
for i, tc := range []struct {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
exp *wasm.ConstantExpression
|
||||
}{
|
||||
@@ -78,8 +78,10 @@ func TestDecodeConstantExpression(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
actual, err := decodeConstantExpression(bytes.NewReader(tc.in),
|
||||
wasm.FeatureBulkMemoryOperations|wasm.FeatureSIMD)
|
||||
@@ -90,7 +92,7 @@ func TestDecodeConstantExpression(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecodeConstantExpression_errors(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
expectedErr string
|
||||
features wasm.Features
|
||||
@@ -174,7 +176,10 @@ func TestDecodeConstantExpression_errors(t *testing.T) {
|
||||
expectedErr: "read vector const instruction immediates: needs 16 bytes but was 8 bytes",
|
||||
features: wasm.FeatureSIMD,
|
||||
},
|
||||
} {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(tc.expectedErr, func(t *testing.T) {
|
||||
_, err := decodeConstantExpression(bytes.NewReader(tc.in), tc.features)
|
||||
require.EqualError(t, err, tc.expectedErr)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_decodeDataSegment(t *testing.T) {
|
||||
for i, tc := range []struct {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
exp *wasm.DataSegment
|
||||
features wasm.Features
|
||||
@@ -112,8 +112,10 @@ func Test_decodeDataSegment(t *testing.T) {
|
||||
features: wasm.FeatureMutableGlobal,
|
||||
expErr: "non-zero prefix for data segment is invalid as feature \"bulk-memory-operations\" is disabled",
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
actual, err := decodeDataSegment(bytes.NewReader(tc.in), tc.features)
|
||||
if tc.expErr == "" {
|
||||
|
||||
@@ -19,7 +19,7 @@ func Test_ensureElementKindFuncRef(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_decodeElementInitValueVector(t *testing.T) {
|
||||
for i, tc := range []struct {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
exp []*wasm.Index
|
||||
}{
|
||||
@@ -31,7 +31,10 @@ func Test_decodeElementInitValueVector(t *testing.T) {
|
||||
in: []byte{5, 1, 2, 3, 4, 5},
|
||||
exp: []*wasm.Index{uint32Ptr(1), uint32Ptr(2), uint32Ptr(3), uint32Ptr(4), uint32Ptr(5)},
|
||||
},
|
||||
} {
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
actual, err := decodeElementInitValueVector(bytes.NewReader(tc.in))
|
||||
require.NoError(t, err)
|
||||
@@ -41,7 +44,7 @@ func Test_decodeElementInitValueVector(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_decodeElementConstExprVector(t *testing.T) {
|
||||
for i, tc := range []struct {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
exp []*wasm.Index
|
||||
features wasm.Features
|
||||
@@ -72,7 +75,10 @@ func Test_decodeElementConstExprVector(t *testing.T) {
|
||||
exp: []*wasm.Index{nil, uint32Ptr(165675008), nil},
|
||||
features: wasm.FeatureBulkMemoryOperations,
|
||||
},
|
||||
} {
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
actual, err := decodeElementConstExprVector(bytes.NewReader(tc.in), tc.features)
|
||||
require.NoError(t, err)
|
||||
@@ -82,7 +88,7 @@ func Test_decodeElementConstExprVector(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecodeElementSegment(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
tests := []struct {
|
||||
name string
|
||||
in []byte
|
||||
exp *wasm.ElementSegment
|
||||
@@ -357,8 +363,10 @@ func TestDecodeElementSegment(t *testing.T) {
|
||||
},
|
||||
features: wasm.FeatureBulkMemoryOperations,
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tc := tt
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
actual, err := decodeElementSegment(bytes.NewReader(tc.in), tc.features)
|
||||
if tc.expErr != "" {
|
||||
|
||||
Reference in New Issue
Block a user