Skip to content

Commit ade7380

Browse files
authored
Spec test updates (WebAssembly#91)
* 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
1 parent 9e107e0 commit ade7380

File tree

8 files changed

+648
-38
lines changed

8 files changed

+648
-38
lines changed

test/core/imports.wast

Lines changed: 233 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
(global (export "global-mut-i64") (mut i64) (i64.const 66))
1414
(table (export "table-10-inf") 10 funcref)
1515
(table (export "table-10-20") 10 20 funcref)
16+
(table (export "table64-10-inf") i64 10 funcref)
17+
(table (export "table64-10-20") i64 10 20 funcref)
1618
(memory (export "memory-2-inf") 2)
17-
;; Multiple memories are not yet supported
18-
;; (memory (export "memory-2-4") 2 4)
19+
(memory (export "memory-2-4") 2 4)
20+
(memory (export "memory64-2-inf") i64 2)
21+
(memory (export "memory64-2-4") i64 2 4)
1922
(tag (export "tag"))
2023
(tag $tag-i32 (param i32))
2124
(export "tag-i32" (tag $tag-i32))
@@ -376,6 +379,7 @@
376379
(module
377380
(type (func (result i32)))
378381
(import "spectest" "table" (table $tab 10 20 funcref))
382+
(import "test" "table64-10-inf" (table $tab64 i64 10 funcref))
379383
(elem (table $tab) (i32.const 1) func $f $g)
380384

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

400405
(func (export "call") (param i32) (result i32)
@@ -413,8 +418,12 @@
413418
(module
414419
(import "spectest" "table" (table 0 funcref))
415420
(import "spectest" "table" (table 0 funcref))
421+
(import "test" "table64-10-inf" (table i64 10 funcref))
422+
(import "test" "table64-10-inf" (table i64 10 funcref))
416423
(table 10 funcref)
417424
(table 10 funcref)
425+
(table i64 10 funcref)
426+
(table i64 10 funcref)
418427
)
419428

420429
(module (import "test" "table-10-inf" (table 10 funcref)))
@@ -429,6 +438,18 @@
429438
(module (import "test" "table-10-20" (table 10 25 funcref)))
430439
(module (import "test" "table-10-20" (table 5 25 funcref)))
431440
(module (import "test" "table-10-20" (table 0 25 funcref)))
441+
(module (import "test" "table64-10-inf" (table i64 10 funcref)))
442+
(module (import "test" "table64-10-inf" (table i64 5 funcref)))
443+
(module (import "test" "table64-10-inf" (table i64 0 funcref)))
444+
(module (import "test" "table64-10-20" (table i64 10 funcref)))
445+
(module (import "test" "table64-10-20" (table i64 5 funcref)))
446+
(module (import "test" "table64-10-20" (table i64 0 funcref)))
447+
(module (import "test" "table64-10-20" (table i64 10 20 funcref)))
448+
(module (import "test" "table64-10-20" (table i64 5 20 funcref)))
449+
(module (import "test" "table64-10-20" (table i64 0 20 funcref)))
450+
(module (import "test" "table64-10-20" (table i64 10 25 funcref)))
451+
(module (import "test" "table64-10-20" (table i64 5 25 funcref)))
452+
(module (import "test" "table64-10-20" (table i64 0 25 funcref)))
432453
(module (import "spectest" "table" (table 10 funcref)))
433454
(module (import "spectest" "table" (table 5 funcref)))
434455
(module (import "spectest" "table" (table 0 funcref)))
@@ -455,6 +476,14 @@
455476
(module (import "test" "table-10-inf" (table 10 20 funcref)))
456477
"incompatible import type"
457478
)
479+
(assert_unlinkable
480+
(module (import "test" "table64-10-inf" (table i64 12 funcref)))
481+
"incompatible import type"
482+
)
483+
(assert_unlinkable
484+
(module (import "test" "table64-10-inf" (table i64 10 20 funcref)))
485+
"incompatible import type"
486+
)
458487
(assert_unlinkable
459488
(module (import "test" "table-10-20" (table 12 20 funcref)))
460489
"incompatible import type"
@@ -463,6 +492,14 @@
463492
(module (import "test" "table-10-20" (table 10 18 funcref)))
464493
"incompatible import type"
465494
)
495+
(assert_unlinkable
496+
(module (import "test" "table64-10-20" (table i64 12 20 funcref)))
497+
"incompatible import type"
498+
)
499+
(assert_unlinkable
500+
(module (import "test" "table64-10-20" (table i64 10 18 funcref)))
501+
"incompatible import type"
502+
)
466503
(assert_unlinkable
467504
(module (import "spectest" "table" (table 12 funcref)))
468505
"incompatible import type"
@@ -489,12 +526,30 @@
489526
"incompatible import type"
490527
)
491528

529+
(assert_unlinkable
530+
(module (import "test" "table-10-inf" (table i64 10 funcref)))
531+
"incompatible import type"
532+
)
533+
(assert_unlinkable
534+
(module (import "test" "table64-10-inf" (table 10 funcref)))
535+
"incompatible import type"
536+
)
537+
(assert_unlinkable
538+
(module (import "test" "table-10-20" (table i64 10 20 funcref)))
539+
"incompatible import type"
540+
)
541+
(assert_unlinkable
542+
(module (import "test" "table64-10-20" (table 10 20 funcref)))
543+
"incompatible import type"
544+
)
492545

493546

494547
;; Memories
495548

496549
(module
497550
(import "spectest" "memory" (memory 1 2))
551+
(import "test" "memory-2-inf" (memory 2))
552+
(import "test" "memory64-2-inf" (memory i64 2))
498553
(data (memory 0) (i32.const 10) "\10")
499554

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

508563
(module
509564
(memory (import "spectest" "memory") 1 2)
565+
(memory (import "test" "memory-2-inf") 2)
566+
(memory (import "test" "memory64-2-inf") i64 2)
510567
(data (memory 0) (i32.const 10) "\10")
511568

512569
(func (export "load") (param i32) (result i32) (i32.load (local.get 0)))
@@ -519,6 +576,26 @@
519576
(module (import "test" "memory-2-inf" (memory 2)))
520577
(module (import "test" "memory-2-inf" (memory 1)))
521578
(module (import "test" "memory-2-inf" (memory 0)))
579+
(module (import "test" "memory-2-4" (memory 2)))
580+
(module (import "test" "memory-2-4" (memory 1)))
581+
(module (import "test" "memory-2-4" (memory 0)))
582+
(module (import "test" "memory-2-4" (memory 2 4)))
583+
(module (import "test" "memory-2-4" (memory 1 4)))
584+
(module (import "test" "memory-2-4" (memory 0 4)))
585+
(module (import "test" "memory-2-4" (memory 2 5)))
586+
(module (import "test" "memory-2-4" (memory 2 6)))
587+
(module (import "test" "memory64-2-inf" (memory i64 2)))
588+
(module (import "test" "memory64-2-inf" (memory i64 1)))
589+
(module (import "test" "memory64-2-inf" (memory i64 0)))
590+
(module (import "test" "memory64-2-4" (memory i64 2)))
591+
(module (import "test" "memory64-2-4" (memory i64 1)))
592+
(module (import "test" "memory64-2-4" (memory i64 0)))
593+
(module (import "test" "memory64-2-4" (memory i64 2 4)))
594+
(module (import "test" "memory64-2-4" (memory i64 1 4)))
595+
(module (import "test" "memory64-2-4" (memory i64 0 4)))
596+
(module (import "test" "memory64-2-4" (memory i64 2 5)))
597+
(module (import "test" "memory64-2-4" (memory i64 1 5)))
598+
(module (import "test" "memory64-2-4" (memory i64 0 5)))
522599
(module (import "spectest" "memory" (memory 1)))
523600
(module (import "spectest" "memory" (memory 0)))
524601
(module (import "spectest" "memory" (memory 1 2)))
@@ -536,13 +613,149 @@
536613
)
537614

538615
(assert_unlinkable
539-
(module (import "test" "memory-2-inf" (memory 3)))
616+
(module (import "test" "memory-2-inf" (memory 0 1)))
617+
"incompatible import type"
618+
)
619+
(assert_unlinkable
620+
(module (import "test" "memory-2-inf" (memory 0 2)))
621+
"incompatible import type"
622+
)
623+
(assert_unlinkable
624+
(module (import "test" "memory-2-inf" (memory 0 3)))
540625
"incompatible import type"
541626
)
542627
(assert_unlinkable
543628
(module (import "test" "memory-2-inf" (memory 2 3)))
544629
"incompatible import type"
545630
)
631+
(assert_unlinkable
632+
(module (import "test" "memory-2-inf" (memory 3)))
633+
"incompatible import type"
634+
)
635+
(assert_unlinkable
636+
(module (import "test" "memory-2-4" (memory 0 1)))
637+
"incompatible import type"
638+
)
639+
(assert_unlinkable
640+
(module (import "test" "memory-2-4" (memory 0 2)))
641+
"incompatible import type"
642+
)
643+
(assert_unlinkable
644+
(module (import "test" "memory-2-4" (memory 0 3)))
645+
"incompatible import type"
646+
)
647+
(assert_unlinkable
648+
(module (import "test" "memory-2-4" (memory 2 2)))
649+
"incompatible import type"
650+
)
651+
(assert_unlinkable
652+
(module (import "test" "memory-2-4" (memory 2 3)))
653+
"incompatible import type"
654+
)
655+
(assert_unlinkable
656+
(module (import "test" "memory-2-4" (memory 3 3)))
657+
"incompatible import type"
658+
)
659+
(assert_unlinkable
660+
(module (import "test" "memory-2-4" (memory 3 4)))
661+
"incompatible import type"
662+
)
663+
(assert_unlinkable
664+
(module (import "test" "memory-2-4" (memory 3 5)))
665+
"incompatible import type"
666+
)
667+
(assert_unlinkable
668+
(module (import "test" "memory-2-4" (memory 4 4)))
669+
"incompatible import type"
670+
)
671+
(assert_unlinkable
672+
(module (import "test" "memory-2-4" (memory 4 5)))
673+
"incompatible import type"
674+
)
675+
(assert_unlinkable
676+
(module (import "test" "memory-2-4" (memory 3)))
677+
"incompatible import type"
678+
)
679+
(assert_unlinkable
680+
(module (import "test" "memory-2-4" (memory 4)))
681+
"incompatible import type"
682+
)
683+
(assert_unlinkable
684+
(module (import "test" "memory-2-4" (memory 5)))
685+
"incompatible import type"
686+
)
687+
(assert_unlinkable
688+
(module (import "test" "memory64-2-inf" (memory i64 0 1)))
689+
"incompatible import type"
690+
)
691+
(assert_unlinkable
692+
(module (import "test" "memory64-2-inf" (memory i64 0 2)))
693+
"incompatible import type"
694+
)
695+
(assert_unlinkable
696+
(module (import "test" "memory64-2-inf" (memory i64 0 3)))
697+
"incompatible import type"
698+
)
699+
(assert_unlinkable
700+
(module (import "test" "memory64-2-inf" (memory i64 2 3)))
701+
"incompatible import type"
702+
)
703+
(assert_unlinkable
704+
(module (import "test" "memory64-2-inf" (memory i64 3)))
705+
"incompatible import type"
706+
)
707+
(assert_unlinkable
708+
(module (import "test" "memory64-2-4" (memory i64 0 1)))
709+
"incompatible import type"
710+
)
711+
(assert_unlinkable
712+
(module (import "test" "memory64-2-4" (memory i64 0 2)))
713+
"incompatible import type"
714+
)
715+
(assert_unlinkable
716+
(module (import "test" "memory64-2-4" (memory i64 0 3)))
717+
"incompatible import type"
718+
)
719+
(assert_unlinkable
720+
(module (import "test" "memory64-2-4" (memory i64 2 2)))
721+
"incompatible import type"
722+
)
723+
(assert_unlinkable
724+
(module (import "test" "memory64-2-4" (memory i64 2 3)))
725+
"incompatible import type"
726+
)
727+
(assert_unlinkable
728+
(module (import "test" "memory64-2-4" (memory i64 3 3)))
729+
"incompatible import type"
730+
)
731+
(assert_unlinkable
732+
(module (import "test" "memory64-2-4" (memory i64 3 4)))
733+
"incompatible import type"
734+
)
735+
(assert_unlinkable
736+
(module (import "test" "memory64-2-4" (memory i64 3 5)))
737+
"incompatible import type"
738+
)
739+
(assert_unlinkable
740+
(module (import "test" "memory64-2-4" (memory i64 4 4)))
741+
"incompatible import type"
742+
)
743+
(assert_unlinkable
744+
(module (import "test" "memory64-2-4" (memory i64 4 5)))
745+
"incompatible import type"
746+
)
747+
(assert_unlinkable
748+
(module (import "test" "memory64-2-4" (memory i64 3)))
749+
"incompatible import type"
750+
)
751+
(assert_unlinkable
752+
(module (import "test" "memory64-2-4" (memory i64 4)))
753+
"incompatible import type"
754+
)
755+
(assert_unlinkable
756+
(module (import "test" "memory64-2-4" (memory i64 5)))
757+
"incompatible import type"
758+
)
546759
(assert_unlinkable
547760
(module (import "spectest" "memory" (memory 2)))
548761
"incompatible import type"
@@ -552,6 +765,23 @@
552765
"incompatible import type"
553766
)
554767

768+
(assert_unlinkable
769+
(module (import "test" "memory-2-inf" (memory i64 2)))
770+
"incompatible import type"
771+
)
772+
(assert_unlinkable
773+
(module (import "test" "memory64-2-inf" (memory 2)))
774+
"incompatible import type"
775+
)
776+
(assert_unlinkable
777+
(module (import "test" "memory-2-4" (memory i64 2 4)))
778+
"incompatible import type"
779+
)
780+
(assert_unlinkable
781+
(module (import "test" "memory64-2-4" (memory 2 4)))
782+
"incompatible import type"
783+
)
784+
555785
(assert_unlinkable
556786
(module (import "test" "func-i32" (memory 1)))
557787
"incompatible import type"

test/js-api/memory/assertions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function assert_ArrayBuffer(actual, { size=0, shared=false, detached=false }, me
2727
assert_equals(Object.isExtensible(actual), !shared, "buffer extensibility");
2828
}
2929

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

3939
// this depends on js-types proposal implementation
4040
if (typeof memory.type == "function") {
41-
assert_equals(memory.type().index, index, "memory index");
41+
assert_equals(memory.type().address, address, "memory address type");
4242
}
4343
}

0 commit comments

Comments
 (0)