1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
;; A preliminary test for prototype GC types and instructions.
;; TODO: Move subtype tests from reference-types.wast here?
;; TODO: The test assumes that `(i31.new (i32.const N))` is a valid constant
;; initializer for i31ref types globals, which isn't yet specified.
(module
;; Test global initializer expressions
(global $global_anyref (mut anyref) (ref.null any))
(global $global_eqref (mut eqref) (ref.null eq))
(global $global_i31ref (mut i31ref) (i31.new (i32.const 0)))
;; Test subtype relationship in global initializer expressions
(global $global_anyref2 (mut anyref) (ref.null eq))
(global $global_anyref3 (mut anyref) (i31.new (i32.const 0)))
(global $global_eqref2 (mut eqref) (i31.new (i32.const 0)))
(func $test
(param $local_i31ref i31ref)
(param $local_dataref dataref)
(local $local_i32 i32)
(local $local_anyref anyref)
(local $local_eqref eqref)
;; Test types for local.get/set
(local.set $local_anyref (local.get $local_anyref))
(local.set $local_anyref (global.get $global_anyref))
(local.set $local_anyref (ref.null any))
(local.set $local_eqref (local.get $local_eqref))
(local.set $local_eqref (global.get $global_eqref))
(local.set $local_eqref (ref.null eq))
(local.set $local_i31ref (local.get $local_i31ref))
(local.set $local_i31ref (global.get $global_i31ref))
(local.set $local_i31ref (i31.new (i32.const 0)))
;; Test subtype relationship for local.set
(local.set $local_anyref (local.get $local_eqref))
(local.set $local_anyref (global.get $global_eqref))
(local.set $local_anyref (ref.null eq))
(local.set $local_anyref (local.get $local_i31ref))
(local.set $local_anyref (global.get $global_i31ref))
(local.set $local_anyref (i31.new (i32.const 0)))
(local.set $local_eqref (local.get $local_i31ref))
(local.set $local_eqref (global.get $global_i31ref))
(local.set $local_eqref (i31.new (i32.const 0)))
;; Test types for global.get/set
(global.set $global_anyref (local.get $local_anyref))
(global.set $global_anyref (global.get $global_anyref))
(global.set $global_anyref (ref.null any))
(global.set $global_eqref (local.get $local_eqref))
(global.set $global_eqref (global.get $global_eqref))
(global.set $global_eqref (ref.null eq))
(global.set $global_i31ref (local.get $local_i31ref))
(global.set $global_i31ref (global.get $global_i31ref))
(global.set $global_i31ref (i31.new (i32.const 0)))
;; Test subtype relationship for global.set
(global.set $global_anyref (local.get $local_eqref))
(global.set $global_anyref (global.get $global_eqref))
(global.set $global_anyref (ref.null eq))
(global.set $global_anyref (local.get $local_i31ref))
(global.set $global_anyref (global.get $global_i31ref))
(global.set $global_anyref (i31.new (i32.const 0)))
(global.set $global_eqref (local.get $local_i31ref))
(global.set $global_eqref (global.get $global_i31ref))
(global.set $global_eqref (i31.new (i32.const 0)))
;; Test i31.get_s/u
(local.set $local_i32 (i31.get_s (local.get $local_i31ref)))
(local.set $local_i32 (i31.get_u (local.get $local_i31ref)))
)
(func $test-variants
(param $local_i31refnull (ref null i31))
(param $local_i31refnonnull (ref i31))
(param $local_datarefnull (ref null data))
(param $local_datarefnonnull (ref data))
)
)
|