Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 3b92782

Browse files
Honryrossberg
authored andcommitted
[test] Move tests from typecheck.wast to appropriate files (#939)
1 parent 36edef5 commit 3b92782

File tree

5 files changed

+277
-213
lines changed

5 files changed

+277
-213
lines changed

test/core/br.wast

+46
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,52 @@
442442
"type mismatch"
443443
)
444444

445+
(assert_invalid
446+
(module
447+
(func $type-operand-missing
448+
(block (result i32) (br 0))
449+
(i32.eqz) (drop)
450+
)
451+
)
452+
"type mismatch"
453+
)
454+
(assert_invalid
455+
(module
456+
(func $type-operand-missing-in-block
457+
(i32.const 0)
458+
(block (result i32) (br 0))
459+
(i32.eqz) (drop)
460+
)
461+
)
462+
"type mismatch"
463+
)
464+
(assert_invalid
465+
(module
466+
(func $type-operand-missing-in-if
467+
(block
468+
(i32.const 0) (i32.const 0)
469+
(if (result i32) (then (br 0)))
470+
)
471+
(i32.eqz) (drop)
472+
)
473+
)
474+
"type mismatch"
475+
)
476+
(assert_invalid
477+
(module
478+
(func $type-operand-missing-in-else
479+
(block
480+
(i32.const 0) (i32.const 0)
481+
(if (result i32) (then (i32.const 0)) (else (br 0)))
482+
)
483+
(i32.eqz) (drop)
484+
)
485+
)
486+
"type mismatch"
487+
)
488+
489+
;; TODO: Compare above "*operand-missing*" tests to others, identify and remove duplicates.
490+
445491
(assert_invalid
446492
(module (func $unbound-label (br 1)))
447493
"unknown label"

test/core/i32.wast

+137
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,140 @@
419419
(assert_return (invoke "ge_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
420420
(assert_return (invoke "ge_u" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
421421
(assert_return (invoke "ge_u" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
422+
423+
424+
(assert_invalid
425+
(module
426+
(func $type-unary-operand-missing
427+
(i32.eqz) (drop)
428+
)
429+
)
430+
"type mismatch"
431+
)
432+
(assert_invalid
433+
(module
434+
(func $type-unary-operand-missing-in-block
435+
(i32.const 0)
436+
(block (i32.eqz) (drop))
437+
)
438+
)
439+
"type mismatch"
440+
)
441+
(assert_invalid
442+
(module
443+
(func $type-unary-operand-missing-in-loop
444+
(i32.const 0)
445+
(loop (i32.eqz) (drop))
446+
)
447+
)
448+
"type mismatch"
449+
)
450+
(assert_invalid
451+
(module
452+
(func $type-unary-operand-missing-in-if
453+
(i32.const 0) (i32.const 0)
454+
(if (then (i32.eqz) (drop)))
455+
)
456+
)
457+
"type mismatch"
458+
)
459+
(assert_invalid
460+
(module
461+
(func $type-unary-operand-missing-in-else
462+
(i32.const 0) (i32.const 0)
463+
(if (result i32) (then (i32.const 0)) (else (i32.eqz))) (drop)
464+
)
465+
)
466+
"type mismatch"
467+
)
468+
469+
(assert_invalid
470+
(module
471+
(func $type-binary-1st-operand-missing
472+
(i32.add) (drop)
473+
)
474+
)
475+
"type mismatch"
476+
)
477+
(assert_invalid
478+
(module
479+
(func $type-binary-2nd-operand-missing
480+
(i32.const 0) (i32.add) (drop)
481+
)
482+
)
483+
"type mismatch"
484+
)
485+
(assert_invalid
486+
(module
487+
(func $type-binary-1st-operand-missing-in-block
488+
(i32.const 0) (i32.const 0)
489+
(block (i32.add) (drop))
490+
)
491+
)
492+
"type mismatch"
493+
)
494+
(assert_invalid
495+
(module
496+
(func $type-binary-2nd-operand-missing-in-block
497+
(i32.const 0)
498+
(block (i32.const 0) (i32.add) (drop))
499+
)
500+
)
501+
"type mismatch"
502+
)
503+
(assert_invalid
504+
(module
505+
(func $type-binary-1st-operand-missing-in-loop
506+
(i32.const 0) (i32.const 0)
507+
(loop (i32.add) (drop))
508+
)
509+
)
510+
"type mismatch"
511+
)
512+
(assert_invalid
513+
(module
514+
(func $type-binary-2nd-operand-missing-in-loop
515+
(i32.const 0)
516+
(loop (i32.const 0) (i32.add) (drop))
517+
)
518+
)
519+
"type mismatch"
520+
)
521+
(assert_invalid
522+
(module
523+
(func $type-binary-1st-operand-missing-in-if
524+
(i32.const 0) (i32.const 0) (i32.const 0)
525+
(if (i32.add) (then (drop)))
526+
)
527+
)
528+
"type mismatch"
529+
)
530+
(assert_invalid
531+
(module
532+
(func $type-binary-2nd-operand-missing-in-if
533+
(i32.const 0) (i32.const 0)
534+
(if (i32.const 0) (then (i32.add)) (else (drop)))
535+
)
536+
)
537+
"type mismatch"
538+
)
539+
(assert_invalid
540+
(module
541+
(func $type-binary-1st-operand-missing-in-else
542+
(i32.const 0) (i32.const 0) (i32.const 0)
543+
(if (result i32) (then (i32.const 0)) (else (i32.add) (i32.const 0)))
544+
(drop) (drop)
545+
)
546+
)
547+
"type mismatch"
548+
)
549+
(assert_invalid
550+
(module
551+
(func $type-binary-2nd-operand-missing-in-else
552+
(i32.const 0) (i32.const 0)
553+
(if (result i32) (then (i32.const 0)) (else (i32.add)))
554+
(drop)
555+
)
556+
)
557+
"type mismatch"
558+
)

test/core/if.wast

+48
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,54 @@
722722
"type mismatch"
723723
)
724724

725+
(assert_invalid
726+
(module
727+
(func $type-operand-missing
728+
(if (then))
729+
)
730+
)
731+
"type mismatch"
732+
)
733+
(assert_invalid
734+
(module
735+
(func $type-operand-missing-in-block
736+
(i32.const 0)
737+
(block (if (then)))
738+
)
739+
)
740+
"type mismatch"
741+
)
742+
(assert_invalid
743+
(module
744+
(func $type-operand-missing-in-loop
745+
(i32.const 0)
746+
(loop (if (then)))
747+
)
748+
)
749+
"type mismatch"
750+
)
751+
(assert_invalid
752+
(module
753+
(func $type-operand-missing-in-if
754+
(i32.const 0) (i32.const 0)
755+
(if (then (if (then))))
756+
)
757+
)
758+
"type mismatch"
759+
)
760+
(assert_invalid
761+
(module
762+
(func $type-operand-missing-in-else
763+
(i32.const 0) (i32.const 0)
764+
(if (result i32) (then (i32.const 0)) (else (if (then)) (i32.const 0)))
765+
(drop)
766+
)
767+
)
768+
"type mismatch"
769+
)
770+
771+
;; TODO: Compare above "*operand-missing*" tests to others, identify and remove duplicates.
772+
725773

726774
(assert_malformed
727775
(module quote "(func if end $l)")

test/core/return.wast

+46
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,49 @@
320320
"type mismatch"
321321
)
322322

323+
(assert_invalid
324+
(module
325+
(func $type-operand-missing (result i32)
326+
(return)
327+
)
328+
)
329+
"type mismatch"
330+
)
331+
(assert_invalid
332+
(module
333+
(func $type-operand-missing-in-block (result i32)
334+
(i32.const 0)
335+
(block (return))
336+
)
337+
)
338+
"type mismatch"
339+
)
340+
(assert_invalid
341+
(module
342+
(func $type-operand-missing-in-loop (result i32)
343+
(i32.const 0)
344+
(loop (return))
345+
)
346+
)
347+
"type mismatch"
348+
)
349+
(assert_invalid
350+
(module
351+
(func $type-operand-missing-in-if (result i32)
352+
(i32.const 0) (i32.const 0)
353+
(if (then (return)))
354+
)
355+
)
356+
"type mismatch"
357+
)
358+
(assert_invalid
359+
(module
360+
(func $type-operand-missing-in-else (result i32)
361+
(i32.const 0) (i32.const 0)
362+
(if (result i32) (then (i32.const 0)) (else (return))) (drop)
363+
)
364+
)
365+
"type mismatch"
366+
)
367+
368+
;; TODO: Compare above "*operand-missing*" tests to others, identify and remove duplicates.

0 commit comments

Comments
 (0)