v4 / vlib / v / gen / wasm / features_test.v
32 lines · 28 sloc · 1.18 KB · f05b0450b1493d16b6518e7cee11b1b09b39beb4
Raw
1module wasm
2
3fn test_relaxed_simd_implies_simd() {
4 // requesting relaxed SIMD on its own must also pull in the base SIMD feature
5 feats := apply_feature_implications([WasmFeature.relaxed_simd])
6 assert WasmFeature.simd in feats
7 assert WasmFeature.relaxed_simd in feats
8}
9
10fn test_relaxed_simd_does_not_duplicate_simd() {
11 // when SIMD is already present, the implication must not add a duplicate
12 feats := apply_feature_implications([WasmFeature.simd, .relaxed_simd])
13 assert feats.filter(it == WasmFeature.simd).len == 1
14}
15
16fn test_simd_without_relaxed_is_unchanged() {
17 feats := apply_feature_implications([WasmFeature.simd])
18 assert WasmFeature.simd in feats
19 assert WasmFeature.relaxed_simd !in feats
20}
21
22fn test_relaxed_simd_renders_simd_in_tool_flags() {
23 feats := apply_feature_implications([WasmFeature.relaxed_simd])
24 // wasm-opt must be told to enable SIMD as well as relaxed SIMD
25 binaryen := binaryen_feature_flags(feats)
26 assert binaryen.contains('--enable-simd')
27 assert binaryen.contains('--enable-relaxed-simd')
28 // wasm-validate must not disable SIMD while enabling relaxed SIMD
29 wabt := wabt_validate_args(feats)
30 assert '--disable-simd' !in wabt
31 assert '--enable-relaxed-simd' in wabt
32}
33