]> git.donarmstrong.com Git - lilypond.git/blob - input/no-notation/display-lily-tests.ly
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / input / no-notation / display-lily-tests.ly
1 \version "2.10.0"
2
3 #(use-modules (srfi srfi-13)
4               (ice-9 format))
5
6 %%%
7 %%% Testing utilities
8 %%%
9
10 #(define (parse-lily-and-compute-lily-string chr port)
11   (let ((lily-string (call-with-output-string
12                       (lambda (out)
13                         (do ((c (read-char port) (read-char port)))
14                             ((and (char=? c #\#)
15                                   (char=? (peek-char port) #\]))
16                              (read-char port))
17                           (display c out))))))
18     `(let* ((parser-clone (ly:clone-parser parser))
19             (input-str (string-trim-both ,lily-string))
20             (music (car (ly:music-property (parse-string-result input-str
21                                                                 parser-clone)
22                                            'elements)))
23             (result-str (string-trim-both (music->lily-string music parser-clone))))
24        (cons input-str result-str))))
25
26 #(read-hash-extend #\[ parse-lily-and-compute-lily-string) %{ ] %}
27
28 #(define (lily-string->markup str)
29    (make-column-markup (string-split str #\NewLine)))
30
31 #(define test-function
32   (let ((test-number 0))
33    (lambda (parser location result-info strings)
34     (let ((input (car strings))
35          (output (cdr strings)))
36      (set! test-number (1+ test-number))
37      (if (string=? input output)
38          (make-music 'SequentialMusic 'void #t)
39          (make-music 'SequentialMusic
40            'elements
41            (list (ly:parser-lookup parser 'fatText)
42                  (make-music 'EventChord
43                    'elements (list (make-music 'LineBreakEvent
44                                      'break-permission 'force)))
45                  (make-music 'EventChord
46                    'elements (list (make-music 'SkipEvent
47                                      'duration (ly:make-duration 0 0 1 1))
48                                    (make-music 'TextScriptEvent
49                                      'direction -1
50                                      'text (markup #:column
51                                             (#:simple (format #f "Test #~a " test-number)
52                                              (if (string-null? result-info) 
53                                                  (markup #:bold "BUG") 
54                                                  (markup #:simple result-info))
55                                              #:typewriter (lily-string->markup input)
56                                              #:typewriter (lily-string->markup output)))))))))))))
57     
58
59 test = 
60 #(define-music-function (parser location result-info strings) (string? pair?)
61    (test-function parser location result-info strings))
62
63 %%%
64 %%% Tests
65 %%%
66 \header {
67   texidoc = \markup \column { \line { \typewriter display-lily-music unit tests }
68                               \line { Real bugs (regressions) are marked as \bold BUG. }
69                               \line { Known bugs are marked as TODO. } }
70 }
71
72 \layout {
73   raggedright = ##t 
74   indent = 0\cm
75   \context {
76     \Staff
77     \override StaffSymbol #'line-count = #1
78     \remove "Time_signature_engraver"
79     \remove "Clef_engraver"
80   }
81   \context {
82     \Score
83     \remove "Bar_number_engraver"
84   }
85 }
86
87 %% Sequential music
88 \test "" ##[ { { a b } { c d } } #]             % SequentialMusic
89 \test "" ##[ << { a b } { c d } >> #]           % SimultaneousMusic
90 \test "" ##[ << { a b } \\ { c d } >> #]        % VoiceSeparator
91
92 %% Chords and Notes
93 \test "" ##[ { ceses ces c cis cisis } #]       % NoteEvent
94 \test "" ##[ { deses des d dis disis } #]
95 \test "" ##[ { eeses ees e eis eisis } #]
96 \test "" ##[ { feses fes f fis fisis } #]
97 \test "" ##[ { geses ges g gis gisis } #]
98 \test "" ##[ { aeses aes a ais aisis } #]
99 \test "" ##[ { beses bes b bis bisis } #]
100 \test "" ##[ { c,, d' } #]
101 \test "" ##[ { c' d'=' } #]
102 \test "" ##[ { c! c? } #]
103 \test "" ##[ r1.*4/3 #]         % RestEvent
104 \test "" ##[ c1\rest #]         % RestEvent
105 \test "" ##[ s2..*3/4 #]                % SkipEvent
106 \test "" ##[ R1.*2/3 #]         % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
107 \test "" ##[ \skip 2.*3/4 #]            % SkipMusic
108 \test "" ##[ < c\1 e\3 >4.*3/4-. #]     % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
109
110 %% tags
111 \test "" ##[ { \tag #'foo { c4 d } } #]
112 \test "" ##[ c-\tag #'foo -\tag #'baz -^ -. #]
113
114 %% Graces
115 \test "" ##[ { \grace c8 d2 } #]                        % GraceMusic
116 \test "" ##[ { \appoggiatura c8 d2 } #]
117 \test "" ##[ { \acciaccatura c8 d2 } #]
118 \test "" ##[ { c1 \afterGrace { b,16 c } d2 } #]
119
120 %% Clusters
121 \test "" ##[ { \makeClusters { c4 g } } #]              % ClusterNoteEvent
122
123 %% Figured bass
124 \test "" ##[ \figures { < 6 > } #]                      % BassFigureEvent
125 \test "" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
126 \test "" ##[ \figuremode { < [6 > < 5] > } #]
127
128 %% Lyrics
129 \test "" ##[ \lyrics { a b } #]
130 \test "" ##[ \lyricmode { a --  b } #]          % HyphenEvent
131 \test "" ##[ \lyricmode { a __  b } #]          % ExtenderEvent
132 \test "" ##[ \lyricmode { "a " } #]                     % LyricEvent
133 \test "" ##[ \lyricsto "foo" { bla bla } #]             % LyricCombineMusic
134 \test "" ##[ { { c d }
135   \addlyrics { bla bla } } #]
136
137 %% Drums
138 \test "" ##[ \drums { hihat } #]
139 \test "" ##[ \drummode { hihat4.*3/4 } #]
140
141 %% Expressive marks
142 \test "" ##[ c4 ~ #]                                    % TieEvent
143 \test "" ##[ c\noBeam #]                                % BeamForbidEvent
144 \test "" ##[ c\1 #]                                     % StringNumberEvent
145 \test "" ##[ { c:  c:1  } #]                            % TremoloEvent
146 \test "" ##[ { c-^  c^^  c_^  } #]                      % ArticulationEvent
147 \test "" ##[ { c-+  c^+  c_+  } #]
148 \test "" ##[ { c--  c^-  c_-  } #]
149 \test "" ##[ { c-|  c^|  c_|  } #]
150 \test "" ##[ { c->  c^>  c_>  } #]
151 \test "" ##[ { c-.  c^.  c_.  } #]
152 \test "" ##[ { c-_  c^_  c__  } #]
153 \test "" ##[ { c-\trill  c^\trill  c_\trill  } #]
154 \test "" ##[ { c-1  c^2  c_3  } #]                      % FingerEvent
155 \test "" ##[ { c-"foo"  c^"foo"  c_"foo"  } #]  % TextScriptEvent
156 \test "" ##[ { R1*4-"foo"  R^"foo"  R_"foo"  } #]       % MultiMeasureTextEvent
157 \test "" ##[ { c4-\harmonic  c^\harmonic  c_\harmonic  } #]     % HarmonicEvent
158 \test "" ##[ { c-\glissando  c^\glissando  c_\glissando  } #] % GlissandoEvent
159 \test "" ##[ { c-\arpeggio  c^\arpeggio  c_\arpeggio  } #]      % ArpeggioEvent
160 \test "" ##[ { c\p  c^\ff  c_\sfz  } #]                 % AbsoluteDynamicEvent
161 \test "" ##[ { c[  c]  c^[  c^]  c_[  c_]  } #]         % BeamEvent
162 \test "" ##[ { c(  c)  c^(  c^)  c_(  c_)  } #]         % SlurEvent
163 \test "" ##[ { c\<  c\!  c^\<  c^\!  c_\<  c_\!  } #]   % CrescendoEvent
164 \test "" ##[ { c\>  c\!  c^\>  c^\!  c_\>  c_\!  } #]   % DecrescendoEvent
165 \test "" ##[ { c\(  c\)  c^\(  c^\)  c_\(  c_\)  } #]   % PhrasingSlurEvent
166 \test "" ##[ { c\sustainDown  c\sustainUp  } #] % SustainEvent
167 \test "" ##[ { c\sostenutoDown  c\sostenutoUp  } #] % SostenutoEvent
168 \test "" ##[ \melisma #]
169 \test "" ##[ \melismaEnd #]
170 \test "" ##[ { c\startTextSpan  c\stopTextSpan  } #] % TextSpanEvent
171 \test "" ##[ { c\startTrillSpan  c\stopTrillSpan  } #] % TrillSpanEvent
172 \test "" ##[ { c \startStaff c \stopStaff } #]  % StaffSpanEvent
173 \test "" ##[ { c\startGroup  c\stopGroup  c^\startGroup  c^\stopGroup  c_\startGroup  c_\stopGroup  } #] % NoteGroupingEvent
174 \test "" ##[ { c\unaCorda  c\treCorde  } #] % UnaCordaEvent
175 \test "" ##[ \breathe #]
176 \test "" ##[ { c \[ c \] } #]                   % LigatureEvent
177 \test "" ##[ \~ #]                                      % PesOrFlexaEvent
178
179 \test "" ##[ \break #]
180 \test "" ##[ \noBreak #]
181 \test "" ##[ \pageBreak #]
182 \test "" ##[ \noPageBreak #]
183 \test "" ##[ \pageTurn #]
184 \test "" ##[ \noPageTurn #]
185
186 %% Checks
187 \test "" ##[ \octave a' #]                              % RelativeOctaveCheck
188 \test "" ##[ | #]                                       % BarCheck
189
190 %% Marks
191 \test "" ##[ \mark \default #]                  % MarkEvent
192 \test "" ##[ \mark "Allegro" #]
193 \test "" ##[ \tempo 4 = 120 #]                  % MetronomeChangeEvent
194
195 %% key, time, clef, bar
196 \test "" ##[ \key \default #]                   % KeyChangeEvent
197 \test "" ##[ \key e \minor #]
198 \test "" ##[ \clef "bass" #]
199 \test "" ##[ \clef "french^2" #]
200 \test "" ##[ \clef "alto_3" #]
201 \test "" ##[ \time 2/4 #]
202 \test "" ##[ #(set-time-signature 5 8 '(3 2)) #]
203 \test "" ##[ \bar "|." #]
204
205 %% staff switches
206 \test "" ##[ \autochange { c d } #]                     % AutoChangeMusic
207 \test "" ##[ { \change Staff = "up" { c d } } #]        % ContextChange
208
209 %% Tuplets
210 \test "" ##[ \times 2/3 { c8 d e } #]                           % TimeScaledMusic
211 \test "" ##[ \times 4/6 { c16 d e f g a } #]
212 %}
213 %% \relative and \tranpose
214 \test #"NOT A BUG" ##[ \relative c' { c b } #]  % RelativeOctaveMusic
215 \test #"NOT A BUG" ##[ \transpose c d { c d } #]        % TransposedMusic
216 %}
217 %% Repeats
218 \test "" ##[ \repeat volta 2 { c d } #]         % VoltaRepeatedMusic
219 \test "" ##[ \repeat unfold 2 { c d } #]                % UnfoldedRepeatedMusic
220 \test "" ##[ \repeat fold 2 { c d } #]          % FoldedRepeatedMusic
221 \test "" ##[ \repeat percent 2 { c d } #]               % PercentRepeatedMusic
222 \test "" ##[ \repeat tremolo 4 { c16 d } #]             % TremoloRepeatedMusic
223 \test "" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] % 
224
225 %% Context creation
226 \test "" ##[ \new Staff { c d } #]                      % ContextSpeccedMusic
227 \test "" ##[ \new Staff = "up" { c d } #]                       % ContextSpeccedMusic
228 \test "" ##[ \context Staff { c d } #]
229 \test "" ##[ \context Staff = "up" { c d } #]
230 \test "" ##[
231 \new Staff \with {
232   \consists "Timing_engraver"
233   \remove "Clef_engraver"
234 } { c d } #]
235 %% Context properties
236 \test "" ##[ \once \set Score . skipBars = ##t #]       % PropertySet
237 \test "" ##[ \set autoBeaming = ##f #]
238 \test "" ##[ \unset Score . skipBars #]         % PropertyUnset
239 \test "" ##[ \unset autoBeaming #]
240 %% Layout properties
241 \test "" ##[ \override Staff . Stem #'thickness = #4.0 #]       % OverrideProperty
242 \test "" ##[ \once \override Beam #'thickness = #0.6 #]
243 \test "" ##[ \revert Staff . Stem #'thickness #]        % RevertProperty
244 \test "" ##[ \revert Beam #'thickness #]
245
246 %% \applyOutput
247 \test "" ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
248 %% \applyContext
249 \test "" ##[ \applyContext #(lambda (arg) (list)) #]
250
251 %% \partial
252 \test "" ##[ \partial 2 #]
253 \test "" ##[ \partial 8. #]
254 \test #"TODO? exotic durations in \\partial" ##[ \partial 4*2/3 #]
255
256 %% \partcombine
257 \test "" ##[ \partcombine { c e }
258 { d f } #]                                              % PartCombineMusic UnrelativableMusic
259
260 %% Cue notes
261 \test "" ##[ \cueDuring #"foo" #1 { c d } #]
262 \test "" ##[ \quoteDuring #"foo" { c d } #]