Skip to content

Commit

Permalink
Spec test updates (#91)
Browse files Browse the repository at this point in the history
* Update JS API tests for memory64 and table64

* Add memory and table matching tests

* Improve loop in assert_Table

* Update spec tests to "address"

* Rename params in table assertion func
  • Loading branch information
bvisness authored Oct 22, 2024
1 parent 9e107e0 commit ade7380
Show file tree
Hide file tree
Showing 8 changed files with 648 additions and 38 deletions.
236 changes: 233 additions & 3 deletions test/core/imports.wast
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
(global (export "global-mut-i64") (mut i64) (i64.const 66))
(table (export "table-10-inf") 10 funcref)
(table (export "table-10-20") 10 20 funcref)
(table (export "table64-10-inf") i64 10 funcref)
(table (export "table64-10-20") i64 10 20 funcref)
(memory (export "memory-2-inf") 2)
;; Multiple memories are not yet supported
;; (memory (export "memory-2-4") 2 4)
(memory (export "memory-2-4") 2 4)
(memory (export "memory64-2-inf") i64 2)
(memory (export "memory64-2-4") i64 2 4)
(tag (export "tag"))
(tag $tag-i32 (param i32))
(export "tag-i32" (tag $tag-i32))
Expand Down Expand Up @@ -376,6 +379,7 @@
(module
(type (func (result i32)))
(import "spectest" "table" (table $tab 10 20 funcref))
(import "test" "table64-10-inf" (table $tab64 i64 10 funcref))
(elem (table $tab) (i32.const 1) func $f $g)

(func (export "call") (param i32) (result i32)
Expand All @@ -395,6 +399,7 @@
(module
(type (func (result i32)))
(table $tab (import "spectest" "table") 10 20 funcref)
(table $tab64 (import "test" "table64-10-inf") i64 10 funcref)
(elem (table $tab) (i32.const 1) func $f $g)

(func (export "call") (param i32) (result i32)
Expand All @@ -413,8 +418,12 @@
(module
(import "spectest" "table" (table 0 funcref))
(import "spectest" "table" (table 0 funcref))
(import "test" "table64-10-inf" (table i64 10 funcref))
(import "test" "table64-10-inf" (table i64 10 funcref))
(table 10 funcref)
(table 10 funcref)
(table i64 10 funcref)
(table i64 10 funcref)
)

(module (import "test" "table-10-inf" (table 10 funcref)))
Expand All @@ -429,6 +438,18 @@
(module (import "test" "table-10-20" (table 10 25 funcref)))
(module (import "test" "table-10-20" (table 5 25 funcref)))
(module (import "test" "table-10-20" (table 0 25 funcref)))
(module (import "test" "table64-10-inf" (table i64 10 funcref)))
(module (import "test" "table64-10-inf" (table i64 5 funcref)))
(module (import "test" "table64-10-inf" (table i64 0 funcref)))
(module (import "test" "table64-10-20" (table i64 10 funcref)))
(module (import "test" "table64-10-20" (table i64 5 funcref)))
(module (import "test" "table64-10-20" (table i64 0 funcref)))
(module (import "test" "table64-10-20" (table i64 10 20 funcref)))
(module (import "test" "table64-10-20" (table i64 5 20 funcref)))
(module (import "test" "table64-10-20" (table i64 0 20 funcref)))
(module (import "test" "table64-10-20" (table i64 10 25 funcref)))
(module (import "test" "table64-10-20" (table i64 5 25 funcref)))
(module (import "test" "table64-10-20" (table i64 0 25 funcref)))
(module (import "spectest" "table" (table 10 funcref)))
(module (import "spectest" "table" (table 5 funcref)))
(module (import "spectest" "table" (table 0 funcref)))
Expand All @@ -455,6 +476,14 @@
(module (import "test" "table-10-inf" (table 10 20 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-inf" (table i64 12 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-inf" (table i64 10 20 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table-10-20" (table 12 20 funcref)))
"incompatible import type"
Expand All @@ -463,6 +492,14 @@
(module (import "test" "table-10-20" (table 10 18 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-20" (table i64 12 20 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-20" (table i64 10 18 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "spectest" "table" (table 12 funcref)))
"incompatible import type"
Expand All @@ -489,12 +526,30 @@
"incompatible import type"
)

(assert_unlinkable
(module (import "test" "table-10-inf" (table i64 10 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-inf" (table 10 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table-10-20" (table i64 10 20 funcref)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "table64-10-20" (table 10 20 funcref)))
"incompatible import type"
)


;; Memories

(module
(import "spectest" "memory" (memory 1 2))
(import "test" "memory-2-inf" (memory 2))
(import "test" "memory64-2-inf" (memory i64 2))
(data (memory 0) (i32.const 10) "\10")

(func (export "load") (param i32) (result i32) (i32.load (local.get 0)))
Expand All @@ -507,6 +562,8 @@

(module
(memory (import "spectest" "memory") 1 2)
(memory (import "test" "memory-2-inf") 2)
(memory (import "test" "memory64-2-inf") i64 2)
(data (memory 0) (i32.const 10) "\10")

(func (export "load") (param i32) (result i32) (i32.load (local.get 0)))
Expand All @@ -519,6 +576,26 @@
(module (import "test" "memory-2-inf" (memory 2)))
(module (import "test" "memory-2-inf" (memory 1)))
(module (import "test" "memory-2-inf" (memory 0)))
(module (import "test" "memory-2-4" (memory 2)))
(module (import "test" "memory-2-4" (memory 1)))
(module (import "test" "memory-2-4" (memory 0)))
(module (import "test" "memory-2-4" (memory 2 4)))
(module (import "test" "memory-2-4" (memory 1 4)))
(module (import "test" "memory-2-4" (memory 0 4)))
(module (import "test" "memory-2-4" (memory 2 5)))
(module (import "test" "memory-2-4" (memory 2 6)))
(module (import "test" "memory64-2-inf" (memory i64 2)))
(module (import "test" "memory64-2-inf" (memory i64 1)))
(module (import "test" "memory64-2-inf" (memory i64 0)))
(module (import "test" "memory64-2-4" (memory i64 2)))
(module (import "test" "memory64-2-4" (memory i64 1)))
(module (import "test" "memory64-2-4" (memory i64 0)))
(module (import "test" "memory64-2-4" (memory i64 2 4)))
(module (import "test" "memory64-2-4" (memory i64 1 4)))
(module (import "test" "memory64-2-4" (memory i64 0 4)))
(module (import "test" "memory64-2-4" (memory i64 2 5)))
(module (import "test" "memory64-2-4" (memory i64 1 5)))
(module (import "test" "memory64-2-4" (memory i64 0 5)))
(module (import "spectest" "memory" (memory 1)))
(module (import "spectest" "memory" (memory 0)))
(module (import "spectest" "memory" (memory 1 2)))
Expand All @@ -536,13 +613,149 @@
)

(assert_unlinkable
(module (import "test" "memory-2-inf" (memory 3)))
(module (import "test" "memory-2-inf" (memory 0 1)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-inf" (memory 0 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-inf" (memory 0 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-inf" (memory 2 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-inf" (memory 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 0 1)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 0 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 0 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 2 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 2 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 3 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 3 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 3 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 4 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 4 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory i64 0 1)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory i64 0 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory i64 0 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory i64 2 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory i64 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 0 1)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 0 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 0 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 2 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 2 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 3 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 3 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 3 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 4 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 4 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 3)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory i64 5)))
"incompatible import type"
)
(assert_unlinkable
(module (import "spectest" "memory" (memory 2)))
"incompatible import type"
Expand All @@ -552,6 +765,23 @@
"incompatible import type"
)

(assert_unlinkable
(module (import "test" "memory-2-inf" (memory i64 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-inf" (memory 2)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory-2-4" (memory i64 2 4)))
"incompatible import type"
)
(assert_unlinkable
(module (import "test" "memory64-2-4" (memory 2 4)))
"incompatible import type"
)

(assert_unlinkable
(module (import "test" "func-i32" (memory 1)))
"incompatible import type"
Expand Down
4 changes: 2 additions & 2 deletions test/js-api/memory/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function assert_ArrayBuffer(actual, { size=0, shared=false, detached=false }, me
assert_equals(Object.isExtensible(actual), !shared, "buffer extensibility");
}

function assert_Memory(memory, { size=0, shared=false, index="u32" }) {
function assert_Memory(memory, { size=0, shared=false, address="i32" }) {
assert_equals(Object.getPrototypeOf(memory), WebAssembly.Memory.prototype,
"prototype");
assert_true(Object.isExtensible(memory), "extensible");
Expand All @@ -38,6 +38,6 @@ function assert_Memory(memory, { size=0, shared=false, index="u32" }) {

// this depends on js-types proposal implementation
if (typeof memory.type == "function") {
assert_equals(memory.type().index, index, "memory index");
assert_equals(memory.type().address, address, "memory address type");
}
}
Loading

0 comments on commit ade7380

Please sign in to comment.