Skip to content

Commit fe35511

Browse files
authored
Move more LEB128 tests to binary-leb128 (#1651)
Tests for LEB128 should be in the separate `binary-leb128.wast` test file.
1 parent 86b6a18 commit fe35511

File tree

2 files changed

+78
-79
lines changed

2 files changed

+78
-79
lines changed

test/core/binary-leb128.wast

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,6 @@
966966
"integer too large"
967967
)
968968

969-
970969
(module binary
971970
"\00asm" "\01\00\00\00"
972971
"\01\04\01" ;; type section
@@ -1003,3 +1002,81 @@
10031002
)
10041003
"integer representation too long"
10051004
)
1005+
1006+
;; Data segment tags and memory index can have non-minimal length
1007+
(module binary
1008+
"\00asm" "\01\00\00\00"
1009+
"\05\03\01" ;; Memory section with 1 entry
1010+
"\00\00" ;; no max, minimum 0
1011+
"\0b\07\01" ;; Data section with 1 entry
1012+
"\80\00" ;; Active segment, encoded with 2 bytes
1013+
"\41\00\0b\00" ;; (i32.const 0) with contents ""
1014+
)
1015+
(module binary
1016+
"\00asm" "\01\00\00\00"
1017+
"\05\03\01" ;; Memory section with 1 entry
1018+
"\00\00" ;; no max, minimum 0
1019+
"\0b\08\01" ;; Data section with 1 entry
1020+
"\82\00" ;; Active segment, encoded with 2 bytes
1021+
"\00" ;; explicit memory index
1022+
"\41\00\0b\00" ;; (i32.const 0) with contents ""
1023+
)
1024+
(module binary
1025+
"\00asm" "\01\00\00\00"
1026+
"\05\03\01" ;; Memory section with 1 entry
1027+
"\00\00" ;; no max, minimum 0
1028+
"\0b\09\01" ;; Data section with 1 entry
1029+
"\82\00" ;; Active segment, encoded with 2 bytes
1030+
"\80\00" ;; explicit memory index, encoded with 2 bytes
1031+
"\41\00\0b\00" ;; (i32.const 0) with contents ""
1032+
)
1033+
1034+
;; Element segment tags and table index can have non-minimal length
1035+
(module binary
1036+
"\00asm" "\01\00\00\00"
1037+
"\04\04\01" ;; Table section with 1 entry
1038+
"\70\00\00" ;; no max, minimum 0, funcref
1039+
"\09\07\01" ;; Element section with 1 entry
1040+
"\80\00" ;; Active segment
1041+
"\41\00\0b\00" ;; (i32.const 0) with no elements
1042+
)
1043+
(module binary
1044+
"\00asm" "\01\00\00\00"
1045+
"\04\04\01" ;; Table section with 1 entry
1046+
"\70\00\00" ;; no max, minimum 0, funcref
1047+
"\09\09\01" ;; Element section with 1 entry
1048+
"\02" ;; Active segment
1049+
"\80\00" ;; explicit table index, encoded with 2 bytes
1050+
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
1051+
)
1052+
(module binary
1053+
"\00asm" "\01\00\00\00"
1054+
"\04\04\01" ;; Table section with 1 entry
1055+
"\70\00\00" ;; no max, minimum 0, funcref
1056+
"\09\09\01" ;; Element section with 1 entry
1057+
"\82\00" ;; Active segment, encoded with 2 bytes
1058+
"\00" ;; explicit table index
1059+
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
1060+
)
1061+
(module binary
1062+
"\00asm" "\01\00\00\00"
1063+
"\04\04\01" ;; Table section with 1 entry
1064+
"\70\00\00" ;; no max, minimum 0, funcref
1065+
"\09\0a\01" ;; Element section with 1 entry
1066+
"\82\00" ;; Active segment, encoded with 2 bytes
1067+
"\80\00" ;; explicit table index, encoded with 2 bytes
1068+
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
1069+
)
1070+
1071+
;; Type section with signed LEB128 encoded type
1072+
(assert_malformed
1073+
(module binary
1074+
"\00asm" "\01\00\00\00"
1075+
"\01" ;; Type section id
1076+
"\05" ;; Type section length
1077+
"\01" ;; Types vector length
1078+
"\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding
1079+
"\00\00"
1080+
)
1081+
"integer representation too long"
1082+
)

