srfi-111.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ;;;; srfi-111.test --- Test suite for SRFI-111 (Boxes). -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2014 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 3 of the License, or (at your option) any later version.
  9. ;;;;
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. ;;;; Lesser General Public License for more details.
  14. ;;;;
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library; if not, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. (define-module (test-srfi-111)
  19. #:use-module (test-suite lib)
  20. #:use-module (srfi srfi-1)
  21. #:use-module (srfi srfi-111))
  22. (with-test-prefix "srfi-111"
  23. (let ((test-vals '(#f #t #\space "string" -5 #e1e100 1e-30 #(a vector))))
  24. (pass-if-equal "box and unbox"
  25. test-vals
  26. (map (lambda (x)
  27. (unbox (box x)))
  28. test-vals))
  29. (pass-if "box?"
  30. (and (box? (box 5))
  31. (not (any box? test-vals))))
  32. (pass-if-equal "set-box!"
  33. "string"
  34. (let ((b (box #f)))
  35. (set-box! b "string")
  36. (unbox b)))
  37. (pass-if "eq? on boxes"
  38. (let ((box1 (box #f))
  39. (box2 (box #f)))
  40. (and (eq? box1 box1)
  41. (eq? box2 box2)
  42. (not (eq? box1 box2)))))
  43. (pass-if "eqv? on boxes"
  44. (let ((box1 (box #f))
  45. (box2 (box #f)))
  46. (and (eqv? box1 box1)
  47. (eqv? box2 box2)
  48. (not (eqv? box1 box2)))))
  49. (pass-if "equal? on boxes"
  50. (let ((box1 (box "foo"))
  51. (box2 (box "bar")))
  52. (and (equal? box1 box1)
  53. (equal? box2 box2)
  54. (not (equal? box1 box2))
  55. ;; Guile extension, not guaranteed by SRFI-111.
  56. (begin (set-box! box2 (string #\f #\o #\o))
  57. (equal? box1 box2)))))))