test.log 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. %%%% Starting test test
  2. Group begin: test
  3. Group begin: ck-base
  4. Test begin:
  5. test-name: "c-cons conses a number onto every sublist"
  6. source-file: "test.scm"
  7. source-line: 21
  8. source-form: (test-equal "c-cons conses a number onto every sublist" (quote ((10 1) (10 2))) (ck () (c-quote (c-map (quote (c-cons (quote 10))) (quote ((1) (2)))))))
  9. Test end:
  10. result-kind: pass
  11. actual-value: ((10 1) (10 2))
  12. expected-value: ((10 1) (10 2))
  13. Test begin:
  14. test-name: "c-cons conses a + onto every sublist"
  15. source-file: "test.scm"
  16. source-line: 28
  17. source-form: (test-equal "c-cons conses a + onto every sublist" (quote ((+ 1) (+ 2))) (ck () (c-quote (c-map (quote (c-cons (quote +))) (quote ((1) (2)))))))
  18. Test end:
  19. result-kind: pass
  20. actual-value: ((+ 1) (+ 2))
  21. expected-value: ((+ 1) (+ 2))
  22. Test begin:
  23. test-name: "c-cons conses a function onto a list to make a function call"
  24. source-file: "test.scm"
  25. source-line: 35
  26. source-form: (test-eqv "c-cons conses a function onto a list to make a function call" 3 (ck () (c-cons (quote +) (quote (1 2)))))
  27. Test end:
  28. result-kind: pass
  29. actual-value: 3
  30. expected-value: 3
  31. Test begin:
  32. test-name: "c-map maps to all elements of a list - 1"
  33. source-file: "test.scm"
  34. source-line: 39
  35. source-form: (test-equal "c-map maps to all elements of a list - 1" (quote ((10 1) (10 2))) (ck () (c-quote (c-map (quote (c-cons (quote 10))) (quote ((1) (2)))))))
  36. Test end:
  37. result-kind: pass
  38. actual-value: ((10 1) (10 2))
  39. expected-value: ((10 1) (10 2))
  40. Test begin:
  41. test-name: "c-map maps to all elements of a list - 2"
  42. source-file: "test.scm"
  43. source-line: 46
  44. source-form: (test-equal "c-map maps to all elements of a list - 2" (quote ((+ 1) (+ 2))) (ck () (c-quote (c-map (quote (c-cons (quote +))) (quote ((1) (2)))))))
  45. Test end:
  46. result-kind: pass
  47. actual-value: ((+ 1) (+ 2))
  48. expected-value: ((+ 1) (+ 2))
  49. Test begin:
  50. test-name: "c-map maps to all elements of a list - 3"
  51. source-file: "test.scm"
  52. source-line: 53
  53. source-form: (test-equal "c-map maps to all elements of a list - 3" (quote (((lambda (elem) (+ elem 1)) 1) ((lambda (elem) (+ elem 1)) 2))) (ck () (c-quote (c-map (quote (c-cons (quote (lambda (elem) (+ elem 1))))) (quote ((1) (2)))))))
  54. Test end:
  55. result-kind: pass
  56. actual-value: (((lambda (elem) (+ elem 1)) 1) ((lambda (elem) (+ elem 1)) 2))
  57. expected-value: (((lambda (elem) (+ elem 1)) 1) ((lambda (elem) (+ elem 1)) 2))
  58. Test begin:
  59. test-name: "c-apply applies procedure to list of arguments - 1"
  60. source-file: "test.scm"
  61. source-line: 63
  62. source-form: (test-equal "c-apply applies procedure to list of arguments - 1" 5 (ck () (c-apply (quote +) (c-map (quote (c-cons (quote (lambda (elem) (+ elem 1))))) (quote ((1) (2)))))))
  63. Test end:
  64. result-kind: pass
  65. actual-value: 5
  66. expected-value: 5
  67. Test begin:
  68. test-name: "c-apply applies procedure to list of arguments - 2"
  69. source-file: "test.scm"
  70. source-line: 70
  71. source-form: (test-equal "c-apply applies procedure to list of arguments - 2" 6 (let ((result 3)) (ck () (c-replace-placeholder (quote result) (quote (apply + (list 1 2 <?>)))))))
  72. Test end:
  73. result-kind: pass
  74. actual-value: 6
  75. expected-value: 6
  76. Test begin:
  77. test-name: "c-quote quotes things"
  78. source-file: "test.scm"
  79. source-line: 77
  80. source-form: (test-equal "c-quote quotes things" (quote ((anything 1) (anything 2))) (ck () (c-quote (c-map (quote (c-cons (quote anything))) (quote ((1) (2)))))))
  81. Test end:
  82. result-kind: pass
  83. actual-value: ((anything 1) (anything 2))
  84. expected-value: ((anything 1) (anything 2))
  85. Test begin:
  86. test-name: "c-unquote unquotes things"
  87. source-file: "test.scm"
  88. source-line: 84
  89. source-form: (test-equal "c-unquote unquotes things" (quote x) (ck () (c-unquote (quote (quote x)))))
  90. Test end:
  91. result-kind: pass
  92. actual-value: x
  93. expected-value: x
  94. Group end: ck-base
  95. Group begin: ck-extra
  96. Test begin:
  97. test-name: "c-and-raise raises a contract violation for a trivial case."
  98. source-file: "test.scm"
  99. source-line: 93
  100. source-form: (test-assert "c-and-raise raises a contract violation for a trivial case." (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn)) #t)) (ck () (c-and-raise (quote "unknown origin") (quote (list (= 1 1) (= 2 3)))))))
  101. Test end:
  102. result-kind: pass
  103. actual-value: #t
  104. Test begin:
  105. test-name: "c-and-raise does not raise an exception when all expressions are true."
  106. source-file: "test.scm"
  107. source-line: 109
  108. source-form: (test-assert "c-and-raise does not raise an exception when all expressions are true." (ck () (c-and-raise (quote "unknown origin") (quote (list (= 1 1))))))
  109. Test end:
  110. result-kind: pass
  111. actual-value: #t
  112. Test begin:
  113. test-name: "c-replace-placeholder replaces the placeholder in a simple expression"
  114. source-file: "test.scm"
  115. source-line: 115
  116. source-form: (test-eqv "c-replace-placeholder replaces the placeholder in a simple expression" 6 (let ((result 3)) (ck () (c-replace-placeholder (quote result) (quote (+ 1 2 <?>))))))
  117. Test end:
  118. result-kind: pass
  119. actual-value: 6
  120. expected-value: 6
  121. Test begin:
  122. test-name: "c-replace-placeholder replaces the placeholder in a list"
  123. source-file: "test.scm"
  124. source-line: 123
  125. source-form: (test-equal "c-replace-placeholder replaces the placeholder in a list" (quote (1 2 3)) (let ((result 3)) (ck () (c-replace-placeholder (quote result) (quote (list 1 2 <?>))))))
  126. Test end:
  127. result-kind: pass
  128. actual-value: (1 2 3)
  129. expected-value: (1 2 3)
  130. Test begin:
  131. test-name: "c-replace-placeholder replaces the placeholder in a compound expression"
  132. source-file: "test.scm"
  133. source-line: 131
  134. source-form: (test-equal "c-replace-placeholder replaces the placeholder in a compound expression" (quote (1 2 3)) (let ((result 7)) (ck () (c-replace-placeholder (quote result) (quote (list 1 2 (vector-index (λ (elem) (= elem <?>)) (vector 4 5 6 7 8))))))))
  135. Test end:
  136. result-kind: pass
  137. actual-value: (1 2 3)
  138. expected-value: (1 2 3)
  139. Test begin:
  140. test-name: "c-replace-placeholder replaces the placeholder multiple times in a compound expression"
  141. source-file: "test.scm"
  142. source-line: 143
  143. source-form: (test-equal "c-replace-placeholder replaces the placeholder multiple times in a compound expression" (quote (1 2 7 3)) (let ((result 7)) (ck () (c-replace-placeholder (quote result) (quote (list 1 2 <?> (vector-index (λ (elem) (= elem <?>)) (vector 4 5 6 7 8))))))))
  144. Test end:
  145. result-kind: pass
  146. actual-value: (1 2 7 3)
  147. expected-value: (1 2 7 3)
  148. Test begin:
  149. test-name: "c-list->vector converts a list to a vector - 1"
  150. source-file: "test.scm"
  151. source-line: 156
  152. source-form: (test-equal "c-list->vector converts a list to a vector - 1" (vector 1 2 3) (ck () (c-list->vector (quote (list 1 2 3)))))
  153. Test end:
  154. result-kind: pass
  155. actual-value: #(1 2 3)
  156. expected-value: #(1 2 3)
  157. Test begin:
  158. test-name: "c-list->vector converts a list to a vector - 2"
  159. source-file: "test.scm"
  160. source-line: 161
  161. source-form: (test-equal "c-list->vector converts a list to a vector - 2" (vector 1 2 3) (ck () (c-list->vector (quote (quote (1 2 3))))))
  162. Test end:
  163. result-kind: pass
  164. actual-value: #(1 2 3)
  165. expected-value: #(1 2 3)
  166. Test begin:
  167. test-name: "c-vector->list converts a vector to a list - 1"
  168. source-file: "test.scm"
  169. source-line: 166
  170. source-form: (test-equal "c-vector->list converts a vector to a list - 1" (list 1 2 3) (ck () (c-vector->list (quote (vector 1 2 3)))))
  171. Test end:
  172. result-kind: pass
  173. actual-value: (1 2 3)
  174. expected-value: (1 2 3)
  175. Test begin:
  176. test-name: "c-vector->list converts a vector to a list - 2"
  177. source-file: "test.scm"
  178. source-line: 171
  179. source-form: (test-equal "c-vector->list converts a vector to a list - 2" (list 1 2 3) (ck () (c-vector->list (quote #(1 2 3)))))
  180. Test end:
  181. result-kind: pass
  182. actual-value: (1 2 3)
  183. expected-value: (1 2 3)
  184. Group end: ck-extra
  185. Group begin: contract
  186. Group begin: lambda*-with-contract
  187. Test begin:
  188. test-name: "lambda*-with-contract - contract does not raise an exception when not violated"
  189. source-file: "test.scm"
  190. source-line: 179
  191. source-form: (test-equal "lambda*-with-contract - contract does not raise an exception when not violated" "00234" ((lambda*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-char padding-length) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (cond ((< counter len-diff) (display padding-char port) (iter (+ counter 1))) (else (display num-as-str port))))))) (else num-as-str)))) 234 #\0 5))
  192. Test end:
  193. result-kind: pass
  194. actual-value: "00234"
  195. expected-value: "00234"
  196. Test begin:
  197. test-name: "lambda*-with-contract - raises when requirement violated"
  198. source-file: "test.scm"
  199. source-line: 206
  200. source-form: (test-assert "lambda*-with-contract - raises when requirement violated" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (integer? num)) (exception-irritants exn))) #t)) ((lambda*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-char padding-length) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (cond ((< counter len-diff) (display padding-char port) (iter (+ counter 1))) (else (display num-as-str port))))))) (else num-as-str)))) "234" #\0 5)))
  201. Test end:
  202. result-kind: pass
  203. actual-value: #t
  204. Test begin:
  205. test-name: "lambda*-with-contract - raises when ensure violated"
  206. source-file: "test.scm"
  207. source-line: 247
  208. source-form: (test-assert "lambda*-with-contract - raises when ensure violated" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (>= (string-length result) padding-length)) (exception-irritants exn))) #t)) ((lambda*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-char padding-length) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (when (<= counter len-diff) (display padding-char port) (iter (+ counter 1))) (display num-as-str port))))) (else num-as-str)))) 234 #\0 5)))
  209. Test end:
  210. result-kind: pass
  211. actual-value: "000234234234234"
  212. Test begin:
  213. test-name: "lambda*-with-contract - works with optional args"
  214. source-file: "test.scm"
  215. source-line: 289
  216. source-form: (test-assert "lambda*-with-contract - works with optional args" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (char? padding-char)) (exception-irritants exn))) #t)) ((lambda*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-length #:optional (padding-char #\0)) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (when (< counter len-diff) (display padding-char port) (iter (+ counter 1))) (display num-as-str port))))) (else num-as-str)))) 234 5 "9")))
  217. Test end:
  218. result-kind: pass
  219. actual-value: #t
  220. Test begin:
  221. test-name: "lambda*-with-contract - works with keyword args"
  222. source-file: "test.scm"
  223. source-line: 327
  224. source-form: (test-assert "lambda*-with-contract - works with keyword args" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (char? padding-char)) (exception-irritants exn))) #t)) ((lambda*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-length #:key (padding-char #\0)) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (when (< counter len-diff) (display padding-char port) (iter (+ counter 1))) (display num-as-str port))))) (else num-as-str)))) 234 5 #:padding-char "9")))
  225. Test end:
  226. result-kind: pass
  227. actual-value: #t
  228. Group end: lambda*-with-contract
  229. Group begin: lambda-with-contract
  230. Test begin:
  231. test-name: "lambda-with-contract - contract does not raise an exception when not violated"
  232. source-file: "test.scm"
  233. source-line: 366
  234. source-form: (test-eqv "lambda-with-contract - contract does not raise an exception when not violated" 7 ((lambda-with-contract (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance) (- account-balance amount)) 5 12))
  235. Test end:
  236. result-kind: pass
  237. actual-value: 7
  238. expected-value: 7
  239. Test begin:
  240. test-name: "lambda-with-contract - simple number contract works"
  241. source-file: "test.scm"
  242. source-line: 388
  243. source-form: (test-assert "lambda-with-contract - simple number contract works" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (<= amount account-balance)) (exception-irritants exn))) #t)) ((lambda-with-contract (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance) (- account-balance amount)) 100 90)))
  244. Test end:
  245. result-kind: pass
  246. actual-value: #t
  247. Test begin:
  248. test-name: "lambda-with-contract - simple number contract works with negative numbers"
  249. source-file: "test.scm"
  250. source-line: 411
  251. source-form: (test-assert "lambda-with-contract - simple number contract works with negative numbers" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (string=? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (>= amount 0)) (exception-irritants exn))) #t)) ((lambda-with-contract (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance) (- account-balance amount)) -15 -10)))
  252. Test end:
  253. result-kind: pass
  254. actual-value: #t
  255. Group end: lambda-with-contract
  256. Group begin: define-with-contract
  257. Test begin:
  258. test-name: "define-with-contract - does not raise an exception when not violated"
  259. source-file: "test.scm"
  260. source-line: 435
  261. source-form: (test-eqv "define-with-contract - does not raise an exception when not violated" 7 (begin (define-with-contract account-withdraw (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (λ (amount account-balance) (- account-balance amount))) (account-withdraw 5 12)))
  262. Test end:
  263. result-kind: pass
  264. actual-value: 7
  265. expected-value: 7
  266. Test begin:
  267. test-name: "define-with-contract - simple number contract works"
  268. source-file: "test.scm"
  269. source-line: 446
  270. source-form: (test-assert "define-with-contract - simple number contract works" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw)) (exception-with-irritants? exn) (equal? (quote (<= amount account-balance)) (exception-irritants exn))) #t)) (begin (define-with-contract account-withdraw (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (λ (amount account-balance) (- account-balance amount))) (account-withdraw 100 90))))
  271. Test end:
  272. result-kind: pass
  273. actual-value: #t
  274. Test begin:
  275. test-name: "define-with-contract - simple number contract works with negative numbers"
  276. source-file: "test.scm"
  277. source-line: 471
  278. source-form: (test-assert "define-with-contract - simple number contract works with negative numbers" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw)) (exception-with-irritants? exn) (equal? (quote (>= amount 0)) (exception-irritants exn))) #t)) (begin (define-with-contract account-withdraw (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (λ (amount account-balance) (- account-balance amount))) (account-withdraw -15 -10))))
  279. Test end:
  280. result-kind: pass
  281. actual-value: #t
  282. Group end: define-with-contract
  283. Group begin: define*-with-contract
  284. Test begin:
  285. test-name: "define*-with-contract - does not raise an exception when not violated - long form"
  286. source-file: "test.scm"
  287. source-line: 497
  288. source-form: (test-eqv "define*-with-contract - does not raise an exception when not violated - long form" 55 (begin (define*-with-contract account-withdraw (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance #:optional (fee 0) #:key (tip 10)) (- account-balance amount fee tip)) (account-withdraw 50 120 5 #:tip 10)))
  289. Test end:
  290. result-kind: pass
  291. actual-value: 55
  292. expected-value: 55
  293. Test begin:
  294. test-name: "define*-with-contract - does not raise an exception when not violated - short form"
  295. source-file: "test.scm"
  296. source-line: 511
  297. source-form: (test-eqv "define*-with-contract - does not raise an exception when not violated - short form" 55 (begin (define*-with-contract (account-withdraw amount account-balance #:optional (fee 0) #:key (tip 10)) (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (- account-balance amount fee tip)) (account-withdraw 50 120 5 #:tip 10)))
  298. Test end:
  299. result-kind: pass
  300. actual-value: 55
  301. expected-value: 55
  302. Test begin:
  303. test-name: "define*-with-contract - simple number contract works"
  304. source-file: "test.scm"
  305. source-line: 527
  306. source-form: (test-assert "define*-with-contract - simple number contract works" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw-extra)) (exception-with-irritants? exn) (equal? (quote (>= result 0)) (exception-irritants exn))) #t)) (begin (define*-with-contract account-withdraw-extra (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance #:optional (fee 0) #:key (tip 10)) (- account-balance amount fee tip)) (account-withdraw-extra 50 90 30 #:tip 15))))
  307. Test end:
  308. result-kind: pass
  309. actual-value: #t
  310. Test begin:
  311. test-name: "define*-with-contract - number contract works with negative numbers"
  312. source-file: "test.scm"
  313. source-line: 555
  314. source-form: (test-assert "define*-with-contract - number contract works with negative numbers" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw-extra)) (exception-with-irritants? exn) (equal? (quote (>= result 0)) (exception-irritants exn))) #t)) (begin (define*-with-contract account-withdraw-extra (require (<= amount account-balance)) (ensure (>= <?> 0)) (amount account-balance #:optional (fee 0) #:key (tip 10)) (- account-balance amount fee tip)) (account-withdraw-extra -20 10 30 #:tip 1))))
  315. Test end:
  316. result-kind: pass
  317. actual-value: #t
  318. Group end: define*-with-contract
  319. Group begin: lambda-aliases
  320. Test begin:
  321. test-name: "λ*-with-contract - contract does not raise an exception when not violated"
  322. source-file: "test.scm"
  323. source-line: 583
  324. source-form: (test-equal "λ*-with-contract - contract does not raise an exception when not violated" "00234" ((λ*-with-contract (require (integer? num) (char? padding-char) (integer? padding-length) (or (positive? padding-length) (zero? padding-length))) (ensure (string? <?>) (>= (string-length <?>) padding-length)) (num padding-char padding-length) (let* ((num-as-str (number->string num)) (len-diff (- padding-length (string-length num-as-str)))) (cond ((positive? len-diff) (call-with-output-string (λ (port) (let iter ((counter 0)) (cond ((< counter len-diff) (display padding-char port) (iter (+ counter 1))) (else (display num-as-str port))))))) (else num-as-str)))) 234 #\0 5))
  325. Test end:
  326. result-kind: pass
  327. actual-value: "00234"
  328. expected-value: "00234"
  329. Test begin:
  330. test-name: "λ-with-contract - contract does not raise an exception when not violated"
  331. source-file: "test.scm"
  332. source-line: 610
  333. source-form: (test-eqv "λ-with-contract - contract does not raise an exception when not violated" 7 ((λ-with-contract (require (<= amount account-balance) (>= amount 0)) (ensure (>= <?> 0)) (amount account-balance) (- account-balance amount)) 5 12))
  334. Test end:
  335. result-kind: pass
  336. actual-value: 7
  337. expected-value: 7
  338. Group end: lambda-aliases
  339. Group begin: rest-argument-definitions
  340. Test begin:
  341. test-name: "define-with-contract - with rest args - contract does not raise an exception when not violated"
  342. source-file: "test.scm"
  343. source-line: 620
  344. source-form: (test-equal "define-with-contract - with rest args - contract does not raise an exception when not violated" 5 (begin (define-with-contract account-withdraw (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance . other-fees) (apply - account-balance amount other-fees)) (account-withdraw 40 100 50 5)))
  345. Test end:
  346. result-kind: pass
  347. actual-value: 5
  348. expected-value: 5
  349. Test begin:
  350. test-name: "define*-with-contract - with rest args - contract does not raise an exception when not violated"
  351. source-file: "test.scm"
  352. source-line: 634
  353. source-form: (test-equal "define*-with-contract - with rest args - contract does not raise an exception when not violated" 10 (begin (define*-with-contract account-withdraw (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance #:optional (fee1 5) #:key (fee2 10) . other-fees) (apply - account-balance amount fee1 fee2 other-fees)) (account-withdraw 40 100 30 1 2 3 4)))
  354. Test end:
  355. result-kind: pass
  356. actual-value: 10
  357. expected-value: 10
  358. Test begin:
  359. test-name: "define*-with-contract - with rest args - raises for require violation"
  360. source-file: "test.scm"
  361. source-line: 653
  362. source-form: (test-assert "define*-with-contract - with rest args - raises for require violation" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw)) (exception-with-irritants? exn) (equal? (quote (<= amount account-balance)) (exception-irritants exn))) #t)) (begin (define*-with-contract account-withdraw (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance #:optional (fee1 5) #:key (fee2 10) . other-fees) (apply - account-balance amount fee1 fee2 other-fees)) (account-withdraw 400 100))))
  363. Test end:
  364. result-kind: pass
  365. actual-value: #t
  366. Test begin:
  367. test-name: "define*-with-contract - with rest args - raises for ensure violation"
  368. source-file: "test.scm"
  369. source-line: 686
  370. source-form: (test-assert "define*-with-contract - with rest args - raises for ensure violation" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw)) (exception-with-irritants? exn) (equal? (quote (>= result 0)) (exception-irritants exn))) #t)) (begin (define*-with-contract account-withdraw (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance #:optional (fee1 5) #:key (fee2 10) . other-fees) (apply - account-balance amount fee1 fee2 200 other-fees)) (account-withdraw 50 100))))
  371. Test end:
  372. result-kind: pass
  373. actual-value: #t
  374. Test begin:
  375. test-name: "define*-with-contract - with rest args - raises for violation of rest args"
  376. source-file: "test.scm"
  377. source-line: 720
  378. source-form: (test-assert "define*-with-contract - with rest args - raises for violation of rest args" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) (quote account-withdraw)) (exception-with-irritants? exn) (equal? (quote (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (exception-irritants exn))) #t)) (begin (define*-with-contract account-withdraw (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance #:optional (fee1 5) #:key (fee2 10) . other-fees) (apply - account-balance amount fee1 fee2 200 other-fees)) (account-withdraw 50 100 1 2 3 4 -5))))
  379. Test end:
  380. result-kind: pass
  381. actual-value: #t
  382. Test begin:
  383. test-name: "lambda*-with-contract - with rest args - works"
  384. source-file: "test.scm"
  385. source-line: 757
  386. source-form: (test-assert "lambda*-with-contract - with rest args - works" (guard (exn ((and (contract-violated-exception? exn) (exception-with-message? exn) (string=? (exception-message exn) "contract violated") (exception-with-origin? exn) (eq? (exception-origin exn) "unknown origin") (exception-with-irritants? exn) (equal? (quote (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (exception-irritants exn))) #t)) ((lambda*-with-contract (require (<= amount account-balance) (fold (λ (current accumulated) (and accumulated current)) #t (map positive? other-fees))) (ensure (>= <?> 0)) (amount account-balance #:optional (fee1 5) #:key (fee2 10) . other-fees) (apply - account-balance amount other-fees)) 50 100 1 2 3 4 -5)))
  387. Test end:
  388. result-kind: pass
  389. actual-value: #t
  390. Group end: rest-argument-definitions
  391. Group end: contract
  392. Group end: test
  393. # of expected passes 43