summaryrefslogtreecommitdiff
path: root/src/unheard/time_object_test.clj
blob: 07e49c3040c7293412a0a575612b72a10c75c197 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(ns unheard.time-object-test
  (:require [unheard.time-object :as sut]
            [missionary.core :as m]
            [hyperfiddle.rcf :refer [tests] :as rcf]))

(tests
  "behavioral test"
  (let [to1-start (atom 5)
        >to1-start (m/watch to1-start)
        to1-end (atom 10)
        >to1-end (m/watch to1-end)
        to1-value (atom :to1-a)
        >to1-value (m/watch to1-value)

        to1 (sut/time-object >to1-start >to1-end >to1-value)

        to2-start (atom 7)
        >to2-start (m/watch to2-start)
        to2-end (atom 15)
        >to2-end (m/watch to2-end)
        to2-value (atom :to1-b)
        >to2-value (m/watch to2-value)

        to2 (sut/time-object >to2-start >to2-end >to2-value)

        toc1 (sut/time-object-collection to1 to2)

        to3-start (atom 2)
        >to3-start (m/watch to3-start)
        to3-end (atom 3)
        >to3-end (m/watch to3-end)
        to3-value (atom :to3-a)
        >to3-value (m/watch to3-value)

        to3 (sut/time-object >to3-start >to3-end >to3-value)

        to4-start (atom 8)
        >to4-start (m/watch to4-start)
        to4-end (atom 12)
        >to4-end (m/watch to4-end)
        to4-value (atom :to3-b)
        >to4-value (m/watch to4-value)

        to4 (sut/time-object >to4-start >to4-end >to4-value)

        toc2 (sut/time-object-collection to3 to4)

        combined (sut/time-object-collection toc1 toc2)

        timeline (sut/timeline combined)

        point-query-at (atom 0)
        >point-query-at (m/watch point-query-at)

        point-query-result (sut/point-query timeline >point-query-at)

        #_#_#_#_#_#_
        range-query-range (atom [0 10])
        >range-query-range (m/watch range-query-range)

        range-query-result (sut/range-query timeline >range-query-range)
        ]

    (def cancel
      ((m/reduce rcf/tap nil point-query-result) #() #(throw %)))

    (cancel)

    ))