@@ -390,13 +390,15 @@ def core_wasm(args):
390
390
nonlocal dtor_value
391
391
392
392
assert (len (args ) == 4 )
393
- assert (args [0 ].t == 'i32' and args [0 ].v == 0 )
394
- assert (args [1 ].t == 'i32' and args [1 ].v == 1 )
395
- assert (args [2 ].t == 'i32' and args [2 ].v == 2 )
393
+ assert (len (inst .handles .table (rt ).array ) == 4 )
394
+ assert (inst .handles .table (rt ).array [0 ] is None )
395
+ assert (args [0 ].t == 'i32' and args [0 ].v == 1 )
396
+ assert (args [1 ].t == 'i32' and args [1 ].v == 2 )
397
+ assert (args [2 ].t == 'i32' and args [2 ].v == 3 )
396
398
assert (args [3 ].t == 'i32' and args [3 ].v == 13 )
397
- assert (canon_resource_rep (inst , rt , 0 ) == 42 )
398
- assert (canon_resource_rep (inst , rt , 1 ) == 43 )
399
- assert (canon_resource_rep (inst , rt , 2 ) == 44 )
399
+ assert (canon_resource_rep (inst , rt , 1 ) == 42 )
400
+ assert (canon_resource_rep (inst , rt , 2 ) == 43 )
401
+ assert (canon_resource_rep (inst , rt , 3 ) == 44 )
400
402
401
403
host_ft = FuncType ([
402
404
Borrow (rt ),
@@ -405,35 +407,35 @@ def core_wasm(args):
405
407
Own (rt )
406
408
])
407
409
args = [
408
- Value ('i32' ,0 ),
409
- Value ('i32' ,2 )
410
+ Value ('i32' ,1 ),
411
+ Value ('i32' ,3 )
410
412
]
411
413
results = canon_lower (opts , inst , host_import , True , host_ft , args )
412
414
assert (len (results ) == 1 )
413
- assert (results [0 ].t == 'i32' and results [0 ].v == 3 )
414
- assert (canon_resource_rep (inst , rt , 3 ) == 45 )
415
+ assert (results [0 ].t == 'i32' and results [0 ].v == 4 )
416
+ assert (canon_resource_rep (inst , rt , 4 ) == 45 )
415
417
416
418
dtor_value = None
417
- canon_resource_drop (inst , rt , 0 )
419
+ canon_resource_drop (inst , rt , 1 )
418
420
assert (dtor_value == 42 )
419
- assert (len (inst .handles .table (rt ).array ) == 4 )
420
- assert (inst .handles .table (rt ).array [0 ] is None )
421
+ assert (len (inst .handles .table (rt ).array ) == 5 )
422
+ assert (inst .handles .table (rt ).array [1 ] is None )
421
423
assert (len (inst .handles .table (rt ).free ) == 1 )
422
424
423
425
h = canon_resource_new (inst , rt , 46 )
424
- assert (h == 0 )
425
- assert (len (inst .handles .table (rt ).array ) == 4 )
426
- assert (inst .handles .table (rt ).array [0 ] is not None )
426
+ assert (h == 1 )
427
+ assert (len (inst .handles .table (rt ).array ) == 5 )
428
+ assert (inst .handles .table (rt ).array [1 ] is not None )
427
429
assert (len (inst .handles .table (rt ).free ) == 0 )
428
430
429
431
dtor_value = None
430
- canon_resource_drop (inst , rt , 2 )
432
+ canon_resource_drop (inst , rt , 3 )
431
433
assert (dtor_value is None )
432
- assert (len (inst .handles .table (rt ).array ) == 4 )
433
- assert (inst .handles .table (rt ).array [2 ] is None )
434
+ assert (len (inst .handles .table (rt ).array ) == 5 )
435
+ assert (inst .handles .table (rt ).array [3 ] is None )
434
436
assert (len (inst .handles .table (rt ).free ) == 1 )
435
437
436
- return [Value ('i32' , 0 ), Value ('i32' , 1 ), Value ('i32' , 3 )]
438
+ return [Value ('i32' , 1 ), Value ('i32' , 2 ), Value ('i32' , 4 )]
437
439
438
440
ft = FuncType ([
439
441
Own (rt ),
@@ -457,8 +459,8 @@ def core_wasm(args):
457
459
assert (got [0 ] == 46 )
458
460
assert (got [1 ] == 43 )
459
461
assert (got [2 ] == 45 )
460
- assert (len (inst .handles .table (rt ).array ) == 4 )
461
- assert (all (inst .handles .table (rt ).array [i ] is None for i in range (3 )))
462
+ assert (len (inst .handles .table (rt ).array ) == 5 )
463
+ assert (all (inst .handles .table (rt ).array [i ] is None for i in range (4 )))
462
464
assert (len (inst .handles .table (rt ).free ) == 4 )
463
465
definitions .MAX_FLAT_RESULTS = before
464
466
0 commit comments