]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/display-lily-tests.ly
Issue 5106: Don't widespace \set/\unset arguments in display
[lilypond.git] / input / regression / display-lily-tests.ly
1 \version "2.19.40"
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))
19             (input-str (string-trim-both ,lily-string))
20             (music (ly:parse-string-expression parser-clone input-str))
21             (result-str (string-trim-both (music->lily-string music))))
22        (cons input-str result-str))))
23
24 #(read-hash-extend #\[ parse-lily-and-compute-lily-string) %{ ] %}
25
26 #(define (lily-string->markup str)
27    (make-column-markup (string-split str #\NewLine)))
28
29 test =
30 #(define-void-function (harmless strings)
31   ((string?) pair?)
32   (let ((input (car strings))
33         (output (cdr strings))
34         (result-info (or harmless "BUG")))
35    (if (not (equal? input output))
36     (if harmless
37      (ly:progress "Test unequal: ~a.\nin  = ~a\nout = ~a\n"
38       harmless input output)
39      (ly:input-warning (*location*) "Test unequal: BUG.\nin  = ~a\nout = ~a\n"
40       input output)))))
41
42 %%%
43 %%% Tests
44 %%%
45 \header {
46   texidoc = "This is a test of the display-lily-music unit. Problems are reported on the
47 stderr of this run." 
48 }
49
50 %% Sequential music
51 \test ##[ { { a4 b4 } { c4 d4 } } #]            % SequentialMusic
52 \test ##[ << { a4 b4 } { c4 d4 } >> #]          % SimultaneousMusic
53 \test ##[ << { a4 b4 } \\ { c4 d4 } >> #]       % VoiceSeparator
54
55 %% Chords and Notes
56 \test ##[ { ceses4 ces4 c4 cis4 cisis4 } #]     % NoteEvent
57 \test ##[ { deses4 des4 d4 dis4 disis4 } #]
58 \test ##[ { eeses4 ees4 e4 eis4 eisis4 } #]
59 \test ##[ { feses4 fes4 f4 fis4 fisis4 } #]
60 \test ##[ { geses4 ges4 g4 gis4 gisis4 } #]
61 \test ##[ { aeses4 aes4 a4 ais4 aisis4 } #]
62 \test ##[ { beses4 bes4 b4 bis4 bisis4 } #]
63 \test ##[ { c,,4 d'4 } #]
64 \test ##[ { c'4 d'='4 } #]
65 \test ##[ { c!4 c?4 } #]
66 \test ##[ r1.*4/3 #]            % RestEvent
67 \test ##[ c1\rest #]            % RestEvent
68 \test ##[ s2..*3/4 #]           % SkipEvent
69 \test ##[ R1.*2/3 #]            % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
70 \test ##[ \skip 2.*3/4 #]               % SkipMusic
71 \test ##[ < c\1 e\3 >4.*3/4-. #]        % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
72 \test ##[ < c-1\4 >8 #]
73 \test ##[ { < c e g c' >4 q8-. } #] % RepeatedChord
74
75 %% tags
76 \test ##[ { \tag #'foo { c4 d4 } } #]
77 \test ##[ c4-\tag #'foo -\tag #'baz -^-. #]
78
79 %% Graces
80 \test ##[ { \grace c8 d2 } #]                           % GraceMusic
81 \test ##[ { \appoggiatura c8 d2 } #]
82 \test ##[ { \acciaccatura c8 d2 } #]
83 \test ##[ { c1 \afterGrace { b,16 c16 } d2 } #]
84
85 %% Clusters
86 \test ##[ { \makeClusters { c4 g4 } } #]                % ClusterNoteEvent
87
88 %% Figured bass
89 \test ##[ \figures { < 6 >4 } #]                        % BassFigureEvent
90 \test ##[ \figuremode { < 1-- 3- >4 < 2+ 4++ >4 < _! 7! >4 } #]
91 \test ##[ \figuremode { < [6 >4 < 5] >4 } #]
92
93 %% Lyrics
94 \test ##[ \lyrics { a b } #]
95 \test ##[ \lyricmode { a -- b } #]              % HyphenEvent
96 \test ##[ \lyricmode { a __ b } #]              % ExtenderEvent
97 \test ##[ \lyricmode { "a " } #]                        % LyricEvent
98 \test ##[ \lyricsto "foo" { bla bla  } #]               % LyricCombineMusic
99 \test ##[ { { c4 d4 }
100   \addlyrics { bla bla  } } #]
101
102 %% Drums
103 \test ##[ \drums { hihat4 } #]
104 \test ##[ \drummode { hihat4.*3/4 } #]
105
106 %% Expressive marks
107 \test ##[ c4 ~ #]                                       % TieEvent
108 \test ##[ c4\noBeam #]                                  % BeamForbidEvent
109 \test ##[ c4\1 #]                                       % StringNumberEvent
110 \test ##[ { c4:8 c4:1 } #]                              % TremoloEvent
111 \test ##[ { c4-^ c4^^ c4_^ } #]                         % ArticulationEvent
112 \test ##[ { c4-+ c4^+ c4_+ } #]
113 \test ##[ { c4-- c4^- c4_- } #]
114 \test ##[ { c4-! c4^! c4_! } #]
115 \test ##[ { c4-> c4^> c4_> } #]
116 \test ##[ { c4-. c4^. c4_. } #]
117 \test ##[ { c4-_ c4^_ c4__ } #]
118 \test ##[ { c4\trill c4^\trill c4_\trill } #]
119 \test ##[ { c4-1 c4^2 c4_3 } #]                         % FingerEvent
120 \test ##[ { c4-"foo" c4^"foo" c4_"foo" } #]             % TextScriptEvent
121 \test ##[ { R1*4-"foo" R1*4^"foo" R1*4_"foo" } #]       % MultiMeasureTextEvent
122 \test ##[ { < c\harmonic >4 < c e\harmonic >4 } #]      % HarmonicEvent
123 \test ##[ { c4\glissando c4^\glissando c4_\glissando } #]       % GlissandoEvent
124 \test ##[ { c4\arpeggio c4^\arpeggio c4_\arpeggio } #]  % ArpeggioEvent
125 \test ##[ { c4\p c4^\ff c4_\sfz } #]                    % AbsoluteDynamicEvent
126 \test ##[ { c4[ c4] c4^[ c4^] c4_[ c4_] } #]            % BeamEvent
127 \test ##[ { c4( c4) c4^( c4^) c4_( c4_) } #]            % SlurEvent
128 \test ##[ { c4\< c4\! c4^\< c4^\! c4_\< c4_\! } #]      % CrescendoEvent
129 \test ##[ { c4\> c4\! c4^\> c4^\! c4_\> c4_\! } #]      % DecrescendoEvent
130 \test ##[ { c4\episemInitium c4\episemFinis } #]        % EpisemaEvent
131 \test ##[ { c4\( c4\) c4^\( c4^\) c4_\( c4_\) } #]      % PhrasingSlurEvent
132 \test ##[ { c4\sustainOn c4\sustainOff } #]             % SustainEvent
133 \test ##[ { c4\sostenutoOn c4\sostenutoOff } #]         % SostenutoEvent
134 \test ##[ \melisma #]
135 \test ##[ \melismaEnd #]
136 \test ##[ { c4\startTextSpan c4\stopTextSpan } #]       % TextSpanEvent
137 \test ##[ { c4\startTrillSpan c4\stopTrillSpan } #]     % TrillSpanEvent
138 \test ##[ { c4 \startStaff c4 \stopStaff } #]           % StaffSpanEvent
139 \test ##[ { c4\startGroup c4\stopGroup c4^\startGroup c4^\stopGroup c4_\startGroup c4_\stopGroup } #]    % NoteGroupingEvent
140 \test ##[ { c4\unaCorda c4\treCorde } #]                % UnaCordaEvent
141 \test ##[ \breathe #]
142 \test ##[ { c4 \[ c4 \] } #]                            % LigatureEvent
143 \test ##[ \~ #]                                         % PesOrFlexaEvent
144 \test ##[ c4\bendAfter #3 #]                            % BendAfterEvent
145 \test ##[ c4\rightHandFinger #1 #]                      % StrokeFingerEvent
146
147 \test ##[ \break #]
148 \test ##[ \noBreak #]
149 \test ##[ \pageBreak #]
150 \test ##[ \noPageBreak #]
151 \test ##[ \pageTurn #]
152 \test ##[ \noPageTurn #]
153
154 %% Checks
155 \test ##[ \octaveCheck a' #]                            % RelativeOctaveCheck
156 \test ##[ | #]                                          % BarCheck
157
158 %% Marks
159 \test ##[ \mark \default #]                     % MarkEvent
160 \test ##[ \mark #3 #]
161 \test ##[ \mark "Z" #]
162 \test ##[ \mark \markup \italic "X" #]
163 \test ##[ \mark "Allegro" #]
164 \test ##[ \tempo 4 = 120 #]                     % MetronomeChangeEvent
165 \test ##[ \tempo 4 = 108 - 116 #]
166 \test ##[ \tempo "Allegro" 4 = 132 #]
167 \test ##[ \tempo "Andante" #]
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 "treble_[8]" #]
175 \test ##[ \clef "bass^(15)" #]
176 \test ##[ \clef "alto_3" #]
177 \test ##[ \time 2/4 #]
178 \test ##[ \time 3,2 5/8 #]
179 \test ##[ \bar "|." #]
180
181 %% staff switches
182 \test ##[ \autochange { c4 d4 } #]                      % AutoChangeMusic
183 \test ##[ { \change Staff = "up" { c4 d4 } } #]         % ContextChange
184
185 %% Tuplets
186 \test ##[ \tuplet 3/2 { c8 d8 e8 } #]                           % TimeScaledMusic
187 \test ##[ \tuplet 6/4 { c16 d16 e16 f16 g16 a16 } #]
188 \test ##[ \tuplet 3/2 { c4 d4 e4 \tuplet 5/2 { f4 e4 d2 d4 } c4 } #]
189 \test ##[ \tuplet 3/2 2 { c4 d4 e4 \tuplet 5/2 2 { f4 e4 d2 d4 } c4 } #]
190
191 %% pure rhythm
192 \test ##[ { 4 4 8 \tuplet 3/2 { 8[ 16] } 16 } #]
193
194 %% \relative and \transpose
195 \test #"NOT A BUG" ##[ \relative { c'4 b4 } #]  % RelativeOctaveMusic
196 \test #"NOT A BUG" ##[ \transpose c d { c4 d4 } #]      % TransposedMusic
197
198 %% Repeats
199 \test ##[ \repeat volta 2 { c4 d4 } #]                  % VoltaRepeatedMusic
200 \test ##[ \repeat unfold 2 { c4 d4 } #]                 % UnfoldedRepeatedMusic
201 \test ##[ \repeat percent 2 { c4 d4 } #]                % PercentRepeatedMusic
202 \test ##[ \repeat tremolo 4 { c16 d16 } #]              % TremoloRepeatedMusic
203 \test ##[ \repeat tremolo 7 { c''32 b'32 } #]
204 \test ##[ \repeat tremolo 15 { c''16 b'16 } #]
205 \test ##[ \repeat volta 2 { c4 d4 } \alternative { { c4 d4 } { e4 f4 } } #]    % 
206
207 %% Context creation
208 \test ##[ \new Staff { c4 d4 } #]                       % ContextSpeccedMusic
209 \test ##[ \new Staff = "up" { c4 d4 } #]                % ContextSpeccedMusic
210 \test ##[ \context Staff { c4 d4 } #]
211 \test ##[ \context Staff = "up" { c4 d4 } #]
212 \test ##[
213 \new Staff \with {
214   \consists "Timing_engraver"
215   \remove "Clef_engraver"
216 } { c4 d4 } #]
217 %% Context properties
218 \test ##[ \once \set Score.skipBars = ##t #]            % PropertySet
219 \test ##[ \set autoBeaming = ##f #]
220 \test ##[ \unset Score.skipBars #]                      % PropertyUnset
221 \test ##[ \unset autoBeaming #]
222 %% Layout properties
223 \test ##[ \override Staff.Stem.thickness = #4.0 #]      % OverrideProperty
224 \test ##[ \once \override Beam.beam-thickness = #0.6 #]
225 \test ##[ \revert Staff.Stem.thickness #]               % RevertProperty
226 \test ##[ \revert Beam.beam-thickness #]
227 \test "NOT A BUG" ##[ \oneVoice #]      % resetting a bunch of properties
228 \test ##[ \override StaffGrouper.staff-staff-spacing.basic-distance = #7 #]    % nested properties
229 \test ##[ \revert StaffGrouper.staff-staff-spacing.basic-distance #]    % nested properties
230
231 %% \applyOutput
232 \test ##[ \applyOutput Foo #(lambda (arg) (list)) #]
233 \test ##[ \applyOutput Foo.NoteHead #(lambda (arg) (list)) #]
234 %% \applyContext
235 \test ##[ \applyContext #(lambda (arg) (list)) #]
236
237 %% \partial
238 \test ##[ \partial 2 #]
239 \test ##[ \partial 8. #]
240 \test ##[ \partial 4*2/3 #]
241
242 %% \partcombine
243 \test ##[ \partcombine { c4 e4 }
244 { d4 f4 } #]
245 \test ##[ \partcombineUp { c2 e2 }
246 { d2 f2 } #]
247 \test ##[ \partcombineDown { c1 e1 }
248 { d1 f1 } #]
249
250 %% Cue notes
251 \test ##[ \cueDuring #"foo" #1 { c4 d4 } #]
252 \test ##[ \quoteDuring #"foo" { c4 d4 } #]
253
254 %% \ottava
255 \test ##[ \ottava #1 #]    % OttavaMusic
256
257 %% \tweak
258 \test ##[ < \tweak duration-log #2 c >4 #]
259 \test ##[ < c \tweak transparent ##t e >4 #]
260 \test ##[ < \tweak color #'(1.0 0.0 0.0) \tweak duration-log #2 c >4 #]
261 \test ##[ c4-\tweak font-size #3 -> #]
262 \test ##[ < \tweak Accidental.color #'(1.0 0.0 0.0) cis eis g >4 #]
263
264 %% end test.
265
266 #(read-hash-extend #\[ #f) %{ ] %}