-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdjoinTiesTest.hs
More file actions
78 lines (60 loc) · 2.09 KB
/
AdjoinTiesTest.hs
File metadata and controls
78 lines (60 loc) · 2.09 KB
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
70
71
72
73
74
75
76
77
78
-- This file is part of KSQuant2.
-- Copyright (c) 2010 - 2011, Kilian Sprotte. All rights reserved.
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
module AdjoinTiesTest
where
import qualified Types as T ( WRat )
import qualified Measure as M ( M(M), E(D), l, dur)
import Test.HUnit ( Assertion, (@=?) )
import Data.Ratio ( (%) )
import qualified Lisp as L ( n60, nil )
import AdjoinTies ( adjoinTies )
type Dur = T.WRat
q, e, s :: Dur
q = 1 % 4
e = 1 % 8
s = 1 % 16
data H = N Dur
| T Dur
deriving Show
buildLeaf :: H -> M.E
buildLeaf (N x) = M.l x False L.n60 L.nil
buildLeaf (T x) = M.l x True L.n60 L.nil
buildD :: [H] -> M.E
buildD hs = M.D q rr ls
where ls = map buildLeaf hs
dd = sum (map M.dur ls)
rr = q / dd
buildM :: [H] -> M.M
buildM hs = M.M (1,4) (4,60) (M.D q 1 [buildD hs])
adjt :: [H] -> [H] -> Assertion
adjt ee ii = buildM ee @=? adjoinTies (buildM ii)
adjoin1 :: Assertion
adjoin1 =
M.M (4,4) (4,60)
(M.D (1 % 1) (1 % 1)
[M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil])
@=?
adjoinTies
(M.M (4,4) (4,60)
(M.D (1 % 1) (1 % 1)
[M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil,
M.l q False L.n60 L.nil]))
adjoin2 :: Assertion
adjoin2 = [N q, N e] `adjt` [T e, N e, N e]
adjoin3 :: Assertion
adjoin3 = [N e, N s, N s] `adjt` [T s, N s, N s, N s]