diff options
author | Blaine Bublitz <blaine.bublitz@gmail.com> | 2022-06-24 16:32:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 16:32:44 -0700 |
commit | 5811c2c7d50c10327565a23e19bf39c105593710 (patch) | |
tree | b07af8e460790171ab6be501c8da79f70c46693e /test/binaryen.js | |
parent | efea05006b4179db159d8850c33a4b54cf04d317 (diff) | |
download | binaryen-5811c2c7d50c10327565a23e19bf39c105593710.tar.gz binaryen-5811c2c7d50c10327565a23e19bf39c105593710.tar.bz2 binaryen-5811c2c7d50c10327565a23e19bf39c105593710.zip |
[JS API] Avoid trying to read the offset if segment is passive (#4750)
This avoids hitting an assertion.
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 11 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index d72ffcec0..ecfc73bff 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -1091,9 +1091,9 @@ function test_for_each() { assert(module.getExportByIndex(i) === exps[i]); } - var expected_offsets = [10, 125]; - var expected_data = ["hello, world", "segment data 2"]; - var expected_passive = [false, false]; + var expected_offsets = [10, 125, null]; + var expected_data = ["hello, world", "segment data 2", "hello, passive"]; + var expected_passive = [false, false, true]; var glos = [ module.addGlobal("a-global", binaryen.i32, false, module.i32.const(expected_offsets[1])), @@ -1115,6 +1115,11 @@ function test_for_each() { passive: expected_passive[1], offset: module.global.get("a-global"), data: expected_data[1].split('').map(function(x) { return x.charCodeAt(0) }) + }, + { + passive: expected_passive[2], + offset: expected_offsets[2], + data: expected_data[2].split('').map(function(x) { return x.charCodeAt(0) }) } ], false); for (i = 0; i < module.getNumMemorySegments(); i++) { diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 70be70e61..b45894c7a 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -4860,6 +4860,7 @@ sizeof Literal: 24 (memory $0 1 256) (data (i32.const 10) "hello, world") (data (global.get $a-global) "segment data 2") + (data "hello, passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) $fn0 $fn1 $fn2) (export "export0" (func $fn0)) |