Debian Codegraph @

tests/cli/component-model/export-ascription.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 (component
4 (import "f" (func $f))
5 (export "f2" (func $f) (func))
6 )
7
8 ;; subtyping works
9 (component
10 (import "f" (instance $i (export "f" (func))))
11 (export "f2" (instance $i) (instance))
12 )
13
14 ;; make sure subtyping works in the right direction
15 (assert_invalid
16 (component
17 (import "f" (instance $i))
18 (export "f2" (instance $i) (instance (export "f" (func))))
19 )
20 "ascribed type of export is not compatible")
21
22 ;; make sure the type is actually changed
23 (assert_invalid
24 (component
25 (import "f" (func $f))
26
27 (component $c
28 (import "f" (instance $i (export "f" (func))))
29 (export "f2" (instance $i) (instance))
30 )
31
32 (instance $c (instantiate $c (with "f" (instance (export "f" (func $f))))))
33
34 (component $consume
35 (import "arg" (instance $i (export "f" (func))))
36 )
37
38 (instance (instantiate $consume (with "arg" (instance $c "f2"))))
39 )
40 "missing expected export `f`")