Coverage for tests/codegen/test_simple_import.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-20 16:25 +0000

1from . import bindgen 

2from wasmtime import Store 

3 

4module = """ 

5 (component 

6 (import "host" (instance $host 

7 (export "thunk" (func)) 

8 )) 

9 

10 (core module $m 

11 (import "host" "thunk" (func $thunk)) 

12 

13 (start $thunk) 

14 ) 

15 

16 (core func $thunk (canon lower (func $host "thunk"))) 

17 (core instance $i (instantiate $m 

18 (with "host" (instance (export "thunk" (func $thunk)))) 

19 )) 

20 ) 

21""" 

22bindgen('simple_import', module) 

23 

24from .generated.simple_import import Root, RootImports, imports 

25 

26 

27class Host(imports.HostHost): 

28 def thunk(self): 

29 self.hit = True 

30 

31 

32def test_bindings(): 

33 store = Store() 

34 host = Host() 

35 Root(store, RootImports(host=host)) 

36 

37 assert host.hit