ftw.test 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ;;;; ftw.test --- exercise ice-9/ftw.scm -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright 2006 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 2.1 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-suite test-ice-9-ftw)
  19. #:use-module (test-suite lib)
  20. #:use-module (ice-9 ftw))
  21. ;; the procedure-source checks here ensure the vector indexes we write match
  22. ;; what ice-9/posix.scm stat:dev and stat:ino do (which in turn match
  23. ;; libguile/filesys.c of course)
  24. (or (equal? (procedure-source stat:dev)
  25. '(lambda (f) (vector-ref f 0)))
  26. (error "oops, unexpected stat:dev definition"))
  27. (define (stat:dev! st dev)
  28. (vector-set! st 0 dev))
  29. (or (equal? (procedure-source stat:ino)
  30. '(lambda (f) (vector-ref f 1)))
  31. (error "oops, unexpected stat:ino definition"))
  32. (define (stat:ino! st ino)
  33. (vector-set! st 1 ino))
  34. ;;
  35. ;; visited?-proc
  36. ;;
  37. (with-test-prefix "visited?-proc"
  38. ;; normally internal-only
  39. (let* ((visited?-proc (@@ (ice-9 ftw) visited?-proc))
  40. (visited? (visited?-proc 97))
  41. (s (stat "/")))
  42. (define (try-visited? dev ino)
  43. (stat:dev! s dev)
  44. (stat:ino! s ino)
  45. (visited? s))
  46. (pass-if "0 0 - 1st" (eq? #f (try-visited? 0 0)))
  47. (pass-if "0 0 - 2nd" (eq? #t (try-visited? 0 0)))
  48. (pass-if "0 0 - 3rd" (eq? #t (try-visited? 0 0)))
  49. (pass-if "0 1" (eq? #f (try-visited? 0 1)))
  50. (pass-if "0 2" (eq? #f (try-visited? 0 2)))
  51. (pass-if "0 3" (eq? #f (try-visited? 0 3)))
  52. (pass-if "5 5" (eq? #f (try-visited? 5 5)))
  53. (pass-if "5 7" (eq? #f (try-visited? 5 7)))
  54. (pass-if "7 5" (eq? #f (try-visited? 7 5)))
  55. (pass-if "7 7" (eq? #f (try-visited? 7 7)))
  56. (pass-if "5 5 - 2nd" (eq? #t (try-visited? 5 5)))
  57. (pass-if "5 7 - 2nd" (eq? #t (try-visited? 5 7)))
  58. (pass-if "7 5 - 2nd" (eq? #t (try-visited? 7 5)))
  59. (pass-if "7 7 - 2nd" (eq? #t (try-visited? 7 7)))))