;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test --ignore-external-input --quiet -all -g -S -o - | filecheck %s

;; Test we execute call_ref properly. After the call, the global will be set to
;; 1.
(module
  ;; CHECK:      (type $f (func))
  (type $f (func))

  ;; CHECK:      (global $g (mut i32) (i32.const 1))
  (global $g (export "gg") (mut i32) (i32.const 0))

  (elem declare $test2)

  (func $test (export "test")
    (call_ref $f
      (ref.func $called)
    )
  )

  (func $called (type $f)
    (global.set $g
      (i32.const 1)
    )
  )
)

;; CHECK:      (export "gg" (global $g))

;; CHECK:      (export "test" (func $test_2))

;; CHECK:      (func $test_2 (type $f)
;; CHECK-NEXT:  (nop)
;; CHECK-NEXT: )
