@@ -381,25 +381,25 @@ def test_mangle_functype(params, results, expect):
381
381
if got != expect :
382
382
fail ("test_mangle_func() got:\n {}\n expected:\n {}" .format (got , expect ))
383
383
384
- test_mangle_functype ([U8 ()], [U8 ()], 'func u8 -> u8' )
385
- test_mangle_functype ([U8 ()], [], 'func u8 -> ()' )
384
+ test_mangle_functype ([( 'x' , U8 ()) ], [U8 ()], 'func(x: u8) -> u8' )
385
+ test_mangle_functype ([( 'x' , U8 ()) ], [], 'func(x: u8) -> ()' )
386
386
test_mangle_functype ([], [U8 ()], 'func() -> u8' )
387
387
test_mangle_functype ([('x' ,U8 ())], [('y' ,U8 ())], 'func(x: u8) -> (y: u8)' )
388
388
test_mangle_functype ([('a' ,Bool ()),('b' ,U8 ()),('c' ,S16 ()),('d' ,U32 ()),('e' ,S64 ())],
389
389
[('a' ,S8 ()),('b' ,U16 ()),('c' ,S32 ()),('d' ,U64 ())],
390
390
'func(a: bool, b: u8, c: s16, d: u32, e: s64) -> (a: s8, b: u16, c: s32, d: u64)' )
391
- test_mangle_functype ([List (List (String ()))], [],
392
- 'func list<list<string>> -> ()' )
393
- test_mangle_functype ([Record ([Field ('x' ,Record ([Field ('y' ,String ())])),Field ('z' ,U32 ())])], [],
394
- 'func record { x: record { y: string }, z: u32 } -> ()' )
395
- test_mangle_functype ([Tuple ([U8 ()])], [Tuple ([U8 (),U8 ()])],
396
- 'func tuple<u8> -> tuple<u8, u8>' )
397
- test_mangle_functype ([Flags (['a' ,'b' ])], [Enum (['a' ,'b' ])],
398
- 'func flags { a, b } -> enum { a, b }' )
399
- test_mangle_functype ([Variant ([Case ('a' ,None ),Case ('b' ,U8 ())])], [Union ([U8 (),List (String ())])],
400
- 'func variant { a, b(u8) } -> union { u8, list<string> }' )
401
- test_mangle_functype ([Option (Bool ())],[Option (List (U8 ()))],
402
- 'func option<bool> -> option<list<u8>>' )
391
+ test_mangle_functype ([( 'l' , List (List (String () )))], [],
392
+ 'func(l: list<list<string>>) -> ()' )
393
+ test_mangle_functype ([( 'r' , Record ([Field ('x' ,Record ([Field ('y' ,String ())])),Field ('z' ,U32 ())]) )], [],
394
+ 'func(r: record { x: record { y: string }, z: u32 }) -> ()' )
395
+ test_mangle_functype ([( 't' , Tuple ([U8 ()]) )], [Tuple ([U8 (),U8 ()])],
396
+ 'func(t: tuple<u8>) -> tuple<u8, u8>' )
397
+ test_mangle_functype ([( 'f' , Flags (['a' ,'b' ]) )], [Enum (['a' ,'b' ])],
398
+ 'func(f: flags { a, b }) -> enum { a, b }' )
399
+ test_mangle_functype ([( 'v' , Variant ([Case ('a' ,None ),Case ('b' ,U8 ())]) )], [Union ([U8 (),List (String ())])],
400
+ 'func(v: variant { a, b(u8) }) -> union { u8, list<string> }' )
401
+ test_mangle_functype ([( 'o' , Option (Bool () ))],[Option (List (U8 ()))],
402
+ 'func(o: option<bool>) -> option<list<u8>>' )
403
403
test_mangle_functype ([], [('a' ,Result (None ,None )),('b' ,Result (U8 (),None )),('c' ,Result (None ,U8 ()))],
404
404
'func() -> (a: result, b: result<u8>, c: result<_, u8>)' )
405
405
@@ -410,24 +410,24 @@ def test_cabi(ct, expect):
410
410
411
411
test_cabi (
412
412
ComponentType (
413
- [ExternDecl ('a' , FuncType ([U8 ()],[U8 ()])),
413
+ [ExternDecl ('a' , FuncType ([( 'x' , U8 () )],[U8 ()])),
414
414
ExternDecl ('b' , ValueType (String ()))],
415
- [ExternDecl ('c' , FuncType ([S8 ()],[S8 ()])),
415
+ [ExternDecl ('c' , FuncType ([( 'x' , S8 () )],[S8 ()])),
416
416
ExternDecl ('d' , ValueType (List (U8 ())))]
417
417
),
418
418
ModuleType (
419
- [CoreImportDecl ('' ,'a: func u8 -> u8' , CoreFuncType (['i32' ],['i32' ]))],
419
+ [CoreImportDecl ('' ,'a: func(x: u8) -> u8' , CoreFuncType (['i32' ],['i32' ]))],
420
420
[CoreExportDecl ('cabi_memory' , CoreMemoryType (0 , None )),
421
421
CoreExportDecl ('cabi_realloc' , CoreFuncType (['i32' ,'i32' ,'i32' ,'i32' ],['i32' ])),
422
422
CoreExportDecl ('cabi_start{cabi=0.1}: func(b: string) -> (d: list<u8>)' ,
423
423
CoreFuncType (['i32' ,'i32' ],['i32' ])),
424
- CoreExportDecl ('c: func s8 -> s8' , CoreFuncType (['i32' ],['i32' ]))]
424
+ CoreExportDecl ('c: func(x: s8) -> s8' , CoreFuncType (['i32' ],['i32' ]))]
425
425
)
426
426
)
427
427
test_cabi (
428
428
ComponentType (
429
429
[ExternDecl ('a' , InstanceType ([
430
- ExternDecl ('b' , FuncType ([U8 ()],[U8 ()])),
430
+ ExternDecl ('b' , FuncType ([( 'x' , U8 () )],[U8 ()])),
431
431
ExternDecl ('c' , ValueType (Float32 ()))
432
432
]))],
433
433
[ExternDecl ('d' , InstanceType ([
@@ -436,7 +436,7 @@ def test_cabi(ct, expect):
436
436
]))]
437
437
),
438
438
ModuleType (
439
- [CoreImportDecl ('' ,'a.b: func u8 -> u8' , CoreFuncType (['i32' ],['i32' ]))],
439
+ [CoreImportDecl ('' ,'a.b: func(x: u8) -> u8' , CoreFuncType (['i32' ],['i32' ]))],
440
440
[CoreExportDecl ('cabi_memory' , CoreMemoryType (0 , None )),
441
441
CoreExportDecl ('cabi_realloc' , CoreFuncType (['i32' ,'i32' ,'i32' ,'i32' ],['i32' ])),
442
442
CoreExportDecl ('cabi_start{cabi=0.1}: func(a.c: float32) -> (d.f: float64)' ,
@@ -452,7 +452,7 @@ def test_cabi(ct, expect):
452
452
ExternDecl ('bar' , FuncType ([('x' , U32 ()),('y' , U32 ())],[U32 ()]))
453
453
])),
454
454
ExternDecl ('v1' , ValueType (String ()))],
455
- [ExternDecl ('baz' , FuncType ([String ()], [String ()])),
455
+ [ExternDecl ('baz' , FuncType ([( 's' , String () )], [String ()])),
456
456
ExternDecl ('v2' , ValueType (List (List (String ()))))]
457
457
),
458
458
ModuleType (
@@ -462,7 +462,7 @@ def test_cabi(ct, expect):
462
462
CoreExportDecl ('cabi_realloc' , CoreFuncType (['i32' ,'i32' ,'i32' ,'i32' ],['i32' ])),
463
463
CoreExportDecl ('cabi_start{cabi=0.1}: func(v1: string) -> (v2: list<list<string>>)' ,
464
464
CoreFuncType (['i32' ,'i32' ],['i32' ])),
465
- CoreExportDecl ('baz: func string -> string' , CoreFuncType (['i32' ,'i32' ],['i32' ])),
465
+ CoreExportDecl ('baz: func(s: string) -> string' , CoreFuncType (['i32' ,'i32' ],['i32' ])),
466
466
CoreExportDecl ('cabi_post_baz' , CoreFuncType (['i32' ],[]))]
467
467
)
468
468
)
0 commit comments