Debian Codegraph @

tests/cli/component-model/start.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-values
2
3
4 (assert_invalid
5 (component
6 (import "a" (func $f (param "p1" string)))
7 (start $f)
8 )
9 "start function requires 1 arguments")
10
11 (assert_invalid
12 (component
13 (import "a" (func $f (param "p" string)))
14 (import "b" (value $v string))
15 (start $f (value $v) (value $v))
16 )
17 "start function requires 1 arguments")
18
19 (assert_invalid
20 (component
21 (import "a" (func $f (param "p1" string) (param "p2" string)))
22 (import "b" (value $v string))
23 (start $f (value $v) (value $v))
24 )
25 "cannot be used more than once")
26
27 (assert_invalid
28 (component
29 (import "a" (func $f (param "x" string) (param "y" string)))
30 (import "b" (value $v string))
31 (import "c" (value $v2 u32))
32 (start $f (value $v) (value $v2))
33 )
34 "type mismatch for component start function argument 1")
35
36 (component
37 (import "a" (func $f (param "z" string) (param "a" string)))
38 (import "b" (value $v string))
39 (import "c" (value $v2 string))
40 (start $f (value $v) (value $v2))
41 )
42
43 (component
44 (import "a" (func $f (result string)))
45 (start $f (result (value $a)))
46 (export "b" (value $a))
47 )
48
49 (assert_malformed
50 (component quote
51 "(import \"a\" (func $f)) "
52 "(start $f) "
53 "(start $f) "
54 )
55 "component cannot have more than one start function")
56
57 (assert_malformed
58 (component binary
59 "\00asm" "\0d\00\01\00" ;; component header
60
61 "\07\05" ;; type section, 5 bytes large
62 "\01" ;; 1 count
63 "\40" ;; function
64 "\00" ;; parameters, 0 count
65 "\01\00" ;; results, named, 0 count
66
67 "\0a\06" ;; import section, 6 bytes large
68 "\01" ;; 1 count
69 "\00\01a" ;; name = "a"
70 "\01\00" ;; type = func ($type 0)
71
72 "\09\06" ;; start section, 6 bytes large
73 "\00" ;; function 0
74 "\00" ;; no arguments
75 "\ff\ff\ff\00" ;; tons of results
76 )
77 "start function results size is out of bounds")
78
79 (assert_malformed
80 (component binary
81 "\00asm" "\0d\00\01\00" ;; component header
82
83 "\07\05" ;; type section, 5 bytes large
84 "\01" ;; 1 count
85 "\40" ;; function
86 "\00" ;; parameters, 0 count
87 "\01\00" ;; results, named, 0 count
88
89 "\0a\06" ;; import section, 6 bytes large
90 "\01" ;; 1 count
91 "\00\01a" ;; name = "a"
92 "\01\00" ;; type = func ($type 0)
93
94 "\09\04" ;; start section, 4 bytes large
95 "\00" ;; function 0
96 "\00" ;; no arguments
97 "\00" ;; no results
98 "\ff" ;; trailing garbage byte
99 )
100 "unexpected content in the component start section")