pairs.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ;;;; pairs.test --- test suite for Guile's pair functions -*- 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 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. (use-modules (test-suite lib))
  19. (with-test-prefix "cxr"
  20. (define x
  21. '(1 . 2))
  22. (pass-if "car"
  23. (= (car x) 1))
  24. (pass-if "cdr"
  25. (= (cdr x) 2)))
  26. (with-test-prefix "cxxr"
  27. (define x
  28. '((1 . 3) 2 . 4))
  29. (pass-if "caar"
  30. (= (caar x) 1))
  31. (pass-if "cadr"
  32. (= (cadr x) 2))
  33. (pass-if "cdar"
  34. (= (cdar x) 3))
  35. (pass-if "cddr"
  36. (= (cddr x) 4)))
  37. (with-test-prefix "cxxxr"
  38. (define x
  39. '(((1 . 5) 3 . 7) (2 . 6) 4 . 8))
  40. (pass-if "caaar"
  41. (= (caaar x) 1))
  42. (pass-if "caadr"
  43. (= (caadr x) 2))
  44. (pass-if "cadar"
  45. (= (cadar x) 3))
  46. (pass-if "caddr"
  47. (= (caddr x) 4))
  48. (pass-if "cdaar"
  49. (= (cdaar x) 5))
  50. (pass-if "cdadr"
  51. (= (cdadr x) 6))
  52. (pass-if "cddar"
  53. (= (cddar x) 7))
  54. (pass-if "cdddr"
  55. (= (cdddr x) 8)))
  56. (with-test-prefix "cxxxxr"
  57. (define x
  58. '((((1 . 9) 5 . 13) (3 . 11) 7 . 15) ((2 . 10) 6 . 14) (4 . 12) 8 . 16))
  59. (pass-if "caaaar"
  60. (= (caaaar x) 1))
  61. (pass-if "caaadr"
  62. (= (caaadr x) 2))
  63. (pass-if "caadar"
  64. (= (caadar x) 3))
  65. (pass-if "caaddr"
  66. (= (caaddr x) 4))
  67. (pass-if "cadaar"
  68. (= (cadaar x) 5))
  69. (pass-if "cadadr"
  70. (= (cadadr x) 6))
  71. (pass-if "caddar"
  72. (= (caddar x) 7))
  73. (pass-if "cadddr"
  74. (= (cadddr x) 8))
  75. (pass-if "cdaaar"
  76. (= (cdaaar x) 9))
  77. (pass-if "cdaadr"
  78. (= (cdaadr x) 10))
  79. (pass-if "cdadar"
  80. (= (cdadar x) 11))
  81. (pass-if "cdaddr"
  82. (= (cdaddr x) 12))
  83. (pass-if "cddaar"
  84. (= (cddaar x) 13))
  85. (pass-if "cddadr"
  86. (= (cddadr x) 14))
  87. (pass-if "cdddar"
  88. (= (cdddar x) 15))
  89. (pass-if "cddddr"
  90. (= (cddddr x) 16)))