forked from ericclack/racket-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearn-music-phrase1-tests.rkt
52 lines (46 loc) · 1.64 KB
/
learn-music-phrase1-tests.rkt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#lang racket
(require rackunit "learn-music-phrase1.rkt")
(require "util.rkt")
(require/expose "learn-music-phrase1.rkt" (NOTES random-note-phrase-123
random-note-phrase-135
random-note-phrase pick-notes
note-index world))
(test-case
"tests for random-note-phrase-123"
(check-true (list? (random-note-phrase-123)))
(times-repeat 100 (check-equal? (length (random-note-phrase-123)) 3))
(let* ((phrase (random-note-phrase-123))
(n1 (first phrase))
(n2 (second phrase))
(n3 (third phrase)))
(check-true (and (= (note-index n1)
(- (note-index n2) 1)
(- (note-index n3) 2)))))
)
(test-case
"tests for random-note-phrase-135"
(check-true (list? (random-note-phrase-135)))
(times-repeat 100 (check-equal? (length (random-note-phrase-135)) 3))
(let* ((phrase (random-note-phrase-135))
(n1 (first phrase))
(n2 (second phrase))
(n3 (third phrase)))
(check-true (and (= (note-index n1)
(- (note-index n2) 2)
(- (note-index n3) 4)))))
)
(test-case
"tests for every-other"
(check-equal? (every-other '(a b c d e f))
'(a c e))
(check-equal? (every-other '(a b c d e f g))
'(a c e g))
(check-equal? (every-other '()) '())
(check-equal? (every-other '(a)) '(a)))
(test-case
"tests for pick-notes"
(check-equal? (pick-notes '(1 3 5) '(a b c d e f))
'(a c e)))
(test-case
"tests for random-note-phrase"
(check-true (list? (random-note-phrase '(1 5 7)))))