check.test 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. #!/bin/sh
  2. # must be run from this directory
  3. guile=${GUILE-../libguile/guile}
  4. if [ -x $guile ] ; then
  5. :
  6. else
  7. echo could not find guile interpreter.
  8. echo '(are you running this script from' `dirname $0` '?)'
  9. echo GUILE env var: ${GUILE-not set}
  10. exit 1
  11. fi
  12. if test "X$srcdir" = X; then
  13. srcdir=.
  14. fi
  15. set -e
  16. #
  17. # simple-hello.scm
  18. #
  19. $guile -s $srcdir/scripts/simple-hello.scm > TMP
  20. cat <<EOF | diff -u - TMP
  21. Hello, World!
  22. EOF
  23. rm -f TMP
  24. #
  25. # hello
  26. #
  27. $guile -s $srcdir/scripts/hello > TMP
  28. echo "Hello, World!" | diff -u - TMP
  29. rm -f TMP
  30. $guile -s $srcdir/scripts/hello --version > TMP
  31. echo "hello 0.0.1" | diff -u - TMP
  32. rm -f TMP
  33. $guile -s $srcdir/scripts/hello --help > TMP
  34. cat <<EOF | diff -u - TMP
  35. Usage: hello [options...]
  36. --help, -h Show this usage information
  37. --version, -v Show version information
  38. EOF
  39. rm -f TMP
  40. #
  41. # fact
  42. #
  43. case `$guile -s $srcdir/scripts/fact 5` in 120) ;; *) echo $0: error: fact 5 ;; esac
  44. #
  45. # ./box/box test #1
  46. #
  47. ./box/box -c '(let ((b (make-box))) (display b) (newline))' > TMP
  48. cat <<EOF | diff -u - TMP
  49. #<box #f>
  50. EOF
  51. rm -f TMP
  52. #
  53. # ./box/box test #2
  54. #
  55. ./box/box -c '(let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline))' > TMP
  56. cat <<EOF | diff -u - TMP
  57. #<box #f>
  58. #<box 1>
  59. EOF
  60. rm -f TMP
  61. #
  62. # ./box/box test #3
  63. #
  64. ./box/box -c '(let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline) (display (box-ref b)) (newline))' > TMP
  65. cat <<EOF | diff -u - TMP
  66. #<box #f>
  67. #<box 1>
  68. 1
  69. EOF
  70. rm -f TMP
  71. #
  72. # ./box-module/box test #1
  73. #
  74. ./box-module/box -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline)))' > TMP
  75. cat <<EOF | diff -u - TMP
  76. #<box #f>
  77. EOF
  78. rm -f TMP
  79. #
  80. # ./box-module/box test #2
  81. #
  82. ./box-module/box -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline)))' > TMP
  83. cat <<EOF | diff -u - TMP
  84. #<box #f>
  85. #<box 1>
  86. EOF
  87. rm -f TMP
  88. #
  89. # ./box-module/box test #3
  90. #
  91. ./box-module/box -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline) (display (box-ref b)) (newline)))' > TMP
  92. cat <<EOF | diff -u - TMP
  93. #<box #f>
  94. #<box 1>
  95. 1
  96. EOF
  97. rm -f TMP
  98. #
  99. # ./box-dynamic/box test #1
  100. #
  101. $guile -c '(begin (load-extension "libbox" "scm_init_box") (let ((b (make-box))) (display b) (newline)))' > TMP
  102. cat <<EOF | diff -u - TMP
  103. #<box #f>
  104. EOF
  105. rm -f TMP
  106. #
  107. # ./box-dynamic/box test #2
  108. #
  109. $guile -c '(begin (load-extension "libbox" "scm_init_box") (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline)))' > TMP
  110. cat <<EOF | diff -u - TMP
  111. #<box #f>
  112. #<box 1>
  113. EOF
  114. rm -f TMP
  115. #
  116. # ./box-dynamic/box test #3
  117. #
  118. $guile -c '(begin (load-extension "libbox" "scm_init_box") (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline) (display (box-ref b)) (newline)))' > TMP
  119. cat <<EOF | diff -u - TMP
  120. #<box #f>
  121. #<box 1>
  122. 1
  123. EOF
  124. rm -f TMP
  125. #
  126. # ./box-dynamic-module/box test #1
  127. #
  128. $guile -L $srcdir/box-dynamic-module \
  129. -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline)))' > TMP
  130. cat <<EOF | diff -u - TMP
  131. #<box #f>
  132. EOF
  133. rm -f TMP
  134. #
  135. # ./box-dynamic-module/box test #2
  136. #
  137. $guile -L $srcdir/box-dynamic-module \
  138. -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline)))' > TMP
  139. cat <<EOF | diff -u - TMP
  140. #<box #f>
  141. #<box 1>
  142. EOF
  143. rm -f TMP
  144. #
  145. # ./box-dynamic-module/box test #3
  146. #
  147. $guile -L $srcdir/box-dynamic-module \
  148. -c '(begin (use-modules (box-module)) (let ((b (make-box))) (display b) (newline) (box-set! b 1) (display b) (newline) (display (box-ref b)) (newline)))' > TMP
  149. cat <<EOF | diff -u - TMP
  150. #<box #f>
  151. #<box 1>
  152. 1
  153. EOF
  154. rm -f TMP
  155. #
  156. # ./box-dynamic-module/box test #4
  157. #
  158. $guile -L $srcdir/box-dynamic-module \
  159. -c '(begin (use-modules (box-mixed)) (let ((b (make-box-list 1 2 3))) (display b) (newline) (display (box-map 1+ b)) (newline)))' > TMP
  160. cat <<EOF | diff -u - TMP
  161. (#<box 1> #<box 2> #<box 3>)
  162. (#<box 2> #<box 3> #<box 4>)
  163. EOF
  164. rm -f TMP
  165. #
  166. # ./main test
  167. #
  168. $guile -L $srcdir/modules -s $srcdir/modules/main > TMP
  169. cat <<EOF | diff -u - TMP
  170. module-0 foo
  171. module-0 bar
  172. module-1 foo
  173. module-1 bar
  174. module-2 braz
  175. module-2 braz
  176. module-2 foo
  177. EOF
  178. rm -f TMP
  179. #
  180. # ./safe untrusted.scm
  181. #
  182. $guile -s $srcdir/safe/safe $srcdir/safe/untrusted.scm > TMP
  183. cat <<EOF | diff -u - TMP
  184. 1
  185. 1
  186. 2
  187. 6
  188. 24
  189. 120
  190. 720
  191. 5040
  192. 40320
  193. 362880
  194. 3628800
  195. EOF
  196. rm -f TMP
  197. #
  198. # ./safe evil.scm
  199. #
  200. $guile -s $srcdir/safe/safe $srcdir/safe/evil.scm > TMP
  201. cat <<EOF | diff -u - TMP
  202. ** Exception: (unbound-variable #f "Unbound variable: ~S" (open-input-file) #f)
  203. EOF
  204. rm -f TMP
  205. # check.test ends here