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