test3.wast 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. (module
  2. (type $t0 (sub (struct)))
  3. (type $t1 (sub $t0 (struct (field i32))))
  4. (type $t1' (sub $t0 (struct (field i32))))
  5. (type $t2 (sub $t1 (struct (field i32 i32))))
  6. (type $t2' (sub $t1' (struct (field i32 i32))))
  7. (type $t3 (sub $t0 (struct (field i32 i32))))
  8. (type $t0' (sub $t0 (struct)))
  9. (type $t4 (sub $t0' (struct (field i32 i32))))
  10. (table 20 (ref null struct))
  11. (func $init
  12. (table.set (i32.const 0) (struct.new_canon_default $t0))
  13. (table.set (i32.const 10) (struct.new_canon_default $t0))
  14. (table.set (i32.const 1) (struct.new_canon_default $t1))
  15. (table.set (i32.const 11) (struct.new_canon_default $t1'))
  16. (table.set (i32.const 2) (struct.new_canon_default $t2))
  17. (table.set (i32.const 12) (struct.new_canon_default $t2'))
  18. (table.set (i32.const 3) (struct.new_canon_default $t3))
  19. (table.set (i32.const 4) (struct.new_canon_default $t4))
  20. )
  21. (func (export "test-sub")
  22. (call $init)
  23. (block $l
  24. ;; must hold
  25. (br_if $l (i32.eqz (ref.test null $t0 (ref.null struct))))
  26. (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0))))
  27. (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1))))
  28. (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2))))
  29. (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3))))
  30. (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t4))))
  31. (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 0)))))
  32. (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 1)))))
  33. (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 2)))))
  34. (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 3)))))
  35. (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 4)))))
  36. (br_if $l (i32.eqz (ref.test null $t1 (ref.null struct))))
  37. (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t0))))
  38. (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1))))
  39. (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2))))
  40. (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3))))
  41. (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t4))))
  42. (br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 1)))))
  43. (br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 2)))))
  44. (br_if $l (i32.eqz (ref.test null $t2 (ref.null struct))))
  45. (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t0))))
  46. (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1))))
  47. (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2))))
  48. (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3))))
  49. (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t4))))
  50. (br_if $l (i32.eqz (ref.test null $t2 (table.get (i32.const 2)))))
  51. (br_if $l (i32.eqz (ref.test null $t3 (ref.null struct))))
  52. (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t0))))
  53. (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1))))
  54. (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2))))
  55. (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3))))
  56. (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t4))))
  57. (br_if $l (i32.eqz (ref.test null $t3 (table.get (i32.const 3)))))
  58. (br_if $l (i32.eqz (ref.test null $t4 (ref.null struct))))
  59. (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t0))))
  60. (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1))))
  61. (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2))))
  62. (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3))))
  63. (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t4))))
  64. (br_if $l (i32.eqz (ref.test null $t4 (table.get (i32.const 4)))))
  65. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0)))))
  66. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1)))))
  67. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2)))))
  68. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3)))))
  69. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4)))))
  70. (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 1)))))
  71. (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 2)))))
  72. (br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 2)))))
  73. (br_if $l (i32.eqz (ref.test $t3 (table.get (i32.const 3)))))
  74. (br_if $l (i32.eqz (ref.test $t4 (table.get (i32.const 4)))))
  75. ;; must not hold
  76. (br_if $l (ref.test $t0 (ref.null struct)))
  77. (br_if $l (ref.test $t1 (ref.null struct)))
  78. (br_if $l (ref.test $t2 (ref.null struct)))
  79. (br_if $l (ref.test $t3 (ref.null struct)))
  80. (br_if $l (ref.test $t4 (ref.null struct)))
  81. (br_if $l (ref.test $t1 (table.get (i32.const 0))))
  82. (br_if $l (ref.test $t1 (table.get (i32.const 3))))
  83. (br_if $l (ref.test $t1 (table.get (i32.const 4))))
  84. (br_if $l (ref.test $t2 (table.get (i32.const 0))))
  85. (br_if $l (ref.test $t2 (table.get (i32.const 1))))
  86. (br_if $l (ref.test $t2 (table.get (i32.const 3))))
  87. (br_if $l (ref.test $t2 (table.get (i32.const 4))))
  88. (br_if $l (ref.test $t3 (table.get (i32.const 0))))
  89. (br_if $l (ref.test $t3 (table.get (i32.const 1))))
  90. (br_if $l (ref.test $t3 (table.get (i32.const 2))))
  91. (br_if $l (ref.test $t3 (table.get (i32.const 4))))
  92. (br_if $l (ref.test $t4 (table.get (i32.const 0))))
  93. (br_if $l (ref.test $t4 (table.get (i32.const 1))))
  94. (br_if $l (ref.test $t4 (table.get (i32.const 2))))
  95. (br_if $l (ref.test $t4 (table.get (i32.const 3))))
  96. (return)
  97. )
  98. (unreachable)
  99. )
  100. (func (export "test-canon")
  101. (call $init)
  102. (block $l
  103. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0)))))
  104. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1)))))
  105. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2)))))
  106. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3)))))
  107. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4)))))
  108. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 10)))))
  109. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 11)))))
  110. (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 12)))))
  111. (br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 1)))))
  112. (br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 2)))))
  113. (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 11)))))
  114. (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 12)))))
  115. (br_if $l (i32.eqz (ref.test $t2' (table.get (i32.const 2)))))
  116. (br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 12)))))
  117. (return)
  118. )
  119. (unreachable)
  120. )
  121. )