summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rwxr-xr-xtest/unit/input/tail_call_target_feature.wasmbin0 -> 129 bytes
-rw-r--r--test/unit/test_features.py25
2 files changed, 23 insertions, 2 deletions
diff --git a/test/unit/input/tail_call_target_feature.wasm b/test/unit/input/tail_call_target_feature.wasm
new file mode 100755
index 000000000..063b6d2a5
--- /dev/null
+++ b/test/unit/input/tail_call_target_feature.wasm
Binary files differ
diff --git a/test/unit/test_features.py b/test/unit/test_features.py
index afb873d30..968aaa252 100644
--- a/test/unit/test_features.py
+++ b/test/unit/test_features.py
@@ -27,6 +27,9 @@ class FeatureValidationTest(BinaryenTestCase):
def check_exception_handling(self, module, error):
self.check_feature(module, error, '--enable-exception-handling')
+ def check_tail_call(self, module, error):
+ self.check_feature(module, error, '--enable-tail-call')
+
def test_v128_signature(self):
module = '''
(module
@@ -117,6 +120,17 @@ class FeatureValidationTest(BinaryenTestCase):
'''
self.check_bulk_mem(module, 'nonzero segment flags (bulk memory is disabled)')
+ def test_tail_call(self):
+ module = '''
+ (module
+ (func $bar)
+ (func $foo
+ (return_call $bar)
+ )
+ )
+ '''
+ self.check_tail_call(module, 'return_call requires tail calls to be enabled')
+
class TargetFeaturesSectionTest(BinaryenTestCase):
def test_atomics(self):
@@ -156,6 +170,12 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
self.check_features(filename, ['simd'])
self.assertIn('i32x4.splat', self.disassemble(filename))
+ def test_tailcall(self):
+ filename = 'tail_call_target_feature.wasm'
+ self.roundtrip(filename)
+ self.check_features(filename, ['tail-call'])
+ self.assertIn('return_call', self.disassemble(filename))
+
def test_incompatible_features(self):
path = self.input_path('signext_target_feature.wasm')
p = run_process(
@@ -188,7 +208,7 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
p2 = run_process(WASM_OPT + ['--print-features', '-o', os.devnull],
input=p.stdout, check=False, capture_output=True)
self.assertEqual(p2.returncode, 0)
- self.assertEqual(p2.stdout.split(), [
+ self.assertEqual([
'--enable-threads',
'--enable-bulk-memory',
'--enable-exception-handling',
@@ -196,4 +216,5 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
'--enable-nontrapping-float-to-int',
'--enable-sign-ext',
'--enable-simd',
- ])
+ '--enable-tail-call'
+ ], p2.stdout.split())