]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/display-lily-tests.ly
Add support for tempo ranges
[lilypond.git] / input / regression / display-lily-tests.ly
1 \version "2.13.20"
2 #(use-modules (srfi srfi-13)
3               (ice-9 format))
4
5 %%%
6 %%% Testing utilities
7 %%%
8 #(use-modules (scm display-lily))
9 #(memoize-clef-names supported-clefs)
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:parser-clone 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 (not (equal? input output))
38          (ly:progress "Test ~a unequal: ~a. \nin  = ~a\nout = ~a\n"
39           test-number
40           (if result-info
41               result-info "BUG")
42           input output))
43      (make-music 'SequentialMusic 'void #t)))))
44
45 test = 
46 #(define-music-function (parser location result-info strings) (string? pair?)
47    (test-function parser location result-info strings))
48
49 %%%
50 %%% Tests
51 %%%
52 \header {
53   texidoc = "This is a test of the display-lily-music unit. Problems are reported on the
54 stderr of this run." 
55 }
56
57 %% Sequential music
58 \test "" ##[ { { a b } { c d } } #]             % SequentialMusic
59 \test "" ##[ << { a b } { c d } >> #]           % SimultaneousMusic
60 \test "" ##[ << { a b } \\ { c d } >> #]        % VoiceSeparator
61
62 %% Chords and Notes
63 \test "" ##[ { ceses ces c cis cisis } #]       % NoteEvent
64 \test "" ##[ { deses des d dis disis } #]
65 \test "" ##[ { eeses ees e eis eisis } #]
66 \test "" ##[ { feses fes f fis fisis } #]
67 \test "" ##[ { geses ges g gis gisis } #]
68 \test "" ##[ { aeses aes a ais aisis } #]
69 \test "" ##[ { beses bes b bis bisis } #]
70 \test "" ##[ { c,, d' } #]
71 \test "" ##[ { c' d'=' } #]
72 \test "" ##[ { c! c? } #]
73 \test "" ##[ r1.*4/3 #]         % RestEvent
74 \test "" ##[ c1\rest #]         % RestEvent
75 \test "" ##[ s2..*3/4 #]                % SkipEvent
76 \test "" ##[ R1.*2/3 #]         % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
77 \test "" ##[ \skip 2.*3/4 #]            % SkipMusic
78 \test "" ##[ < c\1 e\3 >4.*3/4-. #]     % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
79 \test "NOT A BUG" ##[ { < c e g c' > q8-. } #] % RepeatedChord
80
81 %% tags
82 \test "" ##[ { \tag #'foo { c4 d } } #]
83 \test "" ##[ c-\tag #'foo -\tag #'baz -^ -. #]
84
85 %% Graces
86 \test "" ##[ { \grace c8 d2 } #]                        % GraceMusic
87 \test "" ##[ { \appoggiatura c8 d2 } #]
88 \test "" ##[ { \acciaccatura c8 d2 } #]
89 \test "" ##[ { c1 \afterGrace { b,16 c } d2 } #]
90
91 %% Clusters
92 \test "" ##[ { \makeClusters { c4 g } } #]              % ClusterNoteEvent
93
94 %% Figured bass
95 \test "" ##[ \figures { < 6 > } #]                      % BassFigureEvent
96 \test "" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
97 \test "" ##[ \figuremode { < [6 > < 5] > } #]
98
99 %% Lyrics
100 \test "" ##[ \lyrics { a b } #]
101 \test "" ##[ \lyricmode { a --  b } #]          % HyphenEvent
102 \test "" ##[ \lyricmode { a __  b } #]          % ExtenderEvent
103 \test "" ##[ \lyricmode { "a " } #]                     % LyricEvent
104 \test "" ##[ \lyricsto "foo" { bla bla  } #]            % LyricCombineMusic
105 \test "" ##[ { { c d }
106   \addlyrics { bla bla  } } #]
107
108 %% Drums
109 \test "" ##[ \drums { hihat } #]
110 \test "" ##[ \drummode { hihat4.*3/4 } #]
111
112 %% Expressive marks
113 \test "" ##[ c4 ~ #]                                    % TieEvent
114 \test "" ##[ c\noBeam #]                                % BeamForbidEvent
115 \test "" ##[ c\1 #]                                     % StringNumberEvent
116 \test "" ##[ { c:  c:1  } #]                            % TremoloEvent
117 \test "" ##[ { c-^  c^^  c_^  } #]                      % ArticulationEvent
118 \test "" ##[ { c-+  c^+  c_+  } #]
119 \test "" ##[ { c--  c^-  c_-  } #]
120 \test "" ##[ { c-|  c^|  c_|  } #]
121 \test "" ##[ { c->  c^>  c_>  } #]
122 \test "" ##[ { c-.  c^.  c_.  } #]
123 \test "" ##[ { c-_  c^_  c__  } #]
124 \test "" ##[ { c-\trill  c^\trill  c_\trill  } #]
125 \test "" ##[ { c-1  c^2  c_3  } #]                      % FingerEvent
126 \test "" ##[ { c-"foo"  c^"foo"  c_"foo"  } #]  % TextScriptEvent
127 \test "" ##[ { R1*4-"foo"  R^"foo"  R_"foo"  } #]       % MultiMeasureTextEvent
128 \test "" ##[ { < c\harmonic >4 < c e\harmonic > } #]    % HarmonicEvent
129 \test "" ##[ { c-\glissando  c^\glissando  c_\glissando  } #] % GlissandoEvent
130 \test "" ##[ { c-\arpeggio  c^\arpeggio  c_\arpeggio  } #]      % ArpeggioEvent
131 \test "" ##[ { c\p  c^\ff  c_\sfz  } #]                 % AbsoluteDynamicEvent
132 \test "" ##[ { c[  c]  c^[  c^]  c_[  c_]  } #]         % BeamEvent
133 \test "" ##[ { c(  c)  c^(  c^)  c_(  c_)  } #]         % SlurEvent
134 \test "" ##[ { c\<  c\!  c^\<  c^\!  c_\<  c_\!  } #]   % CrescendoEvent
135 \test "" ##[ { c\>  c\!  c^\>  c^\!  c_\>  c_\!  } #]   % DecrescendoEvent
136 \test "" ##[ { c\episemInitium  c\episemFinis  } #] % EpisemaEvent
137 \test "" ##[ { c\(  c\)  c^\(  c^\)  c_\(  c_\)  } #]   % PhrasingSlurEvent
138 \test "" ##[ { c\sustainOn  c\sustainOff  } #] % SustainEvent
139 \test "" ##[ { c\sostenutoOn  c\sostenutoOff  } #] % SostenutoEvent
140 \test "" ##[ \melisma #]
141 \test "" ##[ \melismaEnd #]
142 \test "" ##[ { c\startTextSpan  c\stopTextSpan  } #] % TextSpanEvent
143 \test "" ##[ { c\startTrillSpan  c\stopTrillSpan  } #] % TrillSpanEvent
144 \test "" ##[ { c \startStaff c \stopStaff } #]  % StaffSpanEvent
145 \test "" ##[ { c\startGroup  c\stopGroup  c^\startGroup  c^\stopGroup  c_\startGroup  c_\stopGroup  } #] % NoteGroupingEvent
146 \test "" ##[ { c\unaCorda  c\treCorde  } #] % UnaCordaEvent
147 \test "" ##[ \breathe #]
148 \test "" ##[ { c \[ c \] } #]                   % LigatureEvent
149 \test "" ##[ \~ #]                                      % PesOrFlexaEvent
150 \test "" ##[ { c-\bendAfter #3  } #] % BendAfterEvent
151
152 \test "" ##[ \break #]
153 \test "" ##[ \noBreak #]
154 \test "" ##[ \pageBreak #]
155 \test "" ##[ \noPageBreak #]
156 \test "" ##[ \pageTurn #]
157 \test "" ##[ \noPageTurn #]
158
159 %% Checks
160 \test "" ##[ \octaveCheck a' #]                         % RelativeOctaveCheck
161 \test "" ##[ | #]                                       % BarCheck
162
163 %% Marks
164 \test "" ##[ \mark \default #]                  % MarkEvent
165 \test "" ##[ \mark "Allegro" #]
166 \test "" ##[ \tempo 4 = 120 #]                  % MetronomeChangeEvent
167 \test "" ##[ \tempo 4 = 108 ~ 116 #]
168 \test "" ##[ \tempo "Allegro" 4 = 132 #]
169 \test "" ##[ \tempo "Andante" #]
170
171 %% key, time, clef, bar
172 \test "" ##[ \key \default #]                   % KeyChangeEvent
173 \test "" ##[ \key e \minor #]
174 \test "" ##[ \clef "bass" #]
175 \test "" ##[ \clef "french^2" #]
176 \test "" ##[ \clef "alto_3" #]
177 \test "" ##[ \time 2/4 #]
178 \test "" ##[ #(set-time-signature 5 8 '(3 2)) #]
179 \test "" ##[ \bar "|." #]
180
181 %% staff switches
182 \test "" ##[ \autochange { c d } #]                     % AutoChangeMusic
183 \test "" ##[ { \change Staff = "up" { c d } } #]        % ContextChange
184
185 %% Tuplets
186 \test "" ##[ \times 2/3 { c8 d e } #]                           % TimeScaledMusic
187 \test "" ##[ \times 4/6 { c16 d e f g a } #]
188 %}
189 %% \relative and \tranpose
190 \test #"NOT A BUG" ##[ \relative c' { c b } #]  % RelativeOctaveMusic
191 \test #"NOT A BUG" ##[ \transpose c d { c d } #]        % TransposedMusic
192 %}
193 %% Repeats
194 \test "" ##[ \repeat volta 2 { c d } #]         % VoltaRepeatedMusic
195 \test "" ##[ \repeat unfold 2 { c d } #]                % UnfoldedRepeatedMusic
196 \test "" ##[ \repeat percent 2 { c d } #]               % PercentRepeatedMusic
197 \test "" ##[ \repeat tremolo 4 { c16 d } #]             % TremoloRepeatedMusic
198 \test "" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] % 
199
200 %% Context creation
201 \test "" ##[ \new Staff { c d } #]                      % ContextSpeccedMusic
202 \test "" ##[ \new Staff = "up" { c d } #]                       % ContextSpeccedMusic
203 \test "" ##[ \context Staff { c d } #]
204 \test "" ##[ \context Staff = "up" { c d } #]
205 \test "" ##[
206 \new Staff \with {
207   \consists "Timing_engraver"
208   \remove "Clef_engraver"
209 } { c d } #]
210 %% Context properties
211 \test "" ##[ \once \set Score . skipBars = ##t #]       % PropertySet
212 \test "" ##[ \set autoBeaming = ##f #]
213 \test "" ##[ \unset Score . skipBars #]         % PropertyUnset
214 \test "" ##[ \unset autoBeaming #]
215 %% Layout properties
216 \test "" ##[ \override Staff . Stem #'thickness = #4.0 #]       % OverrideProperty
217 \test "" ##[ \once \override Beam #'beam-thickness = #0.6 #]
218 \test "" ##[ \revert Staff . Stem #'thickness #]        % RevertProperty
219 \test "" ##[ \revert Beam #'beam-thickness #]
220
221 %% \applyOutput
222 \test "" ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
223 %% \applyContext
224 \test "" ##[ \applyContext #(lambda (arg) (list)) #]
225
226 %% \partial
227 \test "" ##[ \partial 2 #]
228 \test "" ##[ \partial 8. #]
229 \test "" ##[ \partial 4*2/3 #]
230
231 %% \partcombine
232 \test "" ##[ \partcombine { c e }
233 { d f } #]                                              % PartCombineMusic UnrelativableMusic
234
235 %% Cue notes
236 \test "" ##[ \cueDuring #"foo" #1 { c d } #]
237 \test "" ##[ \quoteDuring #"foo" { c d } #]
238
239 %% \ottava
240 \test "" ##[ \ottava #1 #] % OttavaMusic
241
242 %% end test.
243
244 #(read-hash-extend #\[ #f) %{ ] %}