summaryrefslogtreecommitdiff
path: root/test/unit/test_features.py
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-11 03:04:17 +0200
committerGitHub <noreply@github.com>2020-09-10 18:04:17 -0700
commit192757772adce7568fc1f3f3e733a4263b6392c6 (patch)
tree922fec8709cf9008d239a1fcbce7280e6ab46deb /test/unit/test_features.py
parentcd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (diff)
downloadbinaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.gz
binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.bz2
binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.zip
Add anyref feature and type (#3109)
Adds `anyref` type, which is enabled by a new feature `--enable-anyref`. This type is primarily used for testing that passes correctly handle subtype relationships so that the codebase will continue to be prepared for future subtyping. Since `--enable-anyref` is meaningless without also using `--enable-reference-types`, this PR also makes it a validation error to pass only the former (and similarly makes it a validation error to enable exception handling without enabling reference types).
Diffstat (limited to 'test/unit/test_features.py')
-rw-r--r--test/unit/test_features.py44
1 files changed, 39 insertions, 5 deletions
diff --git a/test/unit/test_features.py b/test/unit/test_features.py
index 506fd8809..2b5b00469 100644
--- a/test/unit/test_features.py
+++ b/test/unit/test_features.py
@@ -42,8 +42,17 @@ class FeatureValidationTest(utils.BinaryenTestCase):
self.check_feature(module, error, '--enable-reference-types')
def check_multivalue(self, module, error):
+ self.check_feature(module, error, '--enable-multivalue')
+
+ def check_multivalue_exception_handling(self, module, error):
self.check_feature(module, error, '--enable-multivalue',
- ['--enable-exception-handling'])
+ ['--enable-exception-handling',
+ '--enable-reference-types'])
+
+ def check_anyref(self, module, error):
+ # Anyref handling implies reference types
+ self.check_feature(module, error, '--enable-anyref',
+ ['--enable-reference-types'])
def test_v128_signature(self):
module = '''
@@ -228,8 +237,8 @@ class FeatureValidationTest(utils.BinaryenTestCase):
(event $foo (attr 0) (param i32 i64))
)
'''
- self.check_multivalue(module, 'Multivalue event type ' +
- '(multivalue is not enabled)')
+ self.check_multivalue_exception_handling(module, 'Multivalue event type ' +
+ '(multivalue is not enabled)')
def test_multivalue_block(self):
module = '''
@@ -249,6 +258,24 @@ class FeatureValidationTest(utils.BinaryenTestCase):
self.check_multivalue(module, 'Multivalue block type ' +
'(multivalue is not enabled)')
+ def test_anyref_global(self):
+ module = '''
+ (module
+ (global $foo anyref (ref.null any))
+ )
+ '''
+ self.check_anyref(module, 'all used types should be allowed')
+
+ def test_anyref_local(self):
+ module = '''
+ (module
+ (func $foo
+ (local $0 anyref)
+ )
+ )
+ '''
+ self.check_anyref(module, 'all used types should be allowed')
+
class TargetFeaturesSectionTest(utils.BinaryenTestCase):
def test_atomics(self):
@@ -303,9 +330,15 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase):
def test_exception_handling(self):
filename = 'exception_handling_target_feature.wasm'
self.roundtrip(filename)
- self.check_features(filename, ['exception-handling'])
+ self.check_features(filename, ['exception-handling', 'reference-types'])
self.assertIn('throw', self.disassemble(filename))
+ def test_anyref(self):
+ filename = 'anyref_target_feature.wasm'
+ self.roundtrip(filename)
+ self.check_features(filename, ['reference-types', 'anyref'])
+ self.assertIn('anyref', self.disassemble(filename))
+
def test_incompatible_features(self):
path = self.input_path('signext_target_feature.wasm')
p = shared.run_process(
@@ -353,5 +386,6 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase):
'--enable-exception-handling',
'--enable-tail-call',
'--enable-reference-types',
- '--enable-multivalue'
+ '--enable-multivalue',
+ '--enable-anyref'
], p2.stdout.splitlines())