@@ -253,17 +253,35 @@ func testHugeStack(t *testing.T, r wazero.Runtime) {
253
253
require .NoError (t , module .Close (testCtx ))
254
254
}()
255
255
256
- fn := module .ExportedFunction ("main" )
257
- require .NotNil (t , fn )
256
+ verifyResult := func (t * testing.T , res []uint64 ) {
257
+ const resultNumInUint64 = 180
258
+ require .Equal (t , resultNumInUint64 , len (res ))
259
+ for i := uint64 (1 ); i <= resultNumInUint64 ; i ++ {
260
+ require .Equal (t , i , res [i - 1 ])
261
+ }
262
+ }
258
263
259
- res , err := fn .Call (testCtx , 0 , 0 , 0 , 0 , 0 , 0 ) // params ignored by wasm
260
- require .NoError (t , err )
264
+ t .Run ("main" , func (t * testing.T ) {
265
+ fn := module .ExportedFunction ("main" )
266
+ require .NotNil (t , fn )
267
+ res , err := fn .Call (testCtx , 0 , 0 , 0 , 0 , 0 , 0 ) // params ignored by wasm
268
+ require .NoError (t , err )
269
+ verifyResult (t , res )
270
+ })
261
271
262
- const resultNumInUint64 = 180
263
- require .Equal (t , resultNumInUint64 , len (res ))
264
- for i := uint64 (1 ); i <= resultNumInUint64 ; i ++ {
265
- require .Equal (t , i , res [i - 1 ])
266
- }
272
+ t .Run ("memory_fill_after_main" , func (t * testing.T ) {
273
+ fn := module .ExportedFunction ("memory_fill_after_main" )
274
+ require .NotNil (t , fn )
275
+ for _ , offset := range []uint64 {0 , 2 , 4 , 8 , 16 , 32 , 48 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 , 16384 , 32768 } {
276
+ for _ , size := range []uint64 {0 , 2 , 4 , 8 , 16 , 32 , 48 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 , 16384 } {
277
+ t .Run (fmt .Sprintf ("offset=%d,size=%d" , offset , size ), func (t * testing.T ) {
278
+ res , err := fn .Call (testCtx , offset , 0xff , size )
279
+ require .NoError (t , err )
280
+ verifyResult (t , res )
281
+ })
282
+ }
283
+ }
284
+ })
267
285
}
268
286
269
287
// testOverflow ensures that adding one into the maximum integer results in the
0 commit comments