]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/display-lily-tests.ly
Add a hack to packed spacing to work around extra columns.
[lilypond.git] / input / regression / display-lily-tests.ly
1 \version "2.11.51"
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
80 %% tags
81 \test "" ##[ { \tag #'foo { c4 d } } #]
82 \test "" ##[ c-\tag #'foo -\tag #'baz -^ -. #]
83
84 %% Graces
85 \test "" ##[ { \grace c8 d2 } #]                        % GraceMusic
86 \test "" ##[ { \appoggiatura c8 d2 } #]
87 \test "" ##[ { \acciaccatura c8 d2 } #]
88 \test "" ##[ { c1 \afterGrace { b,16 c } d2 } #]
89
90 %% Clusters
91 \test "" ##[ { \makeClusters { c4 g } } #]              % ClusterNoteEvent
92
93 %% Figured bass
94 \test "" ##[ \figures { < 6 > } #]                      % BassFigureEvent
95 \test "" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
96 \test "" ##[ \figuremode { < [6 > < 5] > } #]
97
98 %% Lyrics
99 \test "" ##[ \lyrics { a b } #]
100 \test "" ##[ \lyricmode { a --  b } #]          % HyphenEvent
101 \test "" ##[ \lyricmode { a __  b } #]          % ExtenderEvent
102 \test "" ##[ \lyricmode { "a " } #]                     % LyricEvent
103 \test "" ##[ \lyricsto "foo" { bla bla } #]             % LyricCombineMusic
104 \test "" ##[ { { c d }
105   \addlyrics { bla bla } } #]
106
107 %% Drums
108 \test "" ##[ \drums { hihat } #]
109 \test "" ##[ \drummode { hihat4.*3/4 } #]
110
111 %% Expressive marks
112 \test "" ##[ c4 ~ #]                                    % TieEvent
113 \test "" ##[ c\noBeam #]                                % BeamForbidEvent
114 \test "" ##[ c\1 #]                                     % StringNumberEvent
115 \test "" ##[ { c:  c:1  } #]                            % TremoloEvent
116 \test "" ##[ { c-^  c^^  c_^  } #]                      % ArticulationEvent
117 \test "" ##[ { c-+  c^+  c_+  } #]
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-\trill  c^\trill  c_\trill  } #]
124 \test "" ##[ { c-1  c^2  c_3  } #]                      % FingerEvent
125 \test "" ##[ { c-"foo"  c^"foo"  c_"foo"  } #]  % TextScriptEvent
126 \test "" ##[ { R1*4-"foo"  R^"foo"  R_"foo"  } #]       % MultiMeasureTextEvent
127 \test "" ##[ { c4-\harmonic  c^\harmonic  c_\harmonic  } #]     % HarmonicEvent
128 \test "" ##[ { c-\glissando  c^\glissando  c_\glissando  } #] % GlissandoEvent
129 \test "" ##[ { c-\arpeggio  c^\arpeggio  c_\arpeggio  } #]      % ArpeggioEvent
130 \test "" ##[ { c\p  c^\ff  c_\sfz  } #]                 % AbsoluteDynamicEvent
131 \test "" ##[ { c[  c]  c^[  c^]  c_[  c_]  } #]         % BeamEvent
132 \test "" ##[ { c(  c)  c^(  c^)  c_(  c_)  } #]         % SlurEvent
133 \test "" ##[ { c\<  c\!  c^\<  c^\!  c_\<  c_\!  } #]   % CrescendoEvent
134 \test "" ##[ { c\>  c\!  c^\>  c^\!  c_\>  c_\!  } #]   % DecrescendoEvent
135 \test "" ##[ { c\(  c\)  c^\(  c^\)  c_\(  c_\)  } #]   % PhrasingSlurEvent
136 \test "" ##[ { c\sustainOn  c\sustainOff  } #] % SustainEvent
137 \test "" ##[ { c\sostenutoOn  c\sostenutoOff  } #] % SostenutoEvent
138 \test "" ##[ \melisma #]
139 \test "" ##[ \melismaEnd #]
140 \test "" ##[ { c\startTextSpan  c\stopTextSpan  } #] % TextSpanEvent
141 \test "" ##[ { c\startTrillSpan  c\stopTrillSpan  } #] % TrillSpanEvent
142 \test "" ##[ { c \startStaff c \stopStaff } #]  % StaffSpanEvent
143 \test "" ##[ { c\startGroup  c\stopGroup  c^\startGroup  c^\stopGroup  c_\startGroup  c_\stopGroup  } #] % NoteGroupingEvent
144 \test "" ##[ { c\unaCorda  c\treCorde  } #] % UnaCordaEvent
145 \test "" ##[ \breathe #]
146 \test "" ##[ { c \[ c \] } #]                   % LigatureEvent
147 \test "" ##[ \~ #]                                      % PesOrFlexaEvent
148
149 \test "" ##[ \break #]
150 \test "" ##[ \noBreak #]
151 \test "" ##[ \pageBreak #]
152 \test "" ##[ \noPageBreak #]
153 \test "" ##[ \pageTurn #]
154 \test "" ##[ \noPageTurn #]
155
156 %% Checks
157 \test "" ##[ \octave a' #]                              % RelativeOctaveCheck
158 \test "" ##[ | #]                                       % BarCheck
159
160 %% Marks
161 \test "" ##[ \mark \default #]                  % MarkEvent
162 \test "" ##[ \mark "Allegro" #]
163 \test "" ##[ \tempo 4 = 120 #]                  % MetronomeChangeEvent
164
165 %% key, time, clef, bar
166 \test "" ##[ \key \default #]                   % KeyChangeEvent
167 \test "" ##[ \key e \minor #]
168 \test "" ##[ \clef "bass" #]
169 \test "" ##[ \clef "french^2" #]
170 \test "" ##[ \clef "alto_3" #]
171 \test "" ##[ \time 2/4 #]
172 \test "" ##[ #(set-time-signature 5 8 '(3 2)) #]
173 \test "" ##[ \bar "|." #]
174
175 %% staff switches
176 \test "" ##[ \autochange { c d } #]                     % AutoChangeMusic
177 \test "" ##[ { \change Staff = "up" { c d } } #]        % ContextChange
178
179 %% Tuplets
180 \test "" ##[ \times 2/3 { c8 d e } #]                           % TimeScaledMusic
181 \test "" ##[ \times 4/6 { c16 d e f g a } #]
182 %}
183 %% \relative and \tranpose
184 \test #"NOT A BUG" ##[ \relative c' { c b } #]  % RelativeOctaveMusic
185 \test #"NOT A BUG" ##[ \transpose c d { c d } #]        % TransposedMusic
186 %}
187 %% Repeats
188 \test "" ##[ \repeat volta 2 { c d } #]         % VoltaRepeatedMusic
189 \test "" ##[ \repeat unfold 2 { c d } #]                % UnfoldedRepeatedMusic
190 \test "" ##[ \repeat percent 2 { c d } #]               % PercentRepeatedMusic
191 \test "" ##[ \repeat tremolo 4 { c16 d } #]             % TremoloRepeatedMusic
192 \test "" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] % 
193
194 %% Context creation
195 \test "" ##[ \new Staff { c d } #]                      % ContextSpeccedMusic
196 \test "" ##[ \new Staff = "up" { c d } #]                       % ContextSpeccedMusic
197 \test "" ##[ \context Staff { c d } #]
198 \test "" ##[ \context Staff = "up" { c d } #]
199 \test "" ##[
200 \new Staff \with {
201   \consists "Timing_engraver"
202   \remove "Clef_engraver"
203 } { c d } #]
204 %% Context properties
205 \test "" ##[ \once \set Score . skipBars = ##t #]       % PropertySet
206 \test "" ##[ \set autoBeaming = ##f #]
207 \test "" ##[ \unset Score . skipBars #]         % PropertyUnset
208 \test "" ##[ \unset autoBeaming #]
209 %% Layout properties
210 \test "" ##[ \override Staff . Stem #'thickness = #4.0 #]       % OverrideProperty
211 \test "" ##[ \once \override Beam #'thickness = #0.6 #]
212 \test "" ##[ \revert Staff . Stem #'thickness #]        % RevertProperty
213 \test "" ##[ \revert Beam #'thickness #]
214
215 %% \applyOutput
216 \test "" ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
217 %% \applyContext
218 \test "" ##[ \applyContext #(lambda (arg) (list)) #]
219
220 %% \partial
221 \test "" ##[ \partial 2 #]
222 \test "" ##[ \partial 8. #]
223 \test #"TODO? exotic durations in \\partial" ##[ \partial 4*2/3 #]
224
225 %% \partcombine
226 \test "" ##[ \partcombine { c e }
227 { d f } #]                                              % PartCombineMusic UnrelativableMusic
228
229 %% Cue notes
230 \test "" ##[ \cueDuring #"foo" #1 { c d } #]
231 \test "" ##[ \quoteDuring #"foo" { c d } #]
232
233
234 %% end test.
235
236 #(read-hash-extend #\[ #f) %{ ] %}