From daa831b0a44d344fb4256b004139c58f661f746d Mon Sep 17 00:00:00 2001 From: Jake Zerrer Date: Mon, 1 Dec 2025 15:34:12 -0500 Subject: Add elongation --- test/unheard/cycles_test.clj | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/unheard/cycles_test.clj b/test/unheard/cycles_test.clj index 0f55a2c..242b6fc 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 unfold]])) + [unheard.cycles :refer [l f p rate elongate unfold]])) (deftest unfold-tests (testing "single scalar" @@ -128,4 +128,33 @@ (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))))))) + (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))))) + + (testing "elongate inside parallel" + (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)))))) + + (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]] + (unfold 1 (rate 2 (l (elongate 2 :a) :b :c))))))) -- cgit v1.2.3