diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-07-03 14:35:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 14:35:42 -0700 |
commit | a5547a56649771a708de8d5b013dbbf62d0fcbae (patch) | |
tree | 776557d4af0f06ac2080d51a6e26e48ffb4fd06b /test/unit/test_features.py | |
parent | 23d8497ce605b41652e97aea06150c9d59b93796 (diff) | |
download | binaryen-a5547a56649771a708de8d5b013dbbf62d0fcbae.tar.gz binaryen-a5547a56649771a708de8d5b013dbbf62d0fcbae.tar.bz2 binaryen-a5547a56649771a708de8d5b013dbbf62d0fcbae.zip |
Clean up loose ends in feature handling (#2203)
Fix and test mutable globals support, replace string literals with
constants, and add a pass to emit the target features section.
Diffstat (limited to 'test/unit/test_features.py')
-rw-r--r-- | test/unit/test_features.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 6156191a2..afb873d30 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -137,6 +137,13 @@ class TargetFeaturesSectionTest(BinaryenTestCase): self.check_features(filename, ['nontrapping-float-to-int']) self.assertIn('i32.trunc_sat_f32_u', self.disassemble(filename)) + def test_mutable_globals(self): + filename = 'mutable_globals_target_feature.wasm' + self.roundtrip(filename) + self.check_features(filename, ['mutable-globals']) + self.assertIn('(import "env" "global-mut" (global $gimport$0 (mut i32)))', + self.disassemble(filename)) + def test_sign_ext(self): filename = 'signext_target_feature.wasm' self.roundtrip(filename) @@ -173,3 +180,20 @@ class TargetFeaturesSectionTest(BinaryenTestCase): def test_explicit_detect_features(self): self.check_features('signext_target_feature.wasm', ['sign-ext', 'simd'], opts=['-mvp', '--detect-features', '--enable-simd']) + + def test_emit_all_features(self): + p = run_process(WASM_OPT + ['--emit-target-features', '-all', '-o', '-'], + input="(module)", check=False, capture_output=True) + self.assertEqual(p.returncode, 0) + 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(), [ + '--enable-threads', + '--enable-bulk-memory', + '--enable-exception-handling', + '--enable-mutable-globals', + '--enable-nontrapping-float-to-int', + '--enable-sign-ext', + '--enable-simd', + ]) |