;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; Similar to string-lowering-imports but the strings are imported from a
;; custom module name. The string constant should be imported from "strings", as
;; the pass-arg specifies.

;; RUN: wasm-opt %s -all --string-lowering-magic-imports --pass-arg=string-constants-module@strings -S -o - | filecheck %s

(module
  ;; CHECK:      (type $0 (array (mut i16)))

  ;; CHECK:      (type $1 (func (param externref externref) (result i32)))

  ;; CHECK:      (type $2 (func (param externref) (result i32)))

  ;; CHECK:      (type $3 (func))

  ;; CHECK:      (type $4 (func (param (ref null $0) i32 i32) (result (ref extern))))

  ;; CHECK:      (type $5 (func (param i32) (result (ref extern))))

  ;; CHECK:      (type $6 (func (param externref externref) (result (ref extern))))

  ;; CHECK:      (type $7 (func (param externref (ref null $0) i32) (result i32)))

  ;; CHECK:      (type $8 (func (param externref i32) (result i32)))

  ;; CHECK:      (type $9 (func (param externref i32 i32) (result (ref extern))))

  ;; CHECK:      (import "strings" "foo" (global $"string.const_\"foo\"" (ref extern)))

  ;; CHECK:      (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $4) (param (ref null $0) i32 i32) (result (ref extern))))

  ;; CHECK:      (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint (type $5) (param i32) (result (ref extern))))

  ;; CHECK:      (import "wasm:js-string" "concat" (func $concat (type $6) (param externref externref) (result (ref extern))))

  ;; CHECK:      (import "wasm:js-string" "intoCharCodeArray" (func $intoCharCodeArray (type $7) (param externref (ref null $0) i32) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "equals" (func $equals (type $1) (param externref externref) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "test" (func $test (type $2) (param externref) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "compare" (func $compare (type $1) (param externref externref) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "length" (func $length (type $2) (param externref) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $8) (param externref i32) (result i32)))

  ;; CHECK:      (import "wasm:js-string" "substring" (func $substring (type $9) (param externref i32 i32) (result (ref extern))))

  ;; CHECK:      (export "const" (func $const))

  ;; CHECK:      (func $const (type $3)
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (global.get $"string.const_\"foo\"")
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT: )
  (func $const (export "const")
    (drop
      (string.const "foo")
    )
  )
)
