forked from exercism/scheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ss
36 lines (31 loc) · 1.08 KB
/
test.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(define (parse-test test)
`(test-success ,(lookup 'description test)
equal?
pascals-triangle
'(,(cdar (lookup 'input test)))
',(lookup 'expected test)))
(define (test-2^n n)
`(test-success "all rows sum to power of 2"
(lambda (n ignore)
(null?
(filter not
(map (lambda (row)
(= 1 (bitwise-bit-count (apply + row))))
(pascals-triangle n)))))
(lambda (x) x)
'(,n)
'ignore))
(define (spec->tests spec)
(map parse-test
(lookup 'cases
(car
(lookup 'cases spec)))))
(let ((spec (get-test-specification 'pascals-triangle)))
(put-problem!
'pascals-triangle
`((test . ,(spec->tests spec))
(stubs pascals-triangle)
(version . ,(lookup 'version spec))
(skeleton . "pascals-triangle.scm")
(solution . "example.scm")
(markdown . ,(splice-exercism 'pascals-triangle)))))