Skip to content

Commit 7e56d35

Browse files
committed
More test updates
1 parent 9e527ef commit 7e56d35

13 files changed

+69
-1
lines changed

‎src/wasm/wasm-validator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,6 +3963,12 @@ static void validateExports(Module& module, ValidationInfo& info) {
39633963
exp->name,
39643964
"Exported type requires type-imports "
39653965
"[--enable-type-imports]");
3966+
auto feats = exp->heaptype.getFeatures();
3967+
if (!info.shouldBeTrue(feats <= module.features,
3968+
exp->name,
3969+
"Export type requires additional features")) {
3970+
info.getStream(nullptr) << getMissingFeaturesList(module, feats) << '\n';
3971+
}
39663972
Name exportName = exp->name;
39673973
info.shouldBeFalse(exportNames.count(exportName) > 0,
39683974
exportName,

‎test/binaryen.js/kitchen-sink.js.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Features.RelaxedSIMD: 4096
3333
Features.ExtendedConst: 8192
3434
Features.Strings: 16384
3535
Features.MultiMemory: 32768
36-
Features.All: 2097151
36+
Features.All: 4194303
3737
InvalidId: 0
3838
BlockId: 1
3939
IfId: 2

‎test/lit/help/wasm-as.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
;; CHECK-NEXT:
129129
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
130130
;; CHECK-NEXT:
131+
;; CHECK-NEXT: --enable-type-imports Enable type imports
132+
;; CHECK-NEXT:
133+
;; CHECK-NEXT: --disable-type-imports Disable type imports
134+
;; CHECK-NEXT:
131135
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
132136
;; CHECK-NEXT:
133137
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-ctor-eval.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@
135135
;; CHECK-NEXT:
136136
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
137137
;; CHECK-NEXT:
138+
;; CHECK-NEXT: --enable-type-imports Enable type imports
139+
;; CHECK-NEXT:
140+
;; CHECK-NEXT: --disable-type-imports Disable type imports
141+
;; CHECK-NEXT:
138142
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
139143
;; CHECK-NEXT:
140144
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-dis.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
;; CHECK-NEXT:
122122
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
123123
;; CHECK-NEXT:
124+
;; CHECK-NEXT: --enable-type-imports Enable type imports
125+
;; CHECK-NEXT:
126+
;; CHECK-NEXT: --disable-type-imports Disable type imports
127+
;; CHECK-NEXT:
124128
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
125129
;; CHECK-NEXT:
126130
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-emscripten-finalize.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@
163163
;; CHECK-NEXT:
164164
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
165165
;; CHECK-NEXT:
166+
;; CHECK-NEXT: --enable-type-imports Enable type imports
167+
;; CHECK-NEXT:
168+
;; CHECK-NEXT: --disable-type-imports Disable type imports
169+
;; CHECK-NEXT:
166170
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
167171
;; CHECK-NEXT:
168172
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-merge.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@
153153
;; CHECK-NEXT:
154154
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
155155
;; CHECK-NEXT:
156+
;; CHECK-NEXT: --enable-type-imports Enable type imports
157+
;; CHECK-NEXT:
158+
;; CHECK-NEXT: --disable-type-imports Disable type imports
159+
;; CHECK-NEXT:
156160
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
157161
;; CHECK-NEXT:
158162
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-metadce.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@
777777
;; CHECK-NEXT:
778778
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
779779
;; CHECK-NEXT:
780+
;; CHECK-NEXT: --enable-type-imports Enable type imports
781+
;; CHECK-NEXT:
782+
;; CHECK-NEXT: --disable-type-imports Disable type imports
783+
;; CHECK-NEXT:
780784
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
781785
;; CHECK-NEXT:
782786
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-opt.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,10 @@
789789
;; CHECK-NEXT:
790790
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
791791
;; CHECK-NEXT:
792+
;; CHECK-NEXT: --enable-type-imports Enable type imports
793+
;; CHECK-NEXT:
794+
;; CHECK-NEXT: --disable-type-imports Disable type imports
795+
;; CHECK-NEXT:
792796
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
793797
;; CHECK-NEXT:
794798
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-reduce.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
;; CHECK-NEXT:
161161
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
162162
;; CHECK-NEXT:
163+
;; CHECK-NEXT: --enable-type-imports Enable type imports
164+
;; CHECK-NEXT:
165+
;; CHECK-NEXT: --disable-type-imports Disable type imports
166+
;; CHECK-NEXT:
163167
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
164168
;; CHECK-NEXT:
165169
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm-split.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@
260260
;; CHECK-NEXT:
261261
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
262262
;; CHECK-NEXT:
263+
;; CHECK-NEXT: --enable-type-imports Enable type imports
264+
;; CHECK-NEXT:
265+
;; CHECK-NEXT: --disable-type-imports Disable type imports
266+
;; CHECK-NEXT:
263267
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
264268
;; CHECK-NEXT:
265269
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/lit/help/wasm2js.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,10 @@
740740
;; CHECK-NEXT:
741741
;; CHECK-NEXT: --disable-fp16 Disable float 16 operations
742742
;; CHECK-NEXT:
743+
;; CHECK-NEXT: --enable-type-imports Enable type imports
744+
;; CHECK-NEXT:
745+
;; CHECK-NEXT: --disable-type-imports Disable type imports
746+
;; CHECK-NEXT:
743747
;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
744748
;; CHECK-NEXT:
745749
;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag

‎test/unit/test_features.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def check_stack_switching(self, module, error):
6060
self.check_feature(module, error, '--enable-stack-switching',
6161
['--enable-gc', '--enable-reference-types', '--enable-exception-handling'])
6262

63+
def check_type_imports(self, module, error):
64+
self.check_feature(module, error, '--enable-type-imports',
65+
['--enable-reference-types'])
66+
6367
def test_v128_signature(self):
6468
module = '''
6569
(module
@@ -329,6 +333,23 @@ def check_nop(flag):
329333
check_nop('--enable-call-indirect-overlong')
330334
check_nop('--disable-call-indirect-overlong')
331335

336+
def test_type_imports_export(self):
337+
module = '''
338+
(module
339+
(export "foo" (type extern))
340+
)
341+
'''
342+
self.check_type_imports(module, 'Exported type requires type-imports')
343+
344+
def test_type_imports_import(self):
345+
module = '''
346+
(module
347+
(import "env" "foo" (type $foo (sub extern)))
348+
(func $f (param (ref $foo)))
349+
)
350+
'''
351+
self.check_type_imports(module, 'all used types should be allowed')
352+
332353

333354
class TargetFeaturesSectionTest(utils.BinaryenTestCase):
334355
def test_atomics(self):
@@ -451,4 +472,5 @@ def test_emit_all_features(self):
451472
'--enable-shared-everything',
452473
'--enable-fp16',
453474
'--enable-bulk-memory-opt',
475+
'--enable-type-imports',
454476
], p2.stdout.splitlines())

0 commit comments

Comments
 (0)