test/core/binary.wast

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -51,84 +51,6 @@
5151
(assert_malformed (module binary "\00asm" "\01\00\00\00" "\81\01\00\01\01\00") "malformed section id")
5252
(assert_malformed (module binary "\00asm" "\01\00\00\00" "\ff\01\00\01\01\00") "malformed section id")
5353

54-
;; Data segment tags and memory index can have non-minimal length
55-
(module binary
56-
"\00asm" "\01\00\00\00"
57-
"\05\03\01" ;; Memory section with 1 entry
58-
"\00\00" ;; no max, minimum 0
59-
"\0b\07\01" ;; Data section with 1 entry
60-
"\80\00" ;; Active segment, encoded with 2 bytes
61-
"\41\00\0b\00" ;; (i32.const 0) with contents ""
62-
)
63-
(module binary
64-
"\00asm" "\01\00\00\00"
65-
"\05\03\01" ;; Memory section with 1 entry
66-
"\00\00" ;; no max, minimum 0
67-
"\0b\08\01" ;; Data section with 1 entry
68-
"\82\00" ;; Active segment, encoded with 2 bytes
69-
"\00" ;; explicit memory index
70-
"\41\00\0b\00" ;; (i32.const 0) with contents ""
71-
)
72-
(module binary
73-
"\00asm" "\01\00\00\00"
74-
"\05\03\01" ;; Memory section with 1 entry
75-
"\00\00" ;; no max, minimum 0
76-
"\0b\09\01" ;; Data section with 1 entry
77-
"\82\00" ;; Active segment, encoded with 2 bytes
78-
"\80\00" ;; explicit memory index, encoded with 2 bytes
79-
"\41\00\0b\00" ;; (i32.const 0) with contents ""
80-
)
81-
82-
;; Element segment tags and table index can have non-minimal length
83-
(module binary
84-
"\00asm" "\01\00\00\00"
85-
"\04\04\01" ;; Table section with 1 entry
86-
"\70\00\00" ;; no max, minimum 0, funcref
87-
"\09\07\01" ;; Element section with 1 entry
88-
"\80\00" ;; Active segment
89-
"\41\00\0b\00" ;; (i32.const 0) with no elements
90-
)
91-
(module binary
92-
"\00asm" "\01\00\00\00"
93-
"\04\04\01" ;; Table section with 1 entry
94-
"\70\00\00" ;; no max, minimum 0, funcref
95-
"\09\09\01" ;; Element section with 1 entry
96-
"\02" ;; Active segment
97-
"\80\00" ;; explicit table index, encoded with 2 bytes
98-
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
99-
)
100-
(module binary
101-
"\00asm" "\01\00\00\00"
102-
"\04\04\01" ;; Table section with 1 entry
103-
"\70\00\00" ;; no max, minimum 0, funcref
104-
"\09\09\01" ;; Element section with 1 entry
105-
"\82\00" ;; Active segment, encoded with 2 bytes
106-
"\00" ;; explicit table index
107-
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
108-
)
109-
(module binary
110-
"\00asm" "\01\00\00\00"
111-
"\04\04\01" ;; Table section with 1 entry
112-
"\70\00\00" ;; no max, minimum 0, funcref
113-
"\09\0a\01" ;; Element section with 1 entry
114-
"\82\00" ;; Active segment, encoded with 2 bytes
115-
"\80\00" ;; explicit table index, encoded with 2 bytes
116-
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
117-
)
118-
119-
;; Type section with signed LEB128 encoded type
120-
(assert_malformed
121-
(module binary
122-
"\00asm" "\01\00\00\00"
123-
"\01" ;; Type section id
124-
"\05" ;; Type section length
125-
"\01" ;; Types vector length
126-
"\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding
127-
"\00\00"
128-
)
129-
"integer representation too long"
130-
)
131-
13254
;; Function with missing end marker (between two functions)
13355
(assert_malformed
13456
(module binary

0 commit comments

Comments
 (0)