Skip to content

Commit 36c9014

Browse files
Honryrossberg
authored andcommitted
[test] Add more tests for operand missing (#948)
1 parent 31b4f34 commit 36c9014

File tree

6 files changed

+849
-11
lines changed

6 files changed

+849
-11
lines changed

test/core/globals.wast

+125
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,128 @@
355355
)
356356
"invalid mutability"
357357
)
358+
359+
360+
(assert_invalid
361+
(module
362+
(global $x (mut i32) (i32.const 0))
363+
(func $type-global.set-value-empty
364+
(global.set $x)
365+
)
366+
)
367+
"type mismatch"
368+
)
369+
(assert_invalid
370+
(module
371+
(global $x (mut i32) (i32.const 0))
372+
(func $type-global.set-value-empty-in-block
373+
(i32.const 0)
374+
(block (global.set $x))
375+
)
376+
)
377+
"type mismatch"
378+
)
379+
(assert_invalid
380+
(module
381+
(global $x (mut i32) (i32.const 0))
382+
(func $type-global.set-value-empty-in-loop
383+
(i32.const 0)
384+
(loop (global.set $x))
385+
)
386+
)
387+
"type mismatch"
388+
)
389+
(assert_invalid
390+
(module
391+
(global $x (mut i32) (i32.const 0))
392+
(func $type-global.set-value-empty-in-then
393+
(i32.const 0) (i32.const 0)
394+
(if (then (global.set $x)))
395+
)
396+
)
397+
"type mismatch"
398+
)
399+
(assert_invalid
400+
(module
401+
(global $x (mut i32) (i32.const 0))
402+
(func $type-global.set-value-empty-in-else
403+
(i32.const 0) (i32.const 0)
404+
(if (result i32) (then (i32.const 0)) (else (global.set $x)))
405+
)
406+
)
407+
"type mismatch"
408+
)
409+
(assert_invalid
410+
(module
411+
(global $x (mut i32) (i32.const 0))
412+
(func $type-global.set-value-empty-in-br
413+
(i32.const 0)
414+
(block (br 0 (global.set $x)))
415+
)
416+
)
417+
"type mismatch"
418+
)
419+
(assert_invalid
420+
(module
421+
(global $x (mut i32) (i32.const 0))
422+
(func $type-global.set-value-empty-in-br_if
423+
(i32.const 0)
424+
(block (br_if 0 (global.set $x)))
425+
)
426+
)
427+
"type mismatch"
428+
)
429+
(assert_invalid
430+
(module
431+
(global $x (mut i32) (i32.const 0))
432+
(func $type-global.set-value-empty-in-br_table
433+
(i32.const 0)
434+
(block (br_table 0 (global.set $x)))
435+
)
436+
)
437+
"type mismatch"
438+
)
439+
(assert_invalid
440+
(module
441+
(global $x (mut i32) (i32.const 0))
442+
(func $type-global.set-value-empty-in-return
443+
(return (global.set $x))
444+
)
445+
)
446+
"type mismatch"
447+
)
448+
(assert_invalid
449+
(module
450+
(global $x (mut i32) (i32.const 0))
451+
(func $type-global.set-value-empty-in-select
452+
(select (global.set $x) (i32.const 1) (i32.const 2))
453+
)
454+
)
455+
"type mismatch"
456+
)
457+
(assert_invalid
458+
(module
459+
(global $x (mut i32) (i32.const 0))
460+
(func $type-global.set-value-empty-in-call
461+
(call 1 (global.set $x))
462+
)
463+
(func (param i32) (result i32) (local.get 0))
464+
)
465+
"type mismatch"
466+
)
467+
(assert_invalid
468+
(module
469+
(global $x (mut i32) (i32.const 0))
470+
(func $f (param i32) (result i32) (local.get 0))
471+
(type $sig (func (param i32) (result i32)))
472+
(table funcref (elem $f))
473+
(func $type-global.set-value-empty-in-call_indirect
474+
(block (result i32)
475+
(call_indirect (type $sig)
476+
(global.set $x) (i32.const 0)
477+
)
478+
)
479+
)
480+
)
481+
"type mismatch"
482+
)

test/core/load.wast

+183
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,186 @@
364364
(module (memory 1) (func $load_f64 (f64.load (i32.const 0))))
365365
"type mismatch"
366366
)
367+
368+
369+
(assert_invalid
370+
(module
371+
(memory 0)
372+
(func $type-address-empty
373+
(i32.load) (drop)
374+
)
375+
)
376+
"type mismatch"
377+
)
378+
(assert_invalid
379+
(module
380+
(memory 0)
381+
(func $type-address-empty-in-block
382+
(i32.const 0)
383+
(block (i32.load) (drop))
384+
)
385+
)
386+
"type mismatch"
387+
)
388+
(assert_invalid
389+
(module
390+
(memory 0)
391+
(func $type-address-empty-in-loop
392+
(i32.const 0)
393+
(loop (i32.load) (drop))
394+
)
395+
)
396+
"type mismatch"
397+
)
398+
(assert_invalid
399+
(module
400+
(memory 0)
401+
(func $type-address-empty-in-then
402+
(i32.const 0) (i32.const 0)
403+
(if (then (i32.load) (drop)))
404+
)
405+
)
406+
"type mismatch"
407+
)
408+
(assert_invalid
409+
(module
410+
(memory 0)
411+
(func $type-address-empty-in-else
412+
(i32.const 0) (i32.const 0)
413+
(if (result i32) (then (i32.const 0)) (else (i32.load))) (drop)
414+
)
415+
)
416+
"type mismatch"
417+
)
418+
(assert_invalid
419+
(module
420+
(memory 0)
421+
(func $type-address-empty-in-br
422+
(i32.const 0)
423+
(block (br 0 (i32.load)) (drop))
424+
)
425+
)
426+
"type mismatch"
427+
)
428+
(assert_invalid
429+
(module
430+
(memory 0)
431+
(func $type-address-empty-in-br_if
432+
(i32.const 0)
433+
(block (br_if 0 (i32.load) (i32.const 1)) (drop))
434+
)
435+
)
436+
"type mismatch"
437+
)
438+
(assert_invalid
439+
(module
440+
(memory 0)
441+
(func $type-address-empty-in-br_table
442+
(i32.const 0)
443+
(block (br_table 0 (i32.load)) (drop))
444+
)
445+
)
446+
"type mismatch"
447+
)
448+
(assert_invalid
449+
(module
450+
(memory 0)
451+
(func $type-address-empty-in-return
452+
(return (i32.load)) (drop)
453+
)
454+
)
455+
"type mismatch"
456+
)
457+
(assert_invalid
458+
(module
459+
(memory 0)
460+
(func $type-address-empty-in-select
461+
(select (i32.load) (i32.const 1) (i32.const 2)) (drop)
462+
)
463+
)
464+
"type mismatch"
465+
)
466+
(assert_invalid
467+
(module
468+
(memory 0)
469+
(func $type-address-empty-in-call
470+
(call 1 (i32.load)) (drop)
471+
)
472+
(func (param i32) (result i32) (local.get 0))
473+
)
474+
"type mismatch"
475+
)
476+
(assert_invalid
477+
(module
478+
(memory 0)
479+
(func $f (param i32) (result i32) (local.get 0))
480+
(type $sig (func (param i32) (result i32)))
481+
(table funcref (elem $f))
482+
(func $type-address-empty-in-call_indirect
483+
(block (result i32)
484+
(call_indirect (type $sig)
485+
(i32.load) (i32.const 0)
486+
)
487+
(drop)
488+
)
489+
)
490+
)
491+
"type mismatch"
492+
)
493+
(assert_invalid
494+
(module
495+
(memory 0)
496+
(func $type-address-empty-in-local.set
497+
(local i32)
498+
(local.set 0 (i32.load)) (local.get 0) (drop)
499+
)
500+
)
501+
"type mismatch"
502+
)
503+
(assert_invalid
504+
(module
505+
(memory 0)
506+
(func $type-address-empty-in-local.tee
507+
(local i32)
508+
(local.tee 0 (i32.load)) (drop)
509+
)
510+
)
511+
"type mismatch"
512+
)
513+
(assert_invalid
514+
(module
515+
(memory 0)
516+
(global $x (mut i32) (i32.const 0))
517+
(func $type-address-empty-in-global.set
518+
(global.set $x (i32.load)) (global.get $x) (drop)
519+
)
520+
)
521+
"type mismatch"
522+
)
523+
(assert_invalid
524+
(module
525+
(memory 0)
526+
(func $type-address-empty-in-memory.grow
527+
(memory.grow (i32.load)) (drop)
528+
)
529+
)
530+
"type mismatch"
531+
)
532+
(assert_invalid
533+
(module
534+
(memory 0)
535+
(func $type-address-empty-in-load
536+
(i32.load (i32.load)) (drop)
537+
)
538+
)
539+
"type mismatch"
540+
)
541+
(assert_invalid
542+
(module
543+
(memory 1)
544+
(func $type-address-empty-in-store
545+
(i32.store (i32.load) (i32.const 1))
546+
)
547+
)
548+
"type mismatch"
549+
)

test/core/local_get.wast

+7-4
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,23 @@
174174
"type mismatch"
175175
)
176176

177+
178+
;; local.set should have retval
179+
177180
(assert_invalid
178-
(module (func $i32-vs-empty (local i32) (local.get 0)))
181+
(module (func $type-empty-vs-i32 (local i32) (local.get 0)))
179182
"type mismatch"
180183
)
181184
(assert_invalid
182-
(module (func $i64-vs-empty (local i64) (local.get 0)))
185+
(module (func $type-empty-vs-i64 (local i64) (local.get 0)))
183186
"type mismatch"
184187
)
185188
(assert_invalid
186-
(module (func $f32-vs-empty (local f32) (local.get 0)))
189+
(module (func $type-empty-vs-f32 (local f32) (local.get 0)))
187190
"type mismatch"
188191
)
189192
(assert_invalid
190-
(module (func $f64-vs-empty (local f64) (local.get 0)))
193+
(module (func $type-empty-vs-f64 (local f64) (local.get 0)))
191194
"type mismatch"
192195
)
193196

0 commit comments

Comments
 (0)