corrade-nucleus-nucleons – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
2 | office | 1 | #!/usr/bin/env python |
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | ''' |
||
5 | AUTO-GENERATED. DO NOT MODIFY. |
||
6 | Script: test/generate-tests.js |
||
7 | Template: test/data/css/python.mustache |
||
8 | Data: test/data/css/tests.js |
||
9 | |||
10 | The MIT License (MIT) |
||
11 | |||
12 | Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. |
||
13 | |||
14 | Permission is hereby granted, free of charge, to any person |
||
15 | obtaining a copy of this software and associated documentation files |
||
16 | (the "Software"), to deal in the Software without restriction, |
||
17 | including without limitation the rights to use, copy, modify, merge, |
||
18 | publish, distribute, sublicense, and/or sell copies of the Software, |
||
19 | and to permit persons to whom the Software is furnished to do so, |
||
20 | subject to the following conditions: |
||
21 | |||
22 | The above copyright notice and this permission notice shall be |
||
23 | included in all copies or substantial portions of the Software. |
||
24 | |||
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
26 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
27 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||
28 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
||
29 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
||
30 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
31 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
32 | SOFTWARE. |
||
33 | ''' |
||
34 | |||
35 | import unittest |
||
36 | import cssbeautifier |
||
37 | import copy |
||
38 | |||
39 | class CSSBeautifierTest(unittest.TestCase): |
||
40 | |||
41 | options = None |
||
42 | |||
43 | @classmethod |
||
44 | def setUpClass(cls): |
||
45 | false = False |
||
46 | true = True |
||
47 | |||
48 | default_options = cssbeautifier.default_options() |
||
49 | default_options.indent_size = 1 |
||
50 | default_options.indent_char = '\t' |
||
51 | default_options.selector_separator_newline = true |
||
52 | default_options.end_with_newline = false |
||
53 | default_options.newline_between_rules = false |
||
54 | |||
55 | default_options.indent_size = 1 |
||
56 | default_options.indent_char = '\t' |
||
57 | default_options.selector_separator_newline = true |
||
58 | default_options.end_with_newline = false |
||
59 | default_options.newline_between_rules = false |
||
60 | default_options.space_around_combinator = false |
||
61 | default_options.preserve_newlines = false |
||
62 | default_options.space_around_selector_separator = false |
||
63 | |||
64 | cls.default_options = default_options |
||
65 | |||
66 | def reset_options(self): |
||
67 | self.options = copy.copy(self.default_options) |
||
68 | |||
69 | def testGenerated(self): |
||
70 | self.reset_options() |
||
71 | test_fragment = self.decodesto |
||
72 | t = self.decodesto |
||
73 | |||
74 | false = False |
||
75 | true = True |
||
76 | |||
77 | |||
78 | #============================================================ |
||
79 | # End With Newline - (eof = "\n") |
||
80 | self.reset_options(); |
||
81 | self.options.end_with_newline = true |
||
82 | test_fragment('', '\n') |
||
83 | test_fragment(' .tabs{}', ' .tabs {}\n') |
||
84 | test_fragment( |
||
85 | ' \n' + |
||
86 | '\n' + |
||
87 | '.tabs{}\n' + |
||
88 | '\n' + |
||
89 | '\n' + |
||
90 | '\n', |
||
91 | # -- output -- |
||
92 | ' .tabs {}\n') |
||
93 | test_fragment('\n') |
||
94 | |||
95 | # End With Newline - (eof = "") |
||
96 | self.reset_options(); |
||
97 | self.options.end_with_newline = false |
||
98 | test_fragment('') |
||
99 | test_fragment(' .tabs{}', ' .tabs {}') |
||
100 | test_fragment( |
||
101 | ' \n' + |
||
102 | '\n' + |
||
103 | '.tabs{}\n' + |
||
104 | '\n' + |
||
105 | '\n' + |
||
106 | '\n', |
||
107 | # -- output -- |
||
108 | ' .tabs {}') |
||
109 | test_fragment('\n', '') |
||
110 | |||
111 | |||
112 | #============================================================ |
||
113 | # Empty braces |
||
114 | self.reset_options(); |
||
115 | t('.tabs{}', '.tabs {}') |
||
116 | t('.tabs { }', '.tabs {}') |
||
117 | t('.tabs { }', '.tabs {}') |
||
118 | t( |
||
119 | '.tabs \n' + |
||
120 | '{\n' + |
||
121 | ' \n' + |
||
122 | ' }', |
||
123 | # -- output -- |
||
124 | '.tabs {}') |
||
125 | |||
126 | |||
127 | #============================================================ |
||
128 | # |
||
129 | self.reset_options(); |
||
130 | t( |
||
131 | '#cboxOverlay {\n' + |
||
132 | '\tbackground: url(images/overlay.png) repeat 0 0;\n' + |
||
133 | '\topacity: 0.9;\n' + |
||
134 | '\tfilter: alpha(opacity = 90);\n' + |
||
135 | '}', |
||
136 | # -- output -- |
||
137 | '#cboxOverlay {\n' + |
||
138 | '\tbackground: url(images/overlay.png) repeat 0 0;\n' + |
||
139 | '\topacity: 0.9;\n' + |
||
140 | '\tfilter: alpha(opacity=90);\n' + |
||
141 | '}') |
||
142 | |||
143 | |||
144 | #============================================================ |
||
145 | # Support simple language specific option inheritance/overriding - (c = " ") |
||
146 | self.reset_options(); |
||
147 | self.options.indent_char = ' ' |
||
148 | self.options.indent_size = 4 |
||
149 | self.options.js = { 'indent_size': 3 } |
||
150 | self.options.css = { 'indent_size': 5 } |
||
151 | t( |
||
152 | '.selector {\n' + |
||
153 | ' font-size: 12px;\n' + |
||
154 | '}') |
||
155 | |||
156 | # Support simple language specific option inheritance/overriding - (c = " ") |
||
157 | self.reset_options(); |
||
158 | self.options.indent_char = ' ' |
||
159 | self.options.indent_size = 4 |
||
160 | self.options.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 } } |
||
161 | t( |
||
162 | '.selector {\n' + |
||
163 | ' font-size: 12px;\n' + |
||
164 | '}') |
||
165 | |||
166 | # Support simple language specific option inheritance/overriding - (c = " ") |
||
167 | self.reset_options(); |
||
168 | self.options.indent_char = ' ' |
||
169 | self.options.indent_size = 9 |
||
170 | self.options.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 8 }, 'indent_size': 2} |
||
171 | self.options.js = { 'indent_size': 5 } |
||
172 | self.options.css = { 'indent_size': 3 } |
||
173 | t( |
||
174 | '.selector {\n' + |
||
175 | ' font-size: 12px;\n' + |
||
176 | '}') |
||
177 | |||
178 | |||
179 | #============================================================ |
||
180 | # Space Around Combinator - (space = " ") |
||
181 | self.reset_options(); |
||
182 | self.options.space_around_combinator = true |
||
183 | t('a>b{}', 'a > b {}') |
||
184 | t('a~b{}', 'a ~ b {}') |
||
185 | t('a+b{}', 'a + b {}') |
||
186 | t('a+b>c{}', 'a + b > c {}') |
||
187 | t('a > b{}', 'a > b {}') |
||
188 | t('a ~ b{}', 'a ~ b {}') |
||
189 | t('a + b{}', 'a + b {}') |
||
190 | t('a + b > c{}', 'a + b > c {}') |
||
191 | t( |
||
192 | 'a > b{width: calc(100% + 45px);}', |
||
193 | # -- output -- |
||
194 | 'a > b {\n' + |
||
195 | '\twidth: calc(100% + 45px);\n' + |
||
196 | '}') |
||
197 | t( |
||
198 | 'a ~ b{width: calc(100% + 45px);}', |
||
199 | # -- output -- |
||
200 | 'a ~ b {\n' + |
||
201 | '\twidth: calc(100% + 45px);\n' + |
||
202 | '}') |
||
203 | t( |
||
204 | 'a + b{width: calc(100% + 45px);}', |
||
205 | # -- output -- |
||
206 | 'a + b {\n' + |
||
207 | '\twidth: calc(100% + 45px);\n' + |
||
208 | '}') |
||
209 | t( |
||
210 | 'a + b > c{width: calc(100% + 45px);}', |
||
211 | # -- output -- |
||
212 | 'a + b > c {\n' + |
||
213 | '\twidth: calc(100% + 45px);\n' + |
||
214 | '}') |
||
215 | |||
216 | # Space Around Combinator - (space = "") |
||
217 | self.reset_options(); |
||
218 | self.options.space_around_combinator = false |
||
219 | t('a>b{}', 'a>b {}') |
||
220 | t('a~b{}', 'a~b {}') |
||
221 | t('a+b{}', 'a+b {}') |
||
222 | t('a+b>c{}', 'a+b>c {}') |
||
223 | t('a > b{}', 'a>b {}') |
||
224 | t('a ~ b{}', 'a~b {}') |
||
225 | t('a + b{}', 'a+b {}') |
||
226 | t('a + b > c{}', 'a+b>c {}') |
||
227 | t( |
||
228 | 'a > b{width: calc(100% + 45px);}', |
||
229 | # -- output -- |
||
230 | 'a>b {\n' + |
||
231 | '\twidth: calc(100% + 45px);\n' + |
||
232 | '}') |
||
233 | t( |
||
234 | 'a ~ b{width: calc(100% + 45px);}', |
||
235 | # -- output -- |
||
236 | 'a~b {\n' + |
||
237 | '\twidth: calc(100% + 45px);\n' + |
||
238 | '}') |
||
239 | t( |
||
240 | 'a + b{width: calc(100% + 45px);}', |
||
241 | # -- output -- |
||
242 | 'a+b {\n' + |
||
243 | '\twidth: calc(100% + 45px);\n' + |
||
244 | '}') |
||
245 | t( |
||
246 | 'a + b > c{width: calc(100% + 45px);}', |
||
247 | # -- output -- |
||
248 | 'a+b>c {\n' + |
||
249 | '\twidth: calc(100% + 45px);\n' + |
||
250 | '}') |
||
251 | |||
252 | # Space Around Combinator - (space = " ") |
||
253 | self.reset_options(); |
||
254 | self.options.space_around_selector_separator = true |
||
255 | t('a>b{}', 'a > b {}') |
||
256 | t('a~b{}', 'a ~ b {}') |
||
257 | t('a+b{}', 'a + b {}') |
||
258 | t('a+b>c{}', 'a + b > c {}') |
||
259 | t('a > b{}', 'a > b {}') |
||
260 | t('a ~ b{}', 'a ~ b {}') |
||
261 | t('a + b{}', 'a + b {}') |
||
262 | t('a + b > c{}', 'a + b > c {}') |
||
263 | t( |
||
264 | 'a > b{width: calc(100% + 45px);}', |
||
265 | # -- output -- |
||
266 | 'a > b {\n' + |
||
267 | '\twidth: calc(100% + 45px);\n' + |
||
268 | '}') |
||
269 | t( |
||
270 | 'a ~ b{width: calc(100% + 45px);}', |
||
271 | # -- output -- |
||
272 | 'a ~ b {\n' + |
||
273 | '\twidth: calc(100% + 45px);\n' + |
||
274 | '}') |
||
275 | t( |
||
276 | 'a + b{width: calc(100% + 45px);}', |
||
277 | # -- output -- |
||
278 | 'a + b {\n' + |
||
279 | '\twidth: calc(100% + 45px);\n' + |
||
280 | '}') |
||
281 | t( |
||
282 | 'a + b > c{width: calc(100% + 45px);}', |
||
283 | # -- output -- |
||
284 | 'a + b > c {\n' + |
||
285 | '\twidth: calc(100% + 45px);\n' + |
||
286 | '}') |
||
287 | |||
288 | |||
289 | #============================================================ |
||
290 | # Selector Separator - (separator = " ", separator1 = " ") |
||
291 | self.reset_options(); |
||
292 | self.options.selector_separator_newline = false |
||
293 | self.options.selector_separator = " " |
||
294 | t( |
||
295 | '#bla, #foo{color:green}', |
||
296 | # -- output -- |
||
297 | '#bla, #foo {\n' + |
||
298 | '\tcolor: green\n' + |
||
299 | '}') |
||
300 | t( |
||
301 | '@media print {.tab{}}', |
||
302 | # -- output -- |
||
303 | '@media print {\n' + |
||
304 | '\t.tab {}\n' + |
||
305 | '}') |
||
306 | t( |
||
307 | '@media print {.tab,.bat{}}', |
||
308 | # -- output -- |
||
309 | '@media print {\n' + |
||
310 | '\t.tab, .bat {}\n' + |
||
311 | '}') |
||
312 | t( |
||
313 | '#bla, #foo{color:black}', |
||
314 | # -- output -- |
||
315 | '#bla, #foo {\n' + |
||
316 | '\tcolor: black\n' + |
||
317 | '}') |
||
318 | t( |
||
319 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
320 | # -- output -- |
||
321 | 'a:first-child, a:first-child {\n' + |
||
322 | '\tcolor: red;\n' + |
||
323 | '\tdiv:first-child, div:hover {\n' + |
||
324 | '\t\tcolor: black;\n' + |
||
325 | '\t}\n' + |
||
326 | '}') |
||
327 | |||
328 | # Selector Separator - (separator = " ", separator1 = " ") |
||
329 | self.reset_options(); |
||
330 | self.options.selector_separator_newline = false |
||
331 | self.options.selector_separator = " " |
||
332 | t( |
||
333 | '#bla, #foo{color:green}', |
||
334 | # -- output -- |
||
335 | '#bla, #foo {\n' + |
||
336 | '\tcolor: green\n' + |
||
337 | '}') |
||
338 | t( |
||
339 | '@media print {.tab{}}', |
||
340 | # -- output -- |
||
341 | '@media print {\n' + |
||
342 | '\t.tab {}\n' + |
||
343 | '}') |
||
344 | t( |
||
345 | '@media print {.tab,.bat{}}', |
||
346 | # -- output -- |
||
347 | '@media print {\n' + |
||
348 | '\t.tab, .bat {}\n' + |
||
349 | '}') |
||
350 | t( |
||
351 | '#bla, #foo{color:black}', |
||
352 | # -- output -- |
||
353 | '#bla, #foo {\n' + |
||
354 | '\tcolor: black\n' + |
||
355 | '}') |
||
356 | t( |
||
357 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
358 | # -- output -- |
||
359 | 'a:first-child, a:first-child {\n' + |
||
360 | '\tcolor: red;\n' + |
||
361 | '\tdiv:first-child, div:hover {\n' + |
||
362 | '\t\tcolor: black;\n' + |
||
363 | '\t}\n' + |
||
364 | '}') |
||
365 | |||
366 | # Selector Separator - (separator = "\n", separator1 = "\n\t") |
||
367 | self.reset_options(); |
||
368 | self.options.selector_separator_newline = true |
||
369 | self.options.selector_separator = " " |
||
370 | t( |
||
371 | '#bla, #foo{color:green}', |
||
372 | # -- output -- |
||
373 | '#bla,\n#foo {\n' + |
||
374 | '\tcolor: green\n' + |
||
375 | '}') |
||
376 | t( |
||
377 | '@media print {.tab{}}', |
||
378 | # -- output -- |
||
379 | '@media print {\n' + |
||
380 | '\t.tab {}\n' + |
||
381 | '}') |
||
382 | t( |
||
383 | '@media print {.tab,.bat{}}', |
||
384 | # -- output -- |
||
385 | '@media print {\n' + |
||
386 | '\t.tab,\n\t.bat {}\n' + |
||
387 | '}') |
||
388 | t( |
||
389 | '#bla, #foo{color:black}', |
||
390 | # -- output -- |
||
391 | '#bla,\n#foo {\n' + |
||
392 | '\tcolor: black\n' + |
||
393 | '}') |
||
394 | t( |
||
395 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
396 | # -- output -- |
||
397 | 'a:first-child,\na:first-child {\n' + |
||
398 | '\tcolor: red;\n' + |
||
399 | '\tdiv:first-child,\n\tdiv:hover {\n' + |
||
400 | '\t\tcolor: black;\n' + |
||
401 | '\t}\n' + |
||
402 | '}') |
||
403 | |||
404 | # Selector Separator - (separator = "\n", separator1 = "\n\t") |
||
405 | self.reset_options(); |
||
406 | self.options.selector_separator_newline = true |
||
407 | self.options.selector_separator = " " |
||
408 | t( |
||
409 | '#bla, #foo{color:green}', |
||
410 | # -- output -- |
||
411 | '#bla,\n#foo {\n' + |
||
412 | '\tcolor: green\n' + |
||
413 | '}') |
||
414 | t( |
||
415 | '@media print {.tab{}}', |
||
416 | # -- output -- |
||
417 | '@media print {\n' + |
||
418 | '\t.tab {}\n' + |
||
419 | '}') |
||
420 | t( |
||
421 | '@media print {.tab,.bat{}}', |
||
422 | # -- output -- |
||
423 | '@media print {\n' + |
||
424 | '\t.tab,\n\t.bat {}\n' + |
||
425 | '}') |
||
426 | t( |
||
427 | '#bla, #foo{color:black}', |
||
428 | # -- output -- |
||
429 | '#bla,\n#foo {\n' + |
||
430 | '\tcolor: black\n' + |
||
431 | '}') |
||
432 | t( |
||
433 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
434 | # -- output -- |
||
435 | 'a:first-child,\na:first-child {\n' + |
||
436 | '\tcolor: red;\n' + |
||
437 | '\tdiv:first-child,\n\tdiv:hover {\n' + |
||
438 | '\t\tcolor: black;\n' + |
||
439 | '\t}\n' + |
||
440 | '}') |
||
441 | |||
442 | |||
443 | #============================================================ |
||
444 | # Preserve Newlines - (separator_input = "\n\n", separator_output = "\n\n") |
||
445 | self.reset_options(); |
||
446 | self.options.preserve_newlines = true |
||
447 | t('.div {}\n\n.span {}') |
||
448 | t( |
||
449 | '#bla, #foo{\n' + |
||
450 | '\tcolor:black;\n\n\tfont-size: 12px;\n' + |
||
451 | '}', |
||
452 | # -- output -- |
||
453 | '#bla,\n' + |
||
454 | '#foo {\n' + |
||
455 | '\tcolor: black;\n\n\tfont-size: 12px;\n' + |
||
456 | '}') |
||
457 | |||
458 | # Preserve Newlines - (separator_input = "\n\n", separator_output = "\n") |
||
459 | self.reset_options(); |
||
460 | self.options.preserve_newlines = false |
||
461 | t('.div {}\n\n.span {}', '.div {}\n.span {}') |
||
462 | t( |
||
463 | '#bla, #foo{\n' + |
||
464 | '\tcolor:black;\n\n\tfont-size: 12px;\n' + |
||
465 | '}', |
||
466 | # -- output -- |
||
467 | '#bla,\n' + |
||
468 | '#foo {\n' + |
||
469 | '\tcolor: black;\n\tfont-size: 12px;\n' + |
||
470 | '}') |
||
471 | |||
472 | |||
473 | #============================================================ |
||
474 | # Preserve Newlines and newline_between_rules |
||
475 | self.reset_options(); |
||
476 | self.options.preserve_newlines = true |
||
477 | self.options.newline_between_rules = true |
||
478 | t( |
||
479 | '.div {}.span {}', |
||
480 | # -- output -- |
||
481 | '.div {}\n' + |
||
482 | '\n' + |
||
483 | '.span {}') |
||
484 | t( |
||
485 | '#bla, #foo{\n' + |
||
486 | '\tcolor:black;\n' + |
||
487 | '\tfont-size: 12px;\n' + |
||
488 | '}', |
||
489 | # -- output -- |
||
490 | '#bla,\n' + |
||
491 | '#foo {\n' + |
||
492 | '\tcolor: black;\n' + |
||
493 | '\tfont-size: 12px;\n' + |
||
494 | '}') |
||
495 | t( |
||
496 | '#bla, #foo{\n' + |
||
497 | '\tcolor:black;\n' + |
||
498 | '\n' + |
||
499 | '\n' + |
||
500 | '\tfont-size: 12px;\n' + |
||
501 | '}', |
||
502 | # -- output -- |
||
503 | '#bla,\n' + |
||
504 | '#foo {\n' + |
||
505 | '\tcolor: black;\n' + |
||
506 | '\n' + |
||
507 | '\n' + |
||
508 | '\tfont-size: 12px;\n' + |
||
509 | '}') |
||
510 | t( |
||
511 | '#bla,\n' + |
||
512 | '\n' + |
||
513 | '#foo {\n' + |
||
514 | '\tcolor: black;\n' + |
||
515 | '\tfont-size: 12px;\n' + |
||
516 | '}') |
||
517 | t( |
||
518 | 'a {\n' + |
||
519 | '\tb: c;\n' + |
||
520 | '\n' + |
||
521 | '\n' + |
||
522 | '\td: {\n' + |
||
523 | '\t\te: f;\n' + |
||
524 | '\t}\n' + |
||
525 | '}') |
||
526 | t( |
||
527 | '.div {}\n' + |
||
528 | '\n' + |
||
529 | '.span {}') |
||
530 | t( |
||
531 | '.div {\n' + |
||
532 | '\ta: 1;\n' + |
||
533 | '\n' + |
||
534 | '\n' + |
||
535 | '\tb: 2;\n' + |
||
536 | '}\n' + |
||
537 | '\n' + |
||
538 | '\n' + |
||
539 | '\n' + |
||
540 | '.span {\n' + |
||
541 | '\ta: 1;\n' + |
||
542 | '}') |
||
543 | t( |
||
544 | '.div {\n' + |
||
545 | '\n' + |
||
546 | '\n' + |
||
547 | '\ta: 1;\n' + |
||
548 | '\n' + |
||
549 | '\n' + |
||
550 | '\tb: 2;\n' + |
||
551 | '}\n' + |
||
552 | '\n' + |
||
553 | '\n' + |
||
554 | '\n' + |
||
555 | '.span {\n' + |
||
556 | '\ta: 1;\n' + |
||
557 | '}') |
||
558 | t( |
||
559 | '@media screen {\n' + |
||
560 | '\t.div {\n' + |
||
561 | '\t\ta: 1;\n' + |
||
562 | '\n' + |
||
563 | '\n' + |
||
564 | '\t\tb: 2;\n' + |
||
565 | '\t}\n' + |
||
566 | '\n' + |
||
567 | '\n' + |
||
568 | '\n' + |
||
569 | '\t.span {\n' + |
||
570 | '\t\ta: 1;\n' + |
||
571 | '\t}\n' + |
||
572 | '}\n' + |
||
573 | '\n' + |
||
574 | '.div {}\n' + |
||
575 | '\n' + |
||
576 | '.span {}') |
||
577 | |||
578 | |||
579 | #============================================================ |
||
580 | # Preserve Newlines and add tabs |
||
581 | self.reset_options(); |
||
582 | self.options.preserve_newlines = true |
||
583 | t( |
||
584 | '.tool-tip {\n' + |
||
585 | '\tposition: relative;\n' + |
||
586 | '\n' + |
||
587 | '\t\t\n' + |
||
588 | '\t.tool-tip-content {\n' + |
||
589 | '\t\t&>* {\n' + |
||
590 | '\t\t\tmargin-top: 0;\n' + |
||
591 | '\t\t}\n' + |
||
592 | '\t\t\n' + |
||
593 | '\n' + |
||
594 | '\t\t.mixin-box-shadow(.2rem .2rem .5rem rgba(0, 0, 0, .15));\n' + |
||
595 | '\t\tpadding: 1rem;\n' + |
||
596 | '\t\tposition: absolute;\n' + |
||
597 | '\t\tz-index: 10;\n' + |
||
598 | '\t}\n' + |
||
599 | '}', |
||
600 | # -- output -- |
||
601 | '.tool-tip {\n' + |
||
602 | '\tposition: relative;\n' + |
||
603 | '\n' + |
||
604 | '\n' + |
||
605 | '\t.tool-tip-content {\n' + |
||
606 | '\t\t&>* {\n' + |
||
607 | '\t\t\tmargin-top: 0;\n' + |
||
608 | '\t\t}\n' + |
||
609 | '\n\n\t\t.mixin-box-shadow(.2rem .2rem .5rem rgba(0, 0, 0, .15));\n' + |
||
610 | '\t\tpadding: 1rem;\n' + |
||
611 | '\t\tposition: absolute;\n' + |
||
612 | '\t\tz-index: 10;\n' + |
||
613 | '\t}\n' + |
||
614 | '}') |
||
615 | |||
616 | |||
617 | #============================================================ |
||
618 | # Newline Between Rules - (separator = "\n") |
||
619 | self.reset_options(); |
||
620 | self.options.newline_between_rules = true |
||
621 | t( |
||
622 | '.div {}\n' + |
||
623 | '.span {}', |
||
624 | # -- output -- |
||
625 | '.div {}\n' + |
||
626 | '\n.span {}') |
||
627 | t( |
||
628 | '.div{}\n' + |
||
629 | ' \n' + |
||
630 | '.span{}', |
||
631 | # -- output -- |
||
632 | '.div {}\n' + |
||
633 | '\n.span {}') |
||
634 | t( |
||
635 | '.div {} \n' + |
||
636 | ' \n' + |
||
637 | '.span { } \n', |
||
638 | # -- output -- |
||
639 | '.div {}\n' + |
||
640 | '\n.span {}') |
||
641 | t( |
||
642 | '.div {\n' + |
||
643 | ' \n' + |
||
644 | '} \n' + |
||
645 | ' .span {\n' + |
||
646 | ' } ', |
||
647 | # -- output -- |
||
648 | '.div {}\n' + |
||
649 | '\n.span {}') |
||
650 | t( |
||
651 | '.selector1 {\n' + |
||
652 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
653 | '}\n' + |
||
654 | '.div{height:15px;}', |
||
655 | # -- output -- |
||
656 | '.selector1 {\n' + |
||
657 | '\tmargin: 0;\n' + |
||
658 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
659 | '}\n' + |
||
660 | '\n.div {\n' + |
||
661 | '\theight: 15px;\n' + |
||
662 | '}') |
||
663 | t( |
||
664 | '.tabs{width:10px;//end of line comment\n' + |
||
665 | 'height:10px;//another\n' + |
||
666 | '}\n' + |
||
667 | '.div{height:15px;}', |
||
668 | # -- output -- |
||
669 | '.tabs {\n' + |
||
670 | '\twidth: 10px; //end of line comment\n' + |
||
671 | '\theight: 10px; //another\n' + |
||
672 | '}\n' + |
||
673 | '\n.div {\n' + |
||
674 | '\theight: 15px;\n' + |
||
675 | '}') |
||
676 | t( |
||
677 | '#foo {\n' + |
||
678 | '\tbackground-image: url(foo@2x.png);\n' + |
||
679 | '\t@font-face {\n' + |
||
680 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
681 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
682 | '\t}\n' + |
||
683 | '}\n' + |
||
684 | '.div{height:15px;}', |
||
685 | # -- output -- |
||
686 | '#foo {\n' + |
||
687 | '\tbackground-image: url(foo@2x.png);\n' + |
||
688 | '\t@font-face {\n' + |
||
689 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
690 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
691 | '\t}\n' + |
||
692 | '}\n' + |
||
693 | '\n.div {\n' + |
||
694 | '\theight: 15px;\n' + |
||
695 | '}') |
||
696 | t( |
||
697 | '@media screen {\n' + |
||
698 | '\t#foo:hover {\n' + |
||
699 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
700 | '\t}\n' + |
||
701 | '\t@font-face {\n' + |
||
702 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
703 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
704 | '\t}\n' + |
||
705 | '}\n' + |
||
706 | '.div{height:15px;}', |
||
707 | # -- output -- |
||
708 | '@media screen {\n' + |
||
709 | '\t#foo:hover {\n' + |
||
710 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
711 | '\t}\n' + |
||
712 | '\t@font-face {\n' + |
||
713 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
714 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
715 | '\t}\n' + |
||
716 | '}\n' + |
||
717 | '\n.div {\n' + |
||
718 | '\theight: 15px;\n' + |
||
719 | '}') |
||
720 | t( |
||
721 | '@font-face {\n' + |
||
722 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
723 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
724 | '}\n' + |
||
725 | '@media screen {\n' + |
||
726 | '\t#foo:hover {\n' + |
||
727 | '\t\tbackground-image: url(foo.png);\n' + |
||
728 | '\t}\n' + |
||
729 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
730 | '\t\t@font-face {\n' + |
||
731 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
732 | '\t\t}\n' + |
||
733 | '\t\t#foo:hover {\n' + |
||
734 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
735 | '\t\t}\n' + |
||
736 | '\t}\n' + |
||
737 | '}', |
||
738 | # -- output -- |
||
739 | '@font-face {\n' + |
||
740 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
741 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
742 | '}\n' + |
||
743 | '\n@media screen {\n' + |
||
744 | '\t#foo:hover {\n' + |
||
745 | '\t\tbackground-image: url(foo.png);\n' + |
||
746 | '\t}\n' + |
||
747 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
748 | '\t\t@font-face {\n' + |
||
749 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
750 | '\t\t}\n' + |
||
751 | '\t\t#foo:hover {\n' + |
||
752 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
753 | '\t\t}\n' + |
||
754 | '\t}\n' + |
||
755 | '}') |
||
756 | t( |
||
757 | 'a:first-child{color:red;div:first-child{color:black;}}\n' + |
||
758 | '.div{height:15px;}', |
||
759 | # -- output -- |
||
760 | 'a:first-child {\n' + |
||
761 | '\tcolor: red;\n' + |
||
762 | '\tdiv:first-child {\n' + |
||
763 | '\t\tcolor: black;\n' + |
||
764 | '\t}\n' + |
||
765 | '}\n' + |
||
766 | '\n.div {\n' + |
||
767 | '\theight: 15px;\n' + |
||
768 | '}') |
||
769 | t( |
||
770 | 'a:first-child{color:red;div:not(.peq){color:black;}}\n' + |
||
771 | '.div{height:15px;}', |
||
772 | # -- output -- |
||
773 | 'a:first-child {\n' + |
||
774 | '\tcolor: red;\n' + |
||
775 | '\tdiv:not(.peq) {\n' + |
||
776 | '\t\tcolor: black;\n' + |
||
777 | '\t}\n' + |
||
778 | '}\n' + |
||
779 | '\n.div {\n' + |
||
780 | '\theight: 15px;\n' + |
||
781 | '}') |
||
782 | |||
783 | # Newline Between Rules - (separator = "") |
||
784 | self.reset_options(); |
||
785 | self.options.newline_between_rules = false |
||
786 | t( |
||
787 | '.div {}\n' + |
||
788 | '.span {}') |
||
789 | t( |
||
790 | '.div{}\n' + |
||
791 | ' \n' + |
||
792 | '.span{}', |
||
793 | # -- output -- |
||
794 | '.div {}\n' + |
||
795 | '.span {}') |
||
796 | t( |
||
797 | '.div {} \n' + |
||
798 | ' \n' + |
||
799 | '.span { } \n', |
||
800 | # -- output -- |
||
801 | '.div {}\n' + |
||
802 | '.span {}') |
||
803 | t( |
||
804 | '.div {\n' + |
||
805 | ' \n' + |
||
806 | '} \n' + |
||
807 | ' .span {\n' + |
||
808 | ' } ', |
||
809 | # -- output -- |
||
810 | '.div {}\n' + |
||
811 | '.span {}') |
||
812 | t( |
||
813 | '.selector1 {\n' + |
||
814 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
815 | '}\n' + |
||
816 | '.div{height:15px;}', |
||
817 | # -- output -- |
||
818 | '.selector1 {\n' + |
||
819 | '\tmargin: 0;\n' + |
||
820 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
821 | '}\n' + |
||
822 | '.div {\n' + |
||
823 | '\theight: 15px;\n' + |
||
824 | '}') |
||
825 | t( |
||
826 | '.tabs{width:10px;//end of line comment\n' + |
||
827 | 'height:10px;//another\n' + |
||
828 | '}\n' + |
||
829 | '.div{height:15px;}', |
||
830 | # -- output -- |
||
831 | '.tabs {\n' + |
||
832 | '\twidth: 10px; //end of line comment\n' + |
||
833 | '\theight: 10px; //another\n' + |
||
834 | '}\n' + |
||
835 | '.div {\n' + |
||
836 | '\theight: 15px;\n' + |
||
837 | '}') |
||
838 | t( |
||
839 | '#foo {\n' + |
||
840 | '\tbackground-image: url(foo@2x.png);\n' + |
||
841 | '\t@font-face {\n' + |
||
842 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
843 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
844 | '\t}\n' + |
||
845 | '}\n' + |
||
846 | '.div{height:15px;}', |
||
847 | # -- output -- |
||
848 | '#foo {\n' + |
||
849 | '\tbackground-image: url(foo@2x.png);\n' + |
||
850 | '\t@font-face {\n' + |
||
851 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
852 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
853 | '\t}\n' + |
||
854 | '}\n' + |
||
855 | '.div {\n' + |
||
856 | '\theight: 15px;\n' + |
||
857 | '}') |
||
858 | t( |
||
859 | '@media screen {\n' + |
||
860 | '\t#foo:hover {\n' + |
||
861 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
862 | '\t}\n' + |
||
863 | '\t@font-face {\n' + |
||
864 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
865 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
866 | '\t}\n' + |
||
867 | '}\n' + |
||
868 | '.div{height:15px;}', |
||
869 | # -- output -- |
||
870 | '@media screen {\n' + |
||
871 | '\t#foo:hover {\n' + |
||
872 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
873 | '\t}\n' + |
||
874 | '\t@font-face {\n' + |
||
875 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
876 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
877 | '\t}\n' + |
||
878 | '}\n' + |
||
879 | '.div {\n' + |
||
880 | '\theight: 15px;\n' + |
||
881 | '}') |
||
882 | t( |
||
883 | '@font-face {\n' + |
||
884 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
885 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
886 | '}\n' + |
||
887 | '@media screen {\n' + |
||
888 | '\t#foo:hover {\n' + |
||
889 | '\t\tbackground-image: url(foo.png);\n' + |
||
890 | '\t}\n' + |
||
891 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
892 | '\t\t@font-face {\n' + |
||
893 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
894 | '\t\t}\n' + |
||
895 | '\t\t#foo:hover {\n' + |
||
896 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
897 | '\t\t}\n' + |
||
898 | '\t}\n' + |
||
899 | '}') |
||
900 | t( |
||
901 | 'a:first-child{color:red;div:first-child{color:black;}}\n' + |
||
902 | '.div{height:15px;}', |
||
903 | # -- output -- |
||
904 | 'a:first-child {\n' + |
||
905 | '\tcolor: red;\n' + |
||
906 | '\tdiv:first-child {\n' + |
||
907 | '\t\tcolor: black;\n' + |
||
908 | '\t}\n' + |
||
909 | '}\n' + |
||
910 | '.div {\n' + |
||
911 | '\theight: 15px;\n' + |
||
912 | '}') |
||
913 | t( |
||
914 | 'a:first-child{color:red;div:not(.peq){color:black;}}\n' + |
||
915 | '.div{height:15px;}', |
||
916 | # -- output -- |
||
917 | 'a:first-child {\n' + |
||
918 | '\tcolor: red;\n' + |
||
919 | '\tdiv:not(.peq) {\n' + |
||
920 | '\t\tcolor: black;\n' + |
||
921 | '\t}\n' + |
||
922 | '}\n' + |
||
923 | '.div {\n' + |
||
924 | '\theight: 15px;\n' + |
||
925 | '}') |
||
926 | |||
927 | |||
928 | #============================================================ |
||
929 | # Functions braces |
||
930 | self.reset_options(); |
||
931 | t('.tabs(){}', '.tabs() {}') |
||
932 | t('.tabs (){}', '.tabs () {}') |
||
933 | t( |
||
934 | '.tabs (pa, pa(1,2)), .cols { }', |
||
935 | # -- output -- |
||
936 | '.tabs (pa, pa(1, 2)),\n' + |
||
937 | '.cols {}') |
||
938 | t( |
||
939 | '.tabs(pa, pa(1,2)), .cols { }', |
||
940 | # -- output -- |
||
941 | '.tabs(pa, pa(1, 2)),\n' + |
||
942 | '.cols {}') |
||
943 | t('.tabs ( ) { }', '.tabs () {}') |
||
944 | t('.tabs( ) { }', '.tabs() {}') |
||
945 | t( |
||
946 | '.tabs (t, t2) \n' + |
||
947 | '{\n' + |
||
948 | ' key: val(p1 ,p2); \n' + |
||
949 | ' }', |
||
950 | # -- output -- |
||
951 | '.tabs (t, t2) {\n' + |
||
952 | '\tkey: val(p1, p2);\n' + |
||
953 | '}') |
||
954 | t( |
||
955 | '.box-shadow(@shadow: 0 1px 3px rgba(0, 0, 0, .25)) {\n' + |
||
956 | '\t-webkit-box-shadow: @shadow;\n' + |
||
957 | '\t-moz-box-shadow: @shadow;\n' + |
||
958 | '\tbox-shadow: @shadow;\n' + |
||
959 | '}') |
||
960 | |||
961 | |||
962 | #============================================================ |
||
963 | # Comments |
||
964 | self.reset_options(); |
||
965 | t('/* test */') |
||
966 | t( |
||
967 | '.tabs{/* test */}', |
||
968 | # -- output -- |
||
969 | '.tabs {\n' + |
||
970 | '\t/* test */\n' + |
||
971 | '}') |
||
972 | t( |
||
973 | '.tabs{/* test */}', |
||
974 | # -- output -- |
||
975 | '.tabs {\n' + |
||
976 | '\t/* test */\n' + |
||
977 | '}') |
||
978 | t( |
||
979 | '/* header */.tabs {}', |
||
980 | # -- output -- |
||
981 | '/* header */\n' + |
||
982 | '\n' + |
||
983 | '.tabs {}') |
||
984 | t( |
||
985 | '.tabs {\n' + |
||
986 | '/* non-header */\n' + |
||
987 | 'width:10px;}', |
||
988 | # -- output -- |
||
989 | '.tabs {\n' + |
||
990 | '\t/* non-header */\n' + |
||
991 | '\twidth: 10px;\n' + |
||
992 | '}') |
||
993 | t('/* header') |
||
994 | t('// comment') |
||
995 | t( |
||
996 | '.selector1 {\n' + |
||
997 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
998 | '}', |
||
999 | # -- output -- |
||
1000 | '.selector1 {\n' + |
||
1001 | '\tmargin: 0;\n' + |
||
1002 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
1003 | '}') |
||
1004 | |||
1005 | # single line comment support (less/sass) |
||
1006 | t( |
||
1007 | '.tabs{\n' + |
||
1008 | '// comment\n' + |
||
1009 | 'width:10px;\n' + |
||
1010 | '}', |
||
1011 | # -- output -- |
||
1012 | '.tabs {\n' + |
||
1013 | '\t// comment\n' + |
||
1014 | '\twidth: 10px;\n' + |
||
1015 | '}') |
||
1016 | t( |
||
1017 | '.tabs{// comment\n' + |
||
1018 | 'width:10px;\n' + |
||
1019 | '}', |
||
1020 | # -- output -- |
||
1021 | '.tabs {\n' + |
||
1022 | '\t// comment\n' + |
||
1023 | '\twidth: 10px;\n' + |
||
1024 | '}') |
||
1025 | t( |
||
1026 | '//comment\n' + |
||
1027 | '.tabs{width:10px;}', |
||
1028 | # -- output -- |
||
1029 | '//comment\n' + |
||
1030 | '.tabs {\n' + |
||
1031 | '\twidth: 10px;\n' + |
||
1032 | '}') |
||
1033 | t( |
||
1034 | '.tabs{//comment\n' + |
||
1035 | '//2nd single line comment\n' + |
||
1036 | 'width:10px;}', |
||
1037 | # -- output -- |
||
1038 | '.tabs {\n' + |
||
1039 | '\t//comment\n' + |
||
1040 | '\t//2nd single line comment\n' + |
||
1041 | '\twidth: 10px;\n' + |
||
1042 | '}') |
||
1043 | t( |
||
1044 | '.tabs{width:10px;//end of line comment\n' + |
||
1045 | '}', |
||
1046 | # -- output -- |
||
1047 | '.tabs {\n' + |
||
1048 | '\twidth: 10px; //end of line comment\n' + |
||
1049 | '}') |
||
1050 | t( |
||
1051 | '.tabs{width:10px;//end of line comment\n' + |
||
1052 | 'height:10px;}', |
||
1053 | # -- output -- |
||
1054 | '.tabs {\n' + |
||
1055 | '\twidth: 10px; //end of line comment\n' + |
||
1056 | '\theight: 10px;\n' + |
||
1057 | '}') |
||
1058 | t( |
||
1059 | '.tabs{width:10px;//end of line comment\n' + |
||
1060 | 'height:10px;//another\n' + |
||
1061 | '}', |
||
1062 | # -- output -- |
||
1063 | '.tabs {\n' + |
||
1064 | '\twidth: 10px; //end of line comment\n' + |
||
1065 | '\theight: 10px; //another\n' + |
||
1066 | '}') |
||
1067 | |||
1068 | |||
1069 | #============================================================ |
||
1070 | # Handle LESS property name interpolation |
||
1071 | self.reset_options(); |
||
1072 | t( |
||
1073 | 'tag {\n' + |
||
1074 | '\t@{prop}: none;\n' + |
||
1075 | '}') |
||
1076 | t( |
||
1077 | 'tag{@{prop}:none;}', |
||
1078 | # -- output -- |
||
1079 | 'tag {\n' + |
||
1080 | '\t@{prop}: none;\n' + |
||
1081 | '}') |
||
1082 | t( |
||
1083 | 'tag{ @{prop}: none;}', |
||
1084 | # -- output -- |
||
1085 | 'tag {\n' + |
||
1086 | '\t@{prop}: none;\n' + |
||
1087 | '}') |
||
1088 | |||
1089 | # can also be part of property name |
||
1090 | t( |
||
1091 | 'tag {\n' + |
||
1092 | '\tdynamic-@{prop}: none;\n' + |
||
1093 | '}') |
||
1094 | t( |
||
1095 | 'tag{dynamic-@{prop}:none;}', |
||
1096 | # -- output -- |
||
1097 | 'tag {\n' + |
||
1098 | '\tdynamic-@{prop}: none;\n' + |
||
1099 | '}') |
||
1100 | t( |
||
1101 | 'tag{ dynamic-@{prop}: none;}', |
||
1102 | # -- output -- |
||
1103 | 'tag {\n' + |
||
1104 | '\tdynamic-@{prop}: none;\n' + |
||
1105 | '}') |
||
1106 | |||
1107 | |||
1108 | #============================================================ |
||
1109 | # Handle LESS property name interpolation, test #631 |
||
1110 | self.reset_options(); |
||
1111 | t( |
||
1112 | '.generate-columns(@n, @i: 1) when (@i =< @n) {\n' + |
||
1113 | '\t.column-@{i} {\n' + |
||
1114 | '\t\twidth: (@i * 100% / @n);\n' + |
||
1115 | '\t}\n' + |
||
1116 | '\t.generate-columns(@n, (@i + 1));\n' + |
||
1117 | '}') |
||
1118 | t( |
||
1119 | '.generate-columns(@n,@i:1) when (@i =< @n){.column-@{i}{width:(@i * 100% / @n);}.generate-columns(@n,(@i + 1));}', |
||
1120 | # -- output -- |
||
1121 | '.generate-columns(@n, @i: 1) when (@i =< @n) {\n' + |
||
1122 | '\t.column-@{i} {\n' + |
||
1123 | '\t\twidth: (@i * 100% / @n);\n' + |
||
1124 | '\t}\n' + |
||
1125 | '\t.generate-columns(@n, (@i + 1));\n' + |
||
1126 | '}') |
||
1127 | |||
1128 | |||
1129 | #============================================================ |
||
1130 | # Psuedo-classes vs Variables |
||
1131 | self.reset_options(); |
||
1132 | t('@page :first {}') |
||
1133 | |||
1134 | # Assume the colon goes with the @name. If we're in LESS, this is required regardless of the at-string. |
||
1135 | t('@page:first {}', '@page: first {}') |
||
1136 | t('@page: first {}') |
||
1137 | |||
1138 | |||
1139 | #============================================================ |
||
1140 | # SASS/SCSS |
||
1141 | self.reset_options(); |
||
1142 | |||
1143 | # Basic Interpolation |
||
1144 | t( |
||
1145 | 'p {\n' + |
||
1146 | '\t$font-size: 12px;\n' + |
||
1147 | '\t$line-height: 30px;\n' + |
||
1148 | '\tfont: #{$font-size}/#{$line-height};\n' + |
||
1149 | '}') |
||
1150 | t('p.#{$name} {}') |
||
1151 | t( |
||
1152 | '@mixin itemPropertiesCoverItem($items, $margin) {\n' + |
||
1153 | '\twidth: calc((100% - ((#{$items} - 1) * #{$margin}rem)) / #{$items});\n' + |
||
1154 | '\tmargin: 1.6rem #{$margin}rem 1.6rem 0;\n' + |
||
1155 | '}') |
||
1156 | |||
1157 | # Multiple filed issues in LESS due to not(:blah) |
||
1158 | t('&:first-of-type:not(:last-child) {}') |
||
1159 | t( |
||
1160 | 'div {\n' + |
||
1161 | '\t&:not(:first-of-type) {\n' + |
||
1162 | '\t\tbackground: red;\n' + |
||
1163 | '\t}\n' + |
||
1164 | '}') |
||
1165 | |||
1166 | |||
1167 | #============================================================ |
||
1168 | # Proper handling of colon in selectors |
||
1169 | self.reset_options(); |
||
1170 | self.options.selector_separator_newline = false |
||
1171 | t('a :b {}') |
||
1172 | t('a ::b {}') |
||
1173 | t('a:b {}') |
||
1174 | t('a::b {}') |
||
1175 | t( |
||
1176 | 'a {}, a::b {}, a ::b {}, a:b {}, a :b {}', |
||
1177 | # -- output -- |
||
1178 | 'a {}\n' + |
||
1179 | ', a::b {}\n' + |
||
1180 | ', a ::b {}\n' + |
||
1181 | ', a:b {}\n' + |
||
1182 | ', a :b {}') |
||
1183 | t( |
||
1184 | '.card-blue ::-webkit-input-placeholder {\n' + |
||
1185 | '\tcolor: #87D1FF;\n' + |
||
1186 | '}') |
||
1187 | t( |
||
1188 | 'div [attr] :not(.class) {\n' + |
||
1189 | '\tcolor: red;\n' + |
||
1190 | '}') |
||
1191 | |||
1192 | |||
1193 | #============================================================ |
||
1194 | # Regresssion Tests |
||
1195 | self.reset_options(); |
||
1196 | self.options.selector_separator_newline = false |
||
1197 | t( |
||
1198 | '@media(min-width:768px) {\n' + |
||
1199 | '\t.selector::after {\n' + |
||
1200 | '\t\t/* property: value */\n' + |
||
1201 | '\t}\n' + |
||
1202 | '\t.other-selector {\n' + |
||
1203 | '\t\t/* property: value */\n' + |
||
1204 | '\t}\n' + |
||
1205 | '}') |
||
1206 | t( |
||
1207 | '.fa-rotate-270 {\n' + |
||
1208 | '\tfilter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);\n' + |
||
1209 | '}') |
||
1210 | |||
1211 | |||
1212 | #============================================================ |
||
1213 | # |
||
1214 | self.reset_options(); |
||
1215 | |||
1216 | |||
1217 | |||
1218 | def testNewline(self): |
||
1219 | self.reset_options() |
||
1220 | t = self.decodesto |
||
1221 | |||
1222 | self.options.end_with_newline = True |
||
1223 | t("", "\n") |
||
1224 | t("\n", "\n") |
||
1225 | t(".tabs{}\n", ".tabs {}\n") |
||
1226 | t(".tabs{}", ".tabs {}\n") |
||
1227 | |||
1228 | def testBasics(self): |
||
1229 | self.reset_options() |
||
1230 | t = self.decodesto |
||
1231 | |||
1232 | t("", "") |
||
1233 | t("\n", "") |
||
1234 | t(".tabs{}\n", ".tabs {}") |
||
1235 | t(".tabs{}", ".tabs {}") |
||
1236 | t(".tabs{color:red}", ".tabs {\n\tcolor: red\n}") |
||
1237 | t(".tabs{color:rgb(255, 255, 0)}", ".tabs {\n\tcolor: rgb(255, 255, 0)\n}") |
||
1238 | t(".tabs{background:url('back.jpg')}", ".tabs {\n\tbackground: url('back.jpg')\n}") |
||
1239 | t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}") |
||
1240 | t("@media print {.tab{}}", "@media print {\n\t.tab {}\n}") |
||
1241 | t("@media print {.tab{background-image:url(foo@2x.png)}}", "@media print {\n\t.tab {\n\t\tbackground-image: url(foo@2x.png)\n\t}\n}") |
||
1242 | |||
1243 | t("a:before {\n" + |
||
1244 | "\tcontent: 'a{color:black;}\"\"\\'\\'\"\\n\\n\\na{color:black}\';\n" + |
||
1245 | "}"); |
||
1246 | |||
1247 | # may not eat the space before "[" |
||
1248 | t('html.js [data-custom="123"] {\n\topacity: 1.00;\n}') |
||
1249 | t('html.js *[data-custom="123"] {\n\topacity: 1.00;\n}') |
||
1250 | |||
1251 | # lead-in whitespace determines base-indent. |
||
1252 | # lead-in newlines are stripped. |
||
1253 | t("\n\na, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") |
||
1254 | t(" a, img {padding: 0.2px}", " a,\n img {\n \tpadding: 0.2px\n }") |
||
1255 | t(" \t \na, img {padding: 0.2px}", " \t a,\n \t img {\n \t \tpadding: 0.2px\n \t }") |
||
1256 | t("\n\n a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") |
||
1257 | |||
1258 | def testSeperateSelectors(self): |
||
1259 | self.reset_options() |
||
1260 | t = self.decodesto |
||
1261 | |||
1262 | t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}") |
||
1263 | t("a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") |
||
1264 | |||
1265 | |||
1266 | def testBlockNesting(self): |
||
1267 | self.reset_options() |
||
1268 | t = self.decodesto |
||
1269 | |||
1270 | t("#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}") |
||
1271 | t("@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}") |
||
1272 | |||
1273 | # @font-face { |
||
1274 | # font-family: 'Bitstream Vera Serif Bold'; |
||
1275 | # src: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf'); |
||
1276 | # } |
||
1277 | # @media screen { |
||
1278 | # #foo:hover { |
||
1279 | # background-image: url(foo.png); |
||
1280 | # } |
||
1281 | # @media screen and (min-device-pixel-ratio: 2) { |
||
1282 | # @font-face { |
||
1283 | # font-family: 'Helvetica Neue' |
||
1284 | # } |
||
1285 | # #foo:hover { |
||
1286 | # background-image: url(foo@2x.png); |
||
1287 | # } |
||
1288 | # } |
||
1289 | # } |
||
1290 | t("@font-face {\n\tfont-family: 'Bitstream Vera Serif Bold';\n\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: 'Helvetica Neue'\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}") |
||
1291 | |||
1292 | |||
1293 | def testOptions(self): |
||
1294 | self.reset_options() |
||
1295 | self.options.indent_size = 2 |
||
1296 | self.options.indent_char = ' ' |
||
1297 | self.options.selector_separator_newline = False |
||
1298 | t = self.decodesto |
||
1299 | |||
1300 | # pseudo-classes and pseudo-elements |
||
1301 | t("#foo:hover {\n background-image: url(foo@2x.png)\n}") |
||
1302 | t("#foo *:hover {\n color: purple\n}") |
||
1303 | t("::selection {\n color: #ff0000;\n}") |
||
1304 | |||
1305 | # TODO: don't break nested pseduo-classes |
||
1306 | t("@media screen {.tab,.bat:hover {color:red}}", "@media screen {\n .tab, .bat:hover {\n color: red\n }\n}") |
||
1307 | |||
1308 | # particular edge case with braces and semicolons inside tags that allows custom text |
||
1309 | t( "a:not(\"foobar\\\";{}omg\"){\ncontent: 'example\\';{} text';\ncontent: \"example\\\";{} text\";}", |
||
1310 | "a:not(\"foobar\\\";{}omg\") {\n content: 'example\\';{} text';\n content: \"example\\\";{} text\";\n}") |
||
1311 | |||
1312 | def testLessCss(self): |
||
1313 | self.reset_options() |
||
1314 | t = self.decodesto |
||
1315 | |||
1316 | t('.well{ \n @well-bg:@bg-color;@well-fg:@fg-color;}','.well {\n\t@well-bg: @bg-color;\n\t@well-fg: @fg-color;\n}') |
||
1317 | t('.well {&.active {\nbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;}}', |
||
1318 | '.well {\n' + |
||
1319 | '\t&.active {\n' + |
||
1320 | '\t\tbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;\n' + |
||
1321 | '\t}\n' + |
||
1322 | '}') |
||
1323 | t('a {\n' + |
||
1324 | '\tcolor: blue;\n' + |
||
1325 | '\t&:hover {\n' + |
||
1326 | '\t\tcolor: green;\n' + |
||
1327 | '\t}\n' + |
||
1328 | '\t& & &&&.active {\n' + |
||
1329 | '\t\tcolor: green;\n' + |
||
1330 | '\t}\n' + |
||
1331 | '}') |
||
1332 | |||
1333 | # Not sure if this is sensible |
||
1334 | # but I believe it is correct to not remove the space in "&: hover". |
||
1335 | t('a {\n' + |
||
1336 | '\t&: hover {\n' + |
||
1337 | '\t\tcolor: green;\n' + |
||
1338 | '\t}\n' + |
||
1339 | '}'); |
||
1340 | |||
1341 | # import |
||
1342 | t('@import "test";'); |
||
1343 | |||
1344 | # don't break nested pseudo-classes |
||
1345 | t("a:first-child{color:red;div:first-child{color:black;}}", |
||
1346 | "a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); |
||
1347 | |||
1348 | # handle SASS/LESS parent reference |
||
1349 | t("div{&:first-letter {text-transform: uppercase;}}", |
||
1350 | "div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); |
||
1351 | |||
1352 | # nested modifiers (&:hover etc) |
||
1353 | t(".tabs{&:hover{width:10px;}}", ".tabs {\n\t&:hover {\n\t\twidth: 10px;\n\t}\n}") |
||
1354 | t(".tabs{&.big{width:10px;}}", ".tabs {\n\t&.big {\n\t\twidth: 10px;\n\t}\n}") |
||
1355 | t(".tabs{&>big{width:10px;}}", ".tabs {\n\t&>big {\n\t\twidth: 10px;\n\t}\n}") |
||
1356 | t(".tabs{&+.big{width:10px;}}", ".tabs {\n\t&+.big {\n\t\twidth: 10px;\n\t}\n}") |
||
1357 | |||
1358 | # nested rules |
||
1359 | t(".tabs{.child{width:10px;}}", ".tabs {\n\t.child {\n\t\twidth: 10px;\n\t}\n}") |
||
1360 | |||
1361 | # variables |
||
1362 | t("@myvar:10px;.tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}") |
||
1363 | t("@myvar:10px; .tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}") |
||
1364 | |||
1365 | def decodesto(self, input, expectation=None): |
||
1366 | if expectation == None: |
||
1367 | expectation = input |
||
1368 | |||
1369 | self.assertMultiLineEqual( |
||
1370 | cssbeautifier.beautify(input, self.options), expectation) |
||
1371 | |||
1372 | # if the expected is different from input, run it again |
||
1373 | # expected output should be unchanged when run twice. |
||
1374 | if not expectation != input: |
||
1375 | self.assertMultiLineEqual( |
||
1376 | cssbeautifier.beautify(expectation, self.options), expectation) |
||
1377 | |||
1378 | # Everywhere we do newlines, they should be replaced with opts.eol |
||
1379 | self.options.eol = '\r\\n'; |
||
1380 | expectation = expectation.replace('\n', '\r\n') |
||
1381 | self.assertMultiLineEqual( |
||
1382 | cssbeautifier.beautify(input, self.options), expectation) |
||
1383 | if input.find('\n') != -1: |
||
1384 | input = input.replace('\n', '\r\n') |
||
1385 | self.assertMultiLineEqual( |
||
1386 | cssbeautifier.beautify(input, self.options), expectation) |
||
1387 | # Ensure support for auto eol detection |
||
1388 | self.options.eol = 'auto' |
||
1389 | self.assertMultiLineEqual( |
||
1390 | cssbeautifier.beautify(input, self.options), expectation) |
||
1391 | self.options.eol = '\n' |
||
1392 | |||
1393 | if __name__ == '__main__': |
||
1394 | unittest.main() |