;;; TOOL: run-gen-spec-js
;;; ARGS: --prefix=%(test_dir)s/gen-spec-empty-prefix.js
(module
  (func (export "f32_nan") (result f32) f32.const nan)
  (func (export "f32_nan_with_tag") (result f32) f32.const nan:0x1234)
  (func (export "f32_passthru") (param f32) (result f32) local.get 0)

  (func (export "f64_nan") (result f64) f64.const nan)
  (func (export "f64_nan_with_tag") (result f64) f64.const nan:0x1234)
  (func (export "f64_passthru") (param f64) (result f64) local.get 0))

(assert_return (invoke "f32_nan") (f32.const nan:canonical))
(assert_return (invoke "f32_nan_with_tag") (f32.const nan:arithmetic))
(assert_return (invoke "f64_nan") (f64.const nan:canonical))
(assert_return (invoke "f64_nan_with_tag") (f64.const nan:canonical))

;; Rewritten to avoid passing nan as a parameter.
(assert_return (invoke "f32_passthru" (f32.const -nan)) (f32.const nan:canonical))
(assert_return (invoke "f32_passthru" (f32.const nan:0x1234)) (f32.const nan:arithmetic))
(assert_return (invoke "f64_passthru" (f64.const -nan)) (f64.const nan:canonical))
(assert_return (invoke "f64_passthru" (f64.const nan:0x1234)) (f64.const nan:arithmetic))

(;; STDOUT ;;;
// A deliberately empty file for testing.

// assert_return_nan.txt:3
let $1 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x16\x05\x60\x00\x01\x7d\x60\x01\x7d\x01\x7d\x60\x00\x01\x7c\x60\x01\x7c\x01\x7c\x60\x00\x00\x03\x0b\x0a\x00\x00\x01\x02\x02\x03\x04\x04\x04\x04\x07\x85\x01\x0a\x07\x66\x33\x32\x5f\x6e\x61\x6e\x00\x00\x10\x66\x33\x32\x5f\x6e\x61\x6e\x5f\x77\x69\x74\x68\x5f\x74\x61\x67\x00\x01\x0c\x66\x33\x32\x5f\x70\x61\x73\x73\x74\x68\x72\x75\x00\x02\x07\x66\x36\x34\x5f\x6e\x61\x6e\x00\x03\x10\x66\x36\x34\x5f\x6e\x61\x6e\x5f\x77\x69\x74\x68\x5f\x74\x61\x67\x00\x04\x0c\x66\x36\x34\x5f\x70\x61\x73\x73\x74\x68\x72\x75\x00\x05\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x06\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x07\x08\x61\x73\x73\x65\x72\x74\x5f\x32\x00\x08\x08\x61\x73\x73\x65\x72\x74\x5f\x33\x00\x09\x0a\xd3\x01\x0a\x07\x00\x43\x00\x00\xc0\x7f\x0b\x07\x00\x43\x34\x12\x80\x7f\x0b\x04\x00\x20\x00\x0b\x0b\x00\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x0b\x0b\x00\x44\x34\x12\x00\x00\x00\x00\xf0\x7f\x0b\x04\x00\x20\x00\x0b\x20\x00\x02\x40\x43\x00\x00\xc0\xff\x10\x02\xbc\x41\xff\xff\xff\xff\x07\x71\x41\x80\x80\x80\xfe\x07\x46\x45\x0d\x00\x0f\x0b\x00\x0b\x20\x00\x02\x40\x43\x34\x12\x80\x7f\x10\x02\xbc\x41\x80\x80\x80\xfe\x07\x71\x41\x80\x80\x80\xfe\x07\x46\x45\x0d\x00\x0f\x0b\x00\x0b\x2e\x00\x02\x40\x44\x00\x00\x00\x00\x00\x00\xf8\xff\x10\x05\xbd\x42\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x83\x42\x80\x80\x80\x80\x80\x80\x80\xfc\xff\x00\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x2e\x00\x02\x40\x44\x34\x12\x00\x00\x00\x00\xf0\x7f\x10\x05\xbd\x42\x80\x80\x80\x80\x80\x80\x80\xfc\xff\x00\x83\x42\x80\x80\x80\x80\x80\x80\x80\xfc\xff\x00\x51\x45\x0d\x00\x0f\x0b\x00\x0b");

// assert_return_nan.txt:12
assert_return(() => call($1, "f32_nan", []), nan:canonical);

// assert_return_nan.txt:13
assert_return(() => call($1, "f32_nan_with_tag", []), nan:arithmetic);

// assert_return_nan.txt:14
assert_return(() => call($1, "f64_nan", []), nan:canonical);

// assert_return_nan.txt:15
assert_return(() => call($1, "f64_nan_with_tag", []), nan:canonical);

// assert_return_nan.txt:18
assert_return(() => call($1, "assert_0", []));

// assert_return_nan.txt:19
assert_return(() => call($1, "assert_1", []));

// assert_return_nan.txt:20
assert_return(() => call($1, "assert_2", []));

// assert_return_nan.txt:21
assert_return(() => call($1, "assert_3", []));

;;; STDOUT ;;)
