summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unheard/cycles_test.clj238
-rw-r--r--test/unheard/strudel/mini_notation_compiler_test.clj135
2 files changed, 93 insertions, 280 deletions
diff --git a/test/unheard/cycles_test.clj b/test/unheard/cycles_test.clj
index c395755..552b6e9 100644
--- a/test/unheard/cycles_test.clj
+++ b/test/unheard/cycles_test.clj
@@ -3,278 +3,160 @@
[unheard.cycles :refer [l f p rate elongate rep paste unfold]]))
(deftest unfold-tests
- (testing "single scalar"
- (is (= [[0 1 :a]]
- (unfold 1 :a))))
-
+ (testing "single scalar" (is (= [[0 1 :a]] (unfold 1 :a))))
(testing "simple list - time subdivision"
- (is (= [[0 1/3 :a] [1/3 2/3 :b] [2/3 1 :c]]
- (unfold 1 (l :a :b :c)))))
-
+ (is (= [[0 1/3 :a] [1/3 2/3 :b] [2/3 1 :c]] (unfold 1 (l :a :b :c)))))
(testing "simple fork - cycles through children"
- (is (= [[0 1 :a]
- [1 2 :b]
- [2 3 :c]]
- (unfold 1 (f :a :b :c)))))
-
+ (is (= [[0 1 :a] [1 2 :b] [2 3 :c]] (unfold 1 (f :a :b :c)))))
(testing "list with fork - fork gets time slice"
- (is (= [[0 1/2 :1] [1/2 1 :2]
- [1 3/2 :1] [3/2 2 :3]]
+ (is (= [[0 1/2 :1] [1/2 1 :2] [1 3/2 :1] [3/2 2 :3]]
(unfold 1 (l :1 (f :2 :3))))))
-
(testing "fork with list - each child subdivides its cycle"
- (is (= [[0 1/2 :a] [1/2 1 :b]
- [1 2 :c]]
- (unfold 1 (f (l :a :b) :c)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :b] [1 2 :c]] (unfold 1 (f (l :a :b) :c)))))
(testing "nested lists"
- (is (= [[0 1/2 :a] [1/2 3/4 :b] [3/4 1 :c]]
- (unfold 1 (l :a (l :b :c))))))
-
+ (is (= [[0 1/2 :a] [1/2 3/4 :b] [3/4 1 :c]] (unfold 1 (l :a (l :b :c))))))
(testing "nested forks"
- (is (= [[0 1 :a]
- [1 2 :b]
- [2 3 :c]
- [3 4 :d]
- [4 5 :a]
- [5 6 :e]
- [6 7 :c]
+ (is (= [[0 1 :a] [1 2 :b] [2 3 :c] [3 4 :d] [4 5 :a] [5 6 :e] [6 7 :c]
[7 8 :d]]
(unfold 1 (f :a (f :b :e) :c :d)))))
-
(testing "complex nested structure from example"
- (is (= [[0 1/2 :1] [1/2 3/4 :2] [3/4 1 :9] [1 3/2 :6] [3/2 2 :7]
- [2 5/2 :1] [5/2 3 :3] [3 7/2 :6] [7/2 4 :8]
- [4 9/2 :1] [9/2 5 :4] [5 11/2 :6] [11/2 6 :7]
- [6 13/2 :1] [13/2 27/4 :2] [27/4 7 :9] [7 15/2 :6] [15/2 8 :8]
- [8 17/2 :1] [17/2 9 :3] [9 19/2 :6] [19/2 10 :7]
+ (is (= [[0 1/2 :1] [1/2 3/4 :2] [3/4 1 :9] [1 3/2 :6] [3/2 2 :7] [2 5/2 :1]
+ [5/2 3 :3] [3 7/2 :6] [7/2 4 :8] [4 9/2 :1] [9/2 5 :4] [5 11/2 :6]
+ [11/2 6 :7] [6 13/2 :1] [13/2 27/4 :2] [27/4 7 :9] [7 15/2 :6]
+ [15/2 8 :8] [8 17/2 :1] [17/2 9 :3] [9 19/2 :6] [19/2 10 :7]
[10 21/2 :1] [21/2 11 :5] [11 23/2 :6] [23/2 12 :8]]
(unfold 2 (l :1 (f (l :2 :9) :3 (f :4 :5)) :6 (f :7 :8))))))
-
(testing "different cycle lengths"
- (is (= [[0 1/2 :a] [1/2 1 :b]]
- (unfold 1 (l :a :b))))
- (is (= [[0 1 :a] [1 2 :b]]
- (unfold 2 (l :a :b))))
- (is (= [[0 5/2 :a] [5/2 5 :b]]
- (unfold 5 (l :a :b)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :b]] (unfold 1 (l :a :b))))
+ (is (= [[0 1 :a] [1 2 :b]] (unfold 2 (l :a :b))))
+ (is (= [[0 5/2 :a] [5/2 5 :b]] (unfold 5 (l :a :b)))))
(testing "fork with nested list subdivides correctly"
- (is (= [[0 1/3 :a] [1/3 2/3 :b] [2/3 1 :c]
- [1 2 :x]]
+ (is (= [[0 1/3 :a] [1/3 2/3 :b] [2/3 1 :c] [1 2 :x]]
(unfold 1 (f (l :a :b :c) :x)))))
-
(testing "simple parallel - all children at same time"
- (is (= [[0 1 :a] [0 1 :b] [0 1 :c]]
- (unfold 1 (p :a :b :c)))))
-
+ (is (= [[0 1 :a] [0 1 :b] [0 1 :c]] (unfold 1 (p :a :b :c)))))
(testing "parallel with list - children subdivide in parallel"
- (is (= [[0 1/2 :a] [1/2 1 :b]
- [0 1/2 :c] [1/2 1 :d]]
+ (is (= [[0 1/2 :a] [1/2 1 :b] [0 1/2 :c] [1/2 1 :d]]
(unfold 1 (p (l :a :b) (l :c :d))))))
-
(testing "parallel with fork - forks extend together"
- (is (= [[0 1 :a] [0 1 :c]
- [1 2 :b] [1 2 :d]]
+ (is (= [[0 1 :a] [0 1 :c] [1 2 :b] [1 2 :d]]
(unfold 1 (p (f :a :b) (f :c :d))))))
-
(testing "list containing parallel"
- (is (= [[0 1/2 :x] [0 1/2 :y]
- [1/2 1 :z]]
- (unfold 1 (l (p :x :y) :z)))))
-
+ (is (= [[0 1/2 :x] [0 1/2 :y] [1/2 1 :z]] (unfold 1 (l (p :x :y) :z)))))
(testing "parallel with different cycle lengths"
- (is (= [[0 1 :a] [0 1 :b]
- [1 2 :a] [1 2 :c]]
- (unfold 1 (p :a (f :b :c))))))
-
+ (is (= [[0 1 :a] [0 1 :b] [1 2 :a] [1 2 :c]] (unfold 1 (p :a (f :b :c))))))
(testing "rate 2 - doubles speed of scalar"
- (is (= [[0 1/2 :a] [1/2 1 :a]]
- (unfold 1 (rate 2 :a)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :a]] (unfold 1 (rate 2 :a)))))
(testing "rate 1/2 - halves speed of scalar"
- (is (= [[0 2 :a]]
- (unfold 1 (rate 1/2 :a)))))
-
+ (is (= [[0 2 :a]] (unfold 1 (rate 1/2 :a)))))
(testing "rate 2 - doubles speed of list"
- (is (= [[0 1/6 :a] [1/6 1/3 :b] [1/3 1/2 :c]
- [1/2 2/3 :a] [2/3 5/6 :b] [5/6 1 :c]]
+ (is (= [[0 1/6 :a] [1/6 1/3 :b] [1/3 1/2 :c] [1/2 2/3 :a] [2/3 5/6 :b]
+ [5/6 1 :c]]
(unfold 1 (rate 2 (l :a :b :c))))))
-
(testing "rate 1/2 - halves speed of list"
- (is (= [[0 1 :a] [1 2 :b]]
- (unfold 1 (rate 1/2 (l :a :b))))))
-
+ (is (= [[0 1 :a] [1 2 :b]] (unfold 1 (rate 1/2 (l :a :b))))))
(testing "rate 2 - doubles speed of fork"
- ;; Fork has 3 children, cycle count is 3
- ;; rate 2 makes it repeat 2x, so 6 total cycles
- (is (= [[0 1/6 :a] [1/6 1/3 :b] [1/3 1/2 :c]
- [1/2 2/3 :a] [2/3 5/6 :b] [5/6 1 :c]
- [1 7/6 :a] [7/6 4/3 :b] [4/3 3/2 :c]
- [3/2 5/3 :a] [5/3 11/6 :b] [11/6 2 :c]
- [2 13/6 :a] [13/6 7/3 :b] [7/3 5/2 :c]
+ ;; Fork has 3 children, cycle count is 3 rate 2 makes it repeat 2x, so
+ ;; 6 total cycles
+ (is (= [[0 1/6 :a] [1/6 1/3 :b] [1/3 1/2 :c] [1/2 2/3 :a] [2/3 5/6 :b]
+ [5/6 1 :c] [1 7/6 :a] [7/6 4/3 :b] [4/3 3/2 :c] [3/2 5/3 :a]
+ [5/3 11/6 :b] [11/6 2 :c] [2 13/6 :a] [13/6 7/3 :b] [7/3 5/2 :c]
[5/2 8/3 :a] [8/3 17/6 :b] [17/6 3 :c]]
(unfold 1 (rate 2 (f :a :b :c))))))
-
(testing "rate with parallel"
;; Parallel has cycle 1, rate 2 repeats it twice
- (is (= [[0 1/2 :a] [0 1/2 :b]
- [1/2 1 :a] [1/2 1 :b]]
+ (is (= [[0 1/2 :a] [0 1/2 :b] [1/2 1 :a] [1/2 1 :b]]
(unfold 1 (rate 2 (p :a :b))))))
-
(testing "rate inside list"
- (is (= [[0 1/2 :x] [1/2 3/4 :y] [3/4 1 :y]]
- (unfold 1 (l :x (rate 2 :y))))))
-
+ (is (= [[0 1/2 :x] [1/2 3/4 :y] [3/4 1 :y]] (unfold 1 (l :x (rate 2 :y))))))
(testing "nested rates"
(is (= [[0 1/4 :a] [1/4 1/2 :a] [1/2 3/4 :a] [3/4 1 :a]]
(unfold 1 (rate 2 (rate 2 :a))))))
-
(testing "elongate 2 - element takes twice as long"
(is (= [[0 1/2 :a] [1/2 3/4 :b] [3/4 1 :c]]
(unfold 1 (l (elongate 2 :a) :b :c)))))
-
(testing "elongate 3 - element takes three times as long"
(is (= [[0 3/5 :a] [3/5 4/5 :b] [4/5 1 :c]]
(unfold 1 (l (elongate 3 :a) :b :c)))))
-
(testing "multiple elongations"
(is (= [[0 2/5 :a] [2/5 4/5 :b] [4/5 1 :c]]
(unfold 1 (l (elongate 2 :a) (elongate 2 :b) :c)))))
-
(testing "elongate with fork"
- (is (= [[0 1 :a] [1 2 :b]]
- (unfold 1 (f (elongate 2 :a) :b)))))
-
+ (is (= [[0 1 :a] [1 2 :b]] (unfold 1 (f (elongate 2 :a) :b)))))
(testing "elongate inside parallel"
- (is (= [[0 1 :a] [0 1 :b]]
- (unfold 1 (p (elongate 2 :a) :b)))))
-
+ (is (= [[0 1 :a] [0 1 :b]] (unfold 1 (p (elongate 2 :a) :b)))))
(testing "elongate with rate"
- (is (= [[0 1/2 :a] [1/2 1 :a]]
- (unfold 1 (elongate 2 (rate 2 :a))))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :a]] (unfold 1 (elongate 2 (rate 2 :a))))))
(testing "rate with elongate inside list"
- (is (= [[0 1/4 :a] [1/4 3/8 :b] [3/8 1/2 :c]
- [1/2 3/4 :a] [3/4 7/8 :b] [7/8 1 :c]]
+ (is (= [[0 1/4 :a] [1/4 3/8 :b] [3/8 1/2 :c] [1/2 3/4 :a] [3/4 7/8 :b]
+ [7/8 1 :c]]
(unfold 1 (rate 2 (l (elongate 2 :a) :b :c))))))
-
(testing "rep 2 - element repeats twice"
- (is (= [[0 1/2 :a] [1/2 1 :a]]
- (unfold 1 (rep 2 :a)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :a]] (unfold 1 (rep 2 :a)))))
(testing "rep 3 - element repeats three times"
- (is (= [[0 1/3 :a] [1/3 2/3 :a] [2/3 1 :a]]
- (unfold 1 (rep 3 :a)))))
-
+ (is (= [[0 1/3 :a] [1/3 2/3 :a] [2/3 1 :a]] (unfold 1 (rep 3 :a)))))
(testing "rep in list - subdivides its time slot"
- (is (= [[0 1/6 :a] [1/6 1/3 :a] [1/3 1/2 :a]
- [1/2 1 :b]]
+ (is (= [[0 1/6 :a] [1/6 1/3 :a] [1/3 1/2 :a] [1/2 1 :b]]
(unfold 1 (l (rep 3 :a) :b)))))
-
(testing "rep with three elements in list"
- (is (= [[0 1/6 :x] [1/6 1/3 :x]
- [1/3 2/3 :y]
- [2/3 1 :z]]
+ (is (= [[0 1/6 :x] [1/6 1/3 :x] [1/3 2/3 :y] [2/3 1 :z]]
(unfold 1 (l (rep 2 :x) :y :z)))))
-
(testing "multiple reps in list"
- (is (= [[0 1/6 :a] [1/6 1/3 :a]
- [1/3 1/2 :b] [1/2 2/3 :b]
- [2/3 1 :c]]
+ (is (= [[0 1/6 :a] [1/6 1/3 :a] [1/3 1/2 :b] [1/2 2/3 :b] [2/3 1 :c]]
(unfold 1 (l (rep 2 :a) (rep 2 :b) :c)))))
-
(testing "rep with fork"
- (is (= [[0 1/2 :a] [1/2 1 :a]
- [1 2 :b]]
- (unfold 1 (f (rep 2 :a) :b)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :a] [1 2 :b]] (unfold 1 (f (rep 2 :a) :b)))))
(testing "rep inside parallel"
- (is (= [[0 1/2 :a] [1/2 1 :a]
- [0 1 :b]]
- (unfold 1 (p (rep 2 :a) :b)))))
-
+ (is (= [[0 1/2 :a] [1/2 1 :a] [0 1 :b]] (unfold 1 (p (rep 2 :a) :b)))))
(testing "rep with rate"
- (is (= [[0 1/4 :a] [1/4 1/2 :a]
- [1/2 3/4 :a] [3/4 1 :a]]
+ (is (= [[0 1/4 :a] [1/4 1/2 :a] [1/2 3/4 :a] [3/4 1 :a]]
(unfold 1 (rep 2 (rate 2 :a))))))
-
(testing "rate with rep inside"
- (is (= [[0 1/4 :a] [1/4 1/2 :a]
- [1/2 3/4 :a] [3/4 1 :a]]
+ (is (= [[0 1/4 :a] [1/4 1/2 :a] [1/2 3/4 :a] [3/4 1 :a]]
(unfold 1 (rate 2 (rep 2 :a))))))
-
(testing "rep in list without elongate"
- (is (= [[0 1/6 :a] [1/6 1/3 :a]
- [1/3 2/3 :b]
- [2/3 1 :c]]
+ (is (= [[0 1/6 :a] [1/6 1/3 :a] [1/3 2/3 :b] [2/3 1 :c]]
(unfold 1 (l (rep 2 :a) :b :c)))))
-
(testing "elongate and rep together"
- (is (= [[0 1/6 :a] [1/6 1/3 :a]
- [1/3 2/3 :b]
- [2/3 1 :c]]
+ (is (= [[0 1/6 :a] [1/6 1/3 :a] [1/3 2/3 :b] [2/3 1 :c]]
(unfold 1 (l (rep 2 (elongate 2 :a)) :b :c)))))
-
(testing "rep of list"
- (is (= [[0 1/4 :a] [1/4 1/2 :b]
- [1/2 3/4 :a] [3/4 1 :b]]
+ (is (= [[0 1/4 :a] [1/4 1/2 :b] [1/2 3/4 :a] [3/4 1 :b]]
(unfold 1 (rep 2 (l :a :b))))))
-
(testing "paste - simple replacement in list"
- (is (= (l :a :b :c)
- (paste (l :_ :_ :_) :a :b :c))))
-
+ (is (= (l :a :b :c) (paste (l :_ :_ :_) :a :b :c))))
(testing "paste - simple replacement in fork"
(is (= (f :c (f :e :g) :b :d)
(paste (f :_ (f :_ :_) :_ :_) :c :e :g :b :d))))
-
(testing "paste - with nil preserves original"
(is (= (f :c (f :e :_) :b :d)
(paste (f :_ (f :_ :_) :_ :_) :c :e nil :b :d))))
-
(testing "paste - multiple nils"
(is (= (f :_ (f :e :_) :b :_)
(paste (f :_ (f :_ :_) :_ :_) nil :e nil :b nil))))
-
(testing "paste - with numbers as template"
- (is (= (l :a :b :c)
- (paste (l 1 2 1) :a :b :c))))
-
+ (is (= (l :a :b :c) (paste (l 1 2 1) :a :b :c))))
(testing "paste - nested structures"
- (is (= (l :x (l :y :z) :w)
- (paste (l :_ (l :_ :_) :_) :x :y :z :w))))
-
+ (is (= (l :x (l :y :z) :w) (paste (l :_ (l :_ :_) :_) :x :y :z :w))))
(testing "paste - with parallel"
- (is (= (p :a :b :c)
- (paste (p :_ :_ :_) :a :b :c))))
-
+ (is (= (p :a :b :c) (paste (p :_ :_ :_) :a :b :c))))
(testing "paste - complex nested with parallel"
- (is (= (l :a (p :b :c) :d)
- (paste (l :_ (p :_ :_) :_) :a :b :c :d))))
-
+ (is (= (l :a (p :b :c) :d) (paste (l :_ (p :_ :_) :_) :a :b :c :d))))
(testing "paste - with modifiers preserved"
- (is (= (l (rate 2 :a) :b)
- (paste (l (rate 2 :_) :_) :a :b))))
-
+ (is (= (l (rate 2 :a) :b) (paste (l (rate 2 :_) :_) :a :b))))
(testing "paste - with elongate"
(is (= (l (elongate 2 :x) :y :z)
(paste (l (elongate 2 :_) :_ :_) :x :y :z))))
-
(testing "paste - with rep"
- (is (= (l (rep 3 :a) :b)
- (paste (l (rep 3 :_) :_) :a :b))))
-
+ (is (= (l (rep 3 :a) :b) (paste (l (rep 3 :_) :_) :a :b))))
(testing "paste - unfolds correctly"
(is (= [[0 1/3 :c] [1/3 2/3 :e] [2/3 1 :g]]
(unfold 1 (paste (l :_ :_ :_) :c :e :g)))))
-
(testing "paste - complex rhythm unfolds correctly"
- (is (= [[0 1 :c] [1 2 :e] [2 3 :b] [3 4 :d]
- [4 5 :c] [5 6 :g] [6 7 :b] [7 8 :d]]
+ (is (= [[0 1 :c] [1 2 :e] [2 3 :b] [3 4 :d] [4 5 :c] [5 6 :g] [6 7 :b]
+ [7 8 :d]]
(unfold 1 (paste (f :_ (f :_ :_) :_ :_) :c :e :g :b :d)))))
-
(testing "paste - with nil unfolds correctly"
- (is (= [[0 1 :c] [1 2 :e] [2 3 :b] [3 4 :d]
- [4 5 :c] [5 6 :_] [6 7 :b] [7 8 :d]]
+ (is (= [[0 1 :c] [1 2 :e] [2 3 :b] [3 4 :d] [4 5 :c] [5 6 :_] [6 7 :b]
+ [7 8 :d]]
(unfold 1 (paste (f :_ (f :_ :_) :_ :_) :c :e nil :b :d))))))
diff --git a/test/unheard/strudel/mini_notation_compiler_test.clj b/test/unheard/strudel/mini_notation_compiler_test.clj
index 184a9ea..38ae8be 100644
--- a/test/unheard/strudel/mini_notation_compiler_test.clj
+++ b/test/unheard/strudel/mini_notation_compiler_test.clj
@@ -4,154 +4,85 @@
[unheard.strudel.mini-notation-compiler :refer [compile]]))
(deftest compile-tests
- (testing "single atom"
- (is (= :c
- (compile "c" keyword))))
-
- (testing "rest literal"
- (is (= :r
- (compile "~" keyword))))
-
+ (testing "single atom" (is (= :c (compile "c" keyword))))
+ (testing "rest literal" (is (= :r (compile "~" keyword))))
(testing "simple sequence - space separated"
- (is (= '(l :c :e :g)
- (compile "c e g" keyword))))
-
+ (is (= '(l :c :e :g) (compile "c e g" keyword))))
(testing "sequence with rest"
- (is (= '(l :c :r :g)
- (compile "c ~ g" keyword))))
-
+ (is (= '(l :c :r :g) (compile "c ~ g" keyword))))
(testing "subdivision with brackets"
- (is (= '(l :c (l :e :g) :b)
- (compile "c [e g] b" keyword))))
-
+ (is (= '(l :c (l :e :g) :b) (compile "c [e g] b" keyword))))
(testing "nested brackets"
- (is (= '(l :a (l :b (l :c :d)))
- (compile "a [b [c d]]" keyword))))
-
+ (is (= '(l :a (l :b (l :c :d))) (compile "a [b [c d]]" keyword))))
(testing "angle brackets - alternation"
- (is (= '(f :c :e :g :b)
- (compile "<c e g b>" keyword))))
-
+ (is (= '(f :c :e :g :b) (compile "<c e g b>" keyword))))
(testing "parallel with commas"
- (is (= '(p :c :e :g)
- (compile "c,e,g" keyword))))
-
+ (is (= '(p :c :e :g) (compile "c,e,g" keyword))))
(testing "parallel in sequence"
- (is (= '(l (p :c :e :g) (p :d :f :a))
- (compile "[c,e,g] [d,f,a]" keyword))))
-
+ (is (= '(l (p :c :e :g) (p :d :f :a)) (compile "[c,e,g] [d,f,a]" keyword))))
(testing "rate modifier - multiplication"
- (is (= '(rate 2 :c)
- (compile "c*2" keyword))))
-
+ (is (= '(rate 2 :c) (compile "c*2" keyword))))
(testing "rate modifier - division"
- (is (= '(rate (/ 1 2) :c)
- (compile "c/2" keyword))))
-
+ (is (= '(rate (/ 1 2) :c) (compile "c/2" keyword))))
(testing "rate on group"
- (is (= '(rate 2 (l :e :g))
- (compile "[e g]*2" keyword))))
-
+ (is (= '(rate 2 (l :e :g)) (compile "[e g]*2" keyword))))
(testing "rate on alternation"
- (is (= '(rate 2 (f :c :e :g :b))
- (compile "<c e g b>*2" keyword))))
-
+ (is (= '(rate 2 (f :c :e :g :b)) (compile "<c e g b>*2" keyword))))
(testing "elongate modifier"
- (is (= '(elongate 3 :c)
- (compile "c@3" keyword))))
-
+ (is (= '(elongate 3 :c) (compile "c@3" keyword))))
(testing "elongate in sequence"
- (is (= '(l (elongate 2 :a) :b :c)
- (compile "a@2 b c" keyword))))
-
- (testing "replication modifier"
- (is (= '(rep 3 :c)
- (compile "c!3" keyword))))
-
+ (is (= '(l (elongate 2 :a) :b :c) (compile "a@2 b c" keyword))))
+ (testing "replication modifier" (is (= '(rep 3 :c) (compile "c!3" keyword))))
(testing "replication in sequence"
- (is (= '(l (rep 2 :x) :y)
- (compile "x!2 y" keyword))))
-
+ (is (= '(l (rep 2 :x) :y) (compile "x!2 y" keyword))))
(testing "multiple modifiers"
- (is (= '(rate 2 (elongate 3 :c))
- (compile "c@3*2" keyword))))
-
+ (is (= '(rate 2 (elongate 3 :c)) (compile "c@3*2" keyword))))
(testing "complex nested structure"
- (is (= '(l :c (f :e :g) :b :d)
- (compile "c <e g> b d" keyword))))
-
+ (is (= '(l :c (f :e :g) :b :d) (compile "c <e g> b d" keyword))))
(testing "subdivision with parallel"
- (is (= '(l :x (p :y :z) :w)
- (compile "x [y,z] w" keyword))))
-
+ (is (= '(l :x (p :y :z) :w) (compile "x [y,z] w" keyword))))
(testing "strudel example from docs"
(is (= '(l :e5 (l :b4 :c5) :d5 (l :c5 :b4))
(compile "e5 [b4 c5] d5 [c5 b4]" keyword))))
-
(testing "chord sequence"
(is (= '(rate 2 (f (p :g3 :b3 :e4) (p :a3 :c3 :e4)))
(compile "<[g3,b3,e4] [a3,c3,e4]>*2" keyword))))
-
(testing "elongated chord"
(is (= '(rate 2 (f (elongate 2 (p :g3 :b3 :e4)) (p :a3 :c3 :e4)))
(compile "<[g3,b3,e4]@2 [a3,c3,e4]>*2" keyword))))
-
(testing "replicated chord"
(is (= '(rate 2 (f (rep 2 (p :g3 :b3 :e4)) (p :a3 :c3 :e4)))
(compile "<[g3,b3,e4]!2 [a3,c3,e4]>*2" keyword))))
-
(testing "rest in subdivision"
- (is (= '(l :b4 (l :r :c5) :d5 :e5)
- (compile "b4 [~ c5] d5 e5" keyword))))
-
- (testing "numbers as values"
- (is (= '(l 1 2 3)
- (compile "1 2 3" keyword))))
-
+ (is (= '(l :b4 (l :r :c5) :d5 :e5) (compile "b4 [~ c5] d5 e5" keyword))))
+ (testing "numbers as values" (is (= '(l 1 2 3) (compile "1 2 3" keyword))))
(testing "rational number rate"
- (is (= '(rate 3/2 :c)
- (compile "c*3/2" keyword))))
-
+ (is (= '(rate 3/2 :c) (compile "c*3/2" keyword))))
(testing "whitespace handling"
- (is (= '(l :a :b :c)
- (compile " a b c " keyword))))
-
+ (is (= '(l :a :b :c) (compile " a b c " keyword))))
(testing "complex real-world pattern"
(is (= '(l (rate 2 (f :bd :sd)) (p :hat :hat :hat))
(compile "<bd sd>*2 [hat,hat,hat]" keyword))))
-
(testing "newlines are converted to spaces"
- (is (= '(f :a :b :c :d)
- (compile "<a b\nc d>" keyword))))
-
+ (is (= '(f :a :b :c :d) (compile "<a b\nc d>" keyword))))
(testing "multi-line pattern with parallel"
- (is (= '(f (l :a :b) (p :c :d))
- (compile "<\n[a b]\n[c,d]\n>" keyword))))
-
+ (is (= '(f (l :a :b) (p :c :d)) (compile "<\n[a b]\n[c,d]\n>" keyword))))
(testing "polymeter - comma creates parallel of forks"
- (is (= '(p (f :a :b) (f :c :d))
- (compile "<a b, c d>" keyword))))
-
+ (is (= '(p (f :a :b) (f :c :d)) (compile "<a b, c d>" keyword))))
(testing "polymeter - three groups"
(is (= '(p (f :a :b) (f :c :d) (f :e :f))
(compile "<a b, c d, e f>" keyword))))
-
(testing "polymeter - unequal lengths"
- (is (= '(p (f :a :b :e) (f :c :d))
- (compile "<a b e, c d>" keyword))))
-
+ (is (= '(p (f :a :b :e) (f :c :d)) (compile "<a b e, c d>" keyword))))
(testing "polymeter - single element per group"
- (is (= '(p :a :c)
- (compile "<a, c>" keyword))))
-
+ (is (= '(p :a :c) (compile "<a, c>" keyword))))
(testing "polymeter - with nested structures"
(is (= '(p (f (l :a :b) (l :c :d)) (f (l :e :f) (l :g :h)))
(compile "<[a b] [c d], [e f] [g h]>" keyword))))
-
(testing "polymeter - with modifiers"
- (is (= '(rate 2 (p (f :a :b) (f :c :d)))
- (compile "<a b, c d>*2" keyword))))
-
+ (is (= '(rate 2 (p (f :a :b) (f :c :d))) (compile "<a b, c d>*2" keyword))))
(testing "polymeter - melody and bass pattern"
- (is (= '(p (f (l :e5 :b4) (l :a4 :c5)) (f (rate 4 (l :e2 :e3)) (rate 4 (l :a2 :a3))))
+ (is (= '(p
+ (f (l :e5 :b4) (l :a4 :c5))
+ (f (rate 4 (l :e2 :e3)) (rate 4 (l :a2 :a3))))
(compile "<[e5 b4] [a4 c5], [[e2 e3]*4] [[a2 a3]*4]>" keyword)))))