test-inline-wasm.scm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ;;; Copyright (C) 2023, 2025 Igalia, S.L.
  2. ;;;
  3. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  4. ;;; you may not use this file except in compliance with the License.
  5. ;;; You may obtain a copy of the License at
  6. ;;;
  7. ;;; http://www.apache.org/licenses/LICENSE-2.0
  8. ;;;
  9. ;;; Unless required by applicable law or agreed to in writing, software
  10. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  11. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. ;;; See the License for the specific language governing permissions and
  13. ;;; limitations under the License.
  14. ;;; Commentary:
  15. ;;;
  16. ;;; Floating point number tests.
  17. ;;;
  18. ;;; Code:
  19. (use-modules (srfi srfi-64)
  20. (test utils))
  21. (test-begin "test-inline-wasm")
  22. (with-additional-imports ((hoot inline-wasm))
  23. (test-call "43" (lambda (a)
  24. (%inline-wasm
  25. '(func (param $a i64) (result i64)
  26. (i64.add (local.get $a) (i64.const 1)))
  27. a))
  28. 42)
  29. (test-call "43" (lambda (a)
  30. (%inline-wasm
  31. '(func (param $a i32) (result i64)
  32. (i64.extend_i32_u (i32.add (local.get $a) (i32.const 1))))
  33. a))
  34. 42)
  35. (test-call "43.0" (lambda (a)
  36. (%inline-wasm
  37. '(func (param $a f64) (result f64)
  38. (f64.add (local.get $a) (f64.const 1.0)))
  39. a))
  40. 42)
  41. (test-call "43.0" (lambda (a)
  42. (%inline-wasm
  43. '(func (param $a f64) (result f64)
  44. (f64.add (local.get $a) (f64.const 1.0)))
  45. a))
  46. 42.0)
  47. (test-call "43.0" (lambda (a)
  48. (%inline-wasm
  49. '(func (param $a f32) (result f64)
  50. (f64.promote_f32 (f32.add (local.get $a) (f32.const 1.0))))
  51. a))
  52. 42)
  53. (test-call "7" (lambda (a)
  54. (%inline-wasm
  55. '(func (param $a (ref string)) (result i64)
  56. (i64.extend_i32_u
  57. (stringview_iter.advance (string.as_iter (local.get $a))
  58. (i32.const -1))))
  59. a))
  60. "hey hey")
  61. ;; Inline wasm that produces multiple values.
  62. (test-call "(43 44)"
  63. (lambda (a)
  64. (call-with-values (lambda ()
  65. (%inline-wasm
  66. '(func (param $a i64) (result i64) (result i64)
  67. (i64.add (local.get $a) (i64.const 1))
  68. (i64.add (local.get $a) (i64.const 2)))
  69. a))
  70. (lambda vals vals)))
  71. 42))
  72. (test-end* "test-inline-wasm")