summaryrefslogtreecommitdiff
path: root/test/unheard
diff options
context:
space:
mode:
Diffstat (limited to 'test/unheard')
-rw-r--r--test/unheard/cycles_test.clj62
1 files changed, 60 insertions, 2 deletions
diff --git a/test/unheard/cycles_test.clj b/test/unheard/cycles_test.clj
index e2e1889..c395755 100644
--- a/test/unheard/cycles_test.clj
+++ b/test/unheard/cycles_test.clj
@@ -1,6 +1,6 @@
(ns unheard.cycles-test
(:require [clojure.test :refer [deftest is testing]]
- [unheard.cycles :refer [l f p rate elongate rep unfold]]))
+ [unheard.cycles :refer [l f p rate elongate rep paste unfold]]))
(deftest unfold-tests
(testing "single scalar"
@@ -219,4 +219,62 @@
(testing "rep of list"
(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)))))))
+ (unfold 1 (rep 2 (l :a :b))))))
+
+ (testing "paste - simple replacement in list"
+ (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))))
+
+ (testing "paste - nested structures"
+ (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))))
+
+ (testing "paste - complex nested with parallel"
+ (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))))
+
+ (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))))
+
+ (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]]
+ (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]]
+ (unfold 1 (paste (f :_ (f :_ :_) :_ :_) :c :e nil :b :d))))))