srcprop.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ;;;; srcprop.test --- test Guile source properties -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2003, 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-srcprop)
  19. :use-module (test-suite lib))
  20. ;;;
  21. ;;; source-properties
  22. ;;;
  23. (with-test-prefix "source-properties"
  24. (pass-if "no props"
  25. (null? (source-properties (list 1 2 3))))
  26. (read-enable 'positions)
  27. (let ((s (read (open-input-string "(1 . 2)"))))
  28. (pass-if "read properties"
  29. (not (null? (source-properties s))))))
  30. ;;;
  31. ;;; set-source-properties!
  32. ;;;
  33. (with-test-prefix "set-source-properties!"
  34. (read-enable 'positions)
  35. (let ((s (read (open-input-string "(1 . 2)"))))
  36. (with-test-prefix "copied props"
  37. (pass-if "visible to source-property"
  38. (let ((t (cons 3 4)))
  39. (set-source-properties! t (source-properties s))
  40. (number? (source-property t 'line))))
  41. (pass-if "visible to source-properties"
  42. (let ((t (cons 3 4)))
  43. (set-source-properties! t (source-properties s))
  44. (not (null? (source-properties t))))))))