test-atomics.scm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. ;;; Atomic box tests.
  17. ;;;
  18. ;;; Code:
  19. (use-modules (srfi srfi-64)
  20. (test utils))
  21. (test-begin "test-atomics")
  22. (test-call "42" (lambda (box)
  23. (let ((val (atomic-box-ref box)))
  24. val))
  25. (make-atomic-box 42))
  26. (test-call "(42 10 10 69 69 69 69 2)"
  27. (lambda (box)
  28. (let ((v0 (atomic-box-ref box)))
  29. (atomic-box-set! box 10)
  30. (let* ((v1 (atomic-box-ref box))
  31. (v2 (atomic-box-swap! box 69))
  32. (v3 (atomic-box-ref box))
  33. (v4 (atomic-box-compare-and-swap! box 1 2))
  34. (v5 (atomic-box-ref box))
  35. (v6 (atomic-box-compare-and-swap! box v4 2))
  36. (v7 (atomic-box-ref box)))
  37. (list v0 v1 v2 v3 v4 v5 v6 v7))))
  38. (make-atomic-box 42))
  39. (test-end* "test-atomics")