-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the module linking proposal (#47)
This updates the Python extension with the API support added in bytecodealliance/wasmtime#2472. Most of the changes here were pretty straightforward!
- Loading branch information
1 parent
784122b
commit a7192c7
Showing
13 changed files
with
533 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import unittest | ||
|
||
from wasmtime import * | ||
|
||
|
||
class TestModuleLinking(unittest.TestCase): | ||
def store(self): | ||
config = Config() | ||
config.wasm_module_linking = True | ||
return Store(Engine(config)) | ||
|
||
def test_import_string_optional(self): | ||
store = self.store() | ||
module = Module(store.engine, """ | ||
(module | ||
(import "" (func)) | ||
) | ||
""") | ||
assert(module.type.imports[0].module == '') | ||
assert(module.type.imports[0].name is None) | ||
|
||
def test_module_import(self): | ||
store = self.store() | ||
module1 = Module(store.engine, """ | ||
(module (import "" (module))) | ||
""") | ||
module2 = Module(store.engine, "(module)") | ||
Instance(store, module1, [module2]) | ||
|
||
def test_module_export(self): | ||
store = self.store() | ||
module = Module(store.engine, """ | ||
(module (module (export ""))) | ||
""") | ||
i = Instance(store, module, []) | ||
assert(isinstance(i.exports[0], Module)) | ||
|
||
def test_instance_import(self): | ||
store = self.store() | ||
module = Module(store.engine, """ | ||
(module (import "" (instance))) | ||
""") | ||
instance = Instance(store, Module(store.engine, "(module)"), []) | ||
Instance(store, module, [instance]) | ||
|
||
def test_instance_export(self): | ||
store = self.store() | ||
instance = Module(store.engine, """ | ||
(module | ||
(module $m) | ||
(instance (export "") (instantiate $m)) | ||
) | ||
""") | ||
i = Instance(store, instance, []) | ||
assert(isinstance(i.exports[0], Instance)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.