test-inline-wasm.scm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ;;; Copyright (C) 2023 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. (test-call "43" (lambda (a)
  23. (%inline-wasm
  24. '(func (param $a i64) (result i64)
  25. (i64.add (local.get $a) (i64.const 1)))
  26. a))
  27. 42)
  28. (test-call "43" (lambda (a)
  29. (%inline-wasm
  30. '(func (param $a i32) (result i64)
  31. (i64.extend_i32_u (i32.add (local.get $a) (i32.const 1))))
  32. a))
  33. 42)
  34. (test-call "43.0" (lambda (a)
  35. (%inline-wasm
  36. '(func (param $a f64) (result f64)
  37. (f64.add (local.get $a) (f64.const 1.0)))
  38. a))
  39. 42)
  40. (test-call "43.0" (lambda (a)
  41. (%inline-wasm
  42. '(func (param $a f64) (result f64)
  43. (f64.add (local.get $a) (f64.const 1.0)))
  44. a))
  45. 42.0)
  46. (test-call "43.0" (lambda (a)
  47. (%inline-wasm
  48. '(func (param $a f32) (result f64)
  49. (f64.promote_f32 (f32.add (local.get $a) (f32.const 1.0))))
  50. a))
  51. 42)
  52. (test-call "7" (lambda (a)
  53. (%inline-wasm
  54. '(func (param $a (ref string)) (result i64)
  55. (i64.extend_i32_u
  56. (stringview_iter.advance (string.as_iter (local.get $a))
  57. (i32.const -1))))
  58. a))
  59. "hey hey")
  60. (test-end* "test-inline-wasm")