equal.scm 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ;;; GNU Mes --- Maxwell Equations of Software
  2. ;;; Copyright © 2016,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Mes.
  5. ;;;
  6. ;;; GNU Mes is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Mes is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>
  18. ;; Setup output file
  19. (set-current-output-port (open-output-file "test/results/test018.answer"))
  20. ; Test integer functionality
  21. (display "= tests:\n")
  22. (display (= 0 0 0 0 0 0 0 0 0))
  23. (display #\newline)
  24. (display (= -1 -1))
  25. (display #\newline)
  26. (display (= 1 1))
  27. (display #\newline)
  28. (display (= -1 1))
  29. (display #\newline)
  30. (display (= 1 -1))
  31. (display #\newline)
  32. (display "> tests:\n")
  33. (display (> 4 3 2 1 0 -1 -2 -3 -4))
  34. (display #\newline)
  35. (display (> -1 -1))
  36. (display #\newline)
  37. (display (> 1 1))
  38. (display #\newline)
  39. (display (> -1 1))
  40. (display #\newline)
  41. (display (> 1 -1))
  42. (display #\newline)
  43. (display ">= tests:\n")
  44. (display (> 4 3 2 1 0 0 0 -1 -2 -3 -4))
  45. (display #\newline)
  46. (display (> -1 -1))
  47. (display #\newline)
  48. (display (> 1 1))
  49. (display #\newline)
  50. (display (> -1 1))
  51. (display #\newline)
  52. (display (> 1 -1))
  53. (display #\newline)
  54. (display "< tests:\n")
  55. (display (< -4 -3 -2 -1 0 1 2 3 4))
  56. (display #\newline)
  57. (display (< -1 -1))
  58. (display #\newline)
  59. (display (< 1 1))
  60. (display #\newline)
  61. (display (< -1 1))
  62. (display #\newline)
  63. (display (< 1 -1))
  64. (display #\newline)
  65. (display "<= tests:\n")
  66. (display (<= -4 -3 -2 -1 0 0 0 1 2 3 4))
  67. (display #\newline)
  68. (display (<= -1 -1))
  69. (display #\newline)
  70. (display (<= 1 1))
  71. (display #\newline)
  72. (display (<= -1 1))
  73. (display #\newline)
  74. (display (<= 1 -1))
  75. (display #\newline)
  76. ; Test char functionality
  77. (display "char=? tests:\n")
  78. (display (char=? #\A #\A #\A #\A #\A))
  79. (display #\newline)
  80. (display (char=? #\B #\B))
  81. (display #\newline)
  82. (display (char=? #\C #\C))
  83. (display #\newline)
  84. (display (char=? #\B #\C))
  85. (display #\newline)
  86. (display (char=? #\C #\B))
  87. (display #\newline)
  88. ; Test string functionality
  89. (display "string=? tests:\n")
  90. (display (string=? "" "" "" "" ""))
  91. (display #\newline)
  92. (display (string=? "foo" "foo"))
  93. (display #\newline)
  94. (display (string=? "bar" "bar"))
  95. (display #\newline)
  96. (display (string=? "foo" "bar"))
  97. (display #\newline)
  98. (display (string=? "bar" "foo"))
  99. (display #\newline)
  100. ; Test eq? functionality per r7rs
  101. (display "\neq? tests:\n")
  102. (display (eq? 'a 'a))
  103. (display #\newline)
  104. ;; WTF guile shell shows #t and put it in file and it is #f??
  105. (display (eq? '(a) '(a)))
  106. (display #\newline)
  107. (display (eq? (list 'a) (list 'a)))
  108. (display #\newline)
  109. ;; WTF guile shell shows #t and put it in file and it is #f??
  110. (display (eq? "a" "a"))
  111. (display #\newline)
  112. (display (eq? "" ""))
  113. (display #\newline)
  114. (display (eq? '() '()))
  115. (display #\newline)
  116. (display (eq? 2 2))
  117. (display #\newline)
  118. (display (eq? #\A #\A))
  119. (display #\newline)
  120. (display (eq? car car))
  121. (display #\newline)
  122. (display (let ((n (+ 2 3))) (eq? n n)))
  123. (display #\newline)
  124. (display (let ((n '(a))) (eq? n n)))
  125. (display #\newline)
  126. (display (let ((n '#())) (eq? n n)))
  127. (display #\newline)
  128. (display (let ((p (lambda (x) x))) (eq? p p)))
  129. (display #\newline)
  130. ; Test equal? functionality per r7rs
  131. (display "\nequal? tests:\n")
  132. (display (equal? 'a 'a))
  133. (display #\newline)
  134. (display (equal? '(a) '(a)))
  135. (display #\newline)
  136. (display (equal? '(a (b) c) '(a (b) c)))
  137. (display #\newline)
  138. (display (equal? "abc" "abc"))
  139. (display #\newline)
  140. (display (equal? 2 2))
  141. (display #\newline)
  142. (display (equal? (make-vector 5 'a) (make-vector 5 'a)))
  143. (display #\newline)
  144. (display (equal? (lambda (x) x) (lambda (y) y)))
  145. (display #\newline)
  146. ;; Now to test further
  147. (display (equal? (cons 1 2) (cons 1 2)))
  148. (display #\newline)
  149. (display (equal? (cons 1 2) (cons 1 '())))
  150. (display #\newline)
  151. (display (equal? #((cons 1 2) (cons 3 '())) #((cons 1 2) (cons 3 '()))))
  152. (display #\newline)
  153. (display (equal? #((cons 1 2) (cons 3 '())) #((cons 1 2) (cons 4 '()))))
  154. (display #\newline)
  155. (display (equal? (list #(1 2) #(3 4)) (list #(1 2) #(3 4))))
  156. (display #\newline)
  157. (display (equal? (list #(1 2) #(3 4)) (list #(1 2) #(3 5))))
  158. (display #\newline)
  159. (exit 0)