sass 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +1 -1
  3. data/README.md +10 -0
  4. data/VERSION +1 -1
  5. data/VERSION_DATE +1 -1
  6. data/lib/sass/script/css_parser.rb +4 -1
  7. data/lib/sass/script/functions.rb +15 -25
  8. data/lib/sass/script/lexer.rb +45 -7
  9. data/lib/sass/script/parser.rb +259 -93
  10. data/lib/sass/scss/parser.rb +43 -16
  11. data/lib/sass/scss/static_parser.rb +15 -15
  12. data/lib/sass/util.rb +31 -0
  13. metadata +8 -156
  14. data/Rakefile +0 -364
  15. data/test/sass-spec.yml +0 -3
  16. data/test/sass/cache_test.rb +0 -130
  17. data/test/sass/callbacks_test.rb +0 -60
  18. data/test/sass/compiler_test.rb +0 -225
  19. data/test/sass/conversion_test.rb +0 -2138
  20. data/test/sass/css2sass_test.rb +0 -523
  21. data/test/sass/css_variable_test.rb +0 -237
  22. data/test/sass/data/hsl-rgb.txt +0 -319
  23. data/test/sass/encoding_test.rb +0 -188
  24. data/test/sass/engine_test.rb +0 -3499
  25. data/test/sass/exec_test.rb +0 -95
  26. data/test/sass/extend_test.rb +0 -1679
  27. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  28. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  29. data/test/sass/functions_test.rb +0 -2021
  30. data/test/sass/importer_test.rb +0 -420
  31. data/test/sass/logger_test.rb +0 -57
  32. data/test/sass/mock_importer.rb +0 -49
  33. data/test/sass/more_results/more1.css +0 -9
  34. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  35. data/test/sass/more_results/more_import.css +0 -29
  36. data/test/sass/more_templates/_more_partial.sass +0 -2
  37. data/test/sass/more_templates/more1.sass +0 -23
  38. data/test/sass/more_templates/more_import.sass +0 -11
  39. data/test/sass/plugin_test.rb +0 -552
  40. data/test/sass/results/alt.css +0 -4
  41. data/test/sass/results/basic.css +0 -9
  42. data/test/sass/results/cached_import_option.css +0 -3
  43. data/test/sass/results/compact.css +0 -5
  44. data/test/sass/results/complex.css +0 -86
  45. data/test/sass/results/compressed.css +0 -1
  46. data/test/sass/results/expanded.css +0 -19
  47. data/test/sass/results/filename_fn.css +0 -3
  48. data/test/sass/results/if.css +0 -3
  49. data/test/sass/results/import.css +0 -31
  50. data/test/sass/results/import_charset.css +0 -5
  51. data/test/sass/results/import_charset_ibm866.css +0 -5
  52. data/test/sass/results/import_content.css +0 -1
  53. data/test/sass/results/line_numbers.css +0 -49
  54. data/test/sass/results/mixins.css +0 -95
  55. data/test/sass/results/multiline.css +0 -24
  56. data/test/sass/results/nested.css +0 -22
  57. data/test/sass/results/options.css +0 -1
  58. data/test/sass/results/parent_ref.css +0 -13
  59. data/test/sass/results/script.css +0 -16
  60. data/test/sass/results/scss_import.css +0 -31
  61. data/test/sass/results/scss_importee.css +0 -2
  62. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  63. data/test/sass/results/subdir/subdir.css +0 -3
  64. data/test/sass/results/units.css +0 -11
  65. data/test/sass/results/warn.css +0 -0
  66. data/test/sass/results/warn_imported.css +0 -0
  67. data/test/sass/script_conversion_test.rb +0 -365
  68. data/test/sass/script_test.rb +0 -1427
  69. data/test/sass/scss/css_test.rb +0 -1266
  70. data/test/sass/scss/rx_test.rb +0 -159
  71. data/test/sass/scss/scss_test.rb +0 -4238
  72. data/test/sass/scss/test_helper.rb +0 -37
  73. data/test/sass/source_map_test.rb +0 -1063
  74. data/test/sass/superselector_test.rb +0 -209
  75. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  76. data/test/sass/templates/_double_import_loop2.sass +0 -1
  77. data/test/sass/templates/_filename_fn_import.scss +0 -11
  78. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  79. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  80. data/test/sass/templates/_imported_content.sass +0 -3
  81. data/test/sass/templates/_partial.sass +0 -2
  82. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  83. data/test/sass/templates/alt.sass +0 -16
  84. data/test/sass/templates/basic.sass +0 -23
  85. data/test/sass/templates/bork1.sass +0 -2
  86. data/test/sass/templates/bork2.sass +0 -2
  87. data/test/sass/templates/bork3.sass +0 -2
  88. data/test/sass/templates/bork4.sass +0 -2
  89. data/test/sass/templates/bork5.sass +0 -3
  90. data/test/sass/templates/cached_import_option.scss +0 -3
  91. data/test/sass/templates/compact.sass +0 -17
  92. data/test/sass/templates/complex.sass +0 -305
  93. data/test/sass/templates/compressed.sass +0 -15
  94. data/test/sass/templates/double_import_loop1.sass +0 -1
  95. data/test/sass/templates/expanded.sass +0 -17
  96. data/test/sass/templates/filename_fn.scss +0 -18
  97. data/test/sass/templates/if.sass +0 -11
  98. data/test/sass/templates/import.sass +0 -12
  99. data/test/sass/templates/import_charset.sass +0 -9
  100. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  101. data/test/sass/templates/import_content.sass +0 -4
  102. data/test/sass/templates/importee.less +0 -2
  103. data/test/sass/templates/importee.sass +0 -19
  104. data/test/sass/templates/line_numbers.sass +0 -13
  105. data/test/sass/templates/mixin_bork.sass +0 -5
  106. data/test/sass/templates/mixins.sass +0 -76
  107. data/test/sass/templates/multiline.sass +0 -20
  108. data/test/sass/templates/nested.sass +0 -25
  109. data/test/sass/templates/nested_bork1.sass +0 -2
  110. data/test/sass/templates/nested_bork2.sass +0 -2
  111. data/test/sass/templates/nested_bork3.sass +0 -2
  112. data/test/sass/templates/nested_bork4.sass +0 -2
  113. data/test/sass/templates/nested_import.sass +0 -2
  114. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  115. data/test/sass/templates/options.sass +0 -2
  116. data/test/sass/templates/parent_ref.sass +0 -25
  117. data/test/sass/templates/same_name_different_ext.sass +0 -2
  118. data/test/sass/templates/same_name_different_ext.scss +0 -1
  119. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  120. data/test/sass/templates/script.sass +0 -101
  121. data/test/sass/templates/scss_import.scss +0 -12
  122. data/test/sass/templates/scss_importee.scss +0 -1
  123. data/test/sass/templates/single_import_loop.sass +0 -1
  124. data/test/sass/templates/subdir/import_up1.scss +0 -1
  125. data/test/sass/templates/subdir/import_up2.scss +0 -1
  126. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  127. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  128. data/test/sass/templates/subdir/subdir.sass +0 -6
  129. data/test/sass/templates/units.sass +0 -11
  130. data/test/sass/templates/warn.sass +0 -3
  131. data/test/sass/templates/warn_imported.sass +0 -4
  132. data/test/sass/test_helper.rb +0 -8
  133. data/test/sass/util/multibyte_string_scanner_test.rb +0 -152
  134. data/test/sass/util/normalized_map_test.rb +0 -50
  135. data/test/sass/util/subset_map_test.rb +0 -90
  136. data/test/sass/util_test.rb +0 -393
  137. data/test/sass/value_helpers_test.rb +0 -178
  138. data/test/test_helper.rb +0 -149
@@ -1,523 +0,0 @@
1
- require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require 'sass/css'
4
-
5
- class CSS2SassTest < MiniTest::Test
6
- def test_basic
7
- css = <<CSS
8
- h1 {
9
- color: red;
10
- }
11
- CSS
12
- assert_equal(<<SASS, css2sass(css))
13
- h1
14
- color: red
15
- SASS
16
- silence_warnings {assert_equal(<<SASS, css2sass(css, :old => true))}
17
- h1
18
- :color red
19
- SASS
20
- end
21
-
22
- def test_nesting
23
- assert_equal(<<SASS, css2sass(<<CSS))
24
- li
25
- display: none
26
-
27
- a
28
- text-decoration: none
29
-
30
- span
31
- color: yellow
32
-
33
- &:hover
34
- text-decoration: underline
35
- SASS
36
- li {
37
- display: none;
38
- }
39
-
40
- li a {
41
- text-decoration: none;
42
- }
43
-
44
- li a span {
45
- color: yellow;
46
- }
47
-
48
- li a:hover {
49
- text-decoration: underline;
50
- }
51
- CSS
52
- end
53
-
54
- def test_no_nesting_around_rules
55
- assert_equal(<<SASS, css2sass(<<CSS))
56
- div .warning
57
- color: #d21a19
58
-
59
- span .debug
60
- cursor: crosshair
61
-
62
- div .debug
63
- cursor: default
64
- SASS
65
- div .warning {
66
- color: #d21a19; }
67
- span .debug {
68
- cursor: crosshair;}
69
- div .debug {
70
- cursor: default; }
71
- CSS
72
- end
73
-
74
- def test_comments_multiline
75
- css = <<CSS
76
- /* comment */
77
- elephant.rawr {
78
- rampages: excessively;
79
- }
80
-
81
- /* actual multiline
82
- comment */
83
- span.turkey {
84
- isdinner: true;
85
- }
86
-
87
- .turducken {
88
- /* Sounds funny
89
- doesn't it */
90
- chimera: not_really;
91
- }
92
-
93
- #overhere {
94
- bored: sorta; /* it's for a good
95
- cause */
96
- better_than: thread_pools;
97
- }
98
-
99
- #one_more {
100
- finally: srsly;
101
- } /* just a line here */
102
- CSS
103
- sass = <<SASS
104
- /* comment
105
-
106
- elephant.rawr
107
- rampages: excessively
108
-
109
- /* actual multiline
110
- *comment
111
-
112
- span.turkey
113
- isdinner: true
114
-
115
- .turducken
116
- /* Sounds funny
117
- * doesn't it
118
- chimera: not_really
119
-
120
- #overhere
121
- bored: sorta
122
-
123
- /* it's for a good
124
- * cause
125
- better_than: thread_pools
126
-
127
- #one_more
128
- finally: srsly
129
-
130
- /* just a line here
131
- SASS
132
- assert_equal(sass, css2sass(css))
133
- end
134
-
135
- def test_fold_commas
136
- assert_equal(<<SASS, css2sass(<<CSS))
137
- li
138
- .one, .two
139
- color: red
140
- SASS
141
- li .one {
142
- color: red;
143
- }
144
- li .two {
145
- color: red;
146
- }
147
- CSS
148
-
149
- assert_equal(<<SASS, css2sass(<<CSS))
150
- .one
151
- color: green
152
-
153
- .two
154
- color: green
155
- color: red
156
-
157
- .three
158
- color: red
159
- SASS
160
- .one, .two {
161
- color: green;
162
- }
163
-
164
- .two, .three {
165
- color: red;
166
- }
167
- CSS
168
- end
169
-
170
- def test_bad_formatting
171
- assert_equal(<<SASS, css2sass(<<CSS))
172
- hello
173
- parent: true
174
-
175
- there
176
- parent: false
177
-
178
- who
179
- hoo: false
180
-
181
- why
182
- y: true
183
-
184
- when
185
- wen: nao
186
-
187
- down_here
188
- yeah: true
189
- SASS
190
- hello {
191
- parent: true;
192
- }
193
-
194
- hello there {
195
- parent: false;
196
- }
197
- hello who {
198
- hoo: false;
199
- }
200
- hello why {
201
- y: true;
202
- }
203
- hello when {
204
- wen: nao;
205
- }
206
-
207
-
208
-
209
- down_here { yeah: true; }
210
- CSS
211
- end
212
-
213
- def test_comments_in_selectors
214
- assert_equal(<<SASS, css2sass(<<CSS))
215
- .js
216
- #location-navigation-form .form-submit, #business-listing-form .form-submit, #detailTabs ul, #detailsEnhanced #addTags, #locationSearchList, #moreHoods
217
- display: none
218
-
219
- #navListLeft
220
- display: none
221
- SASS
222
- .js #location-navigation-form .form-submit,
223
- .js #business-listing-form .form-submit,
224
- .js #detailTabs ul,
225
- /* .js #addReview, */
226
- /* .js #addTags, */
227
- .js #detailsEnhanced #addTags,
228
- .js #locationSearchList,
229
- .js #moreHoods,
230
- #navListLeft
231
- { display: none; }
232
- CSS
233
- end
234
-
235
- def test_pseudo_classes_are_escaped
236
- assert_equal(<<SASS, css2sass(<<CSS))
237
- \\:focus
238
- a: b
239
-
240
- \\:foo
241
- bar: baz
242
- SASS
243
- :focus {a: b;}
244
- :focus :foo {bar: baz;}
245
- CSS
246
- end
247
-
248
- def test_subject
249
- silence_warnings {assert_equal(<<SASS, css2sass(<<CSS))}
250
- .foo
251
- .bar!
252
- .baz
253
- a: b
254
-
255
- .bip
256
- c: d
257
-
258
- .bar .bonk
259
- e: f
260
-
261
- .flip!
262
- &.bar
263
- a: b
264
-
265
- &.baz
266
- c: d
267
- SASS
268
- .foo .bar! .baz {a: b;}
269
- .foo .bar! .bip {c: d;}
270
- .foo .bar .bonk {e: f;}
271
-
272
- .flip.bar! {a: b;}
273
- .flip.baz! {c: d;}
274
- CSS
275
- end
276
-
277
- def test_keyframes
278
- assert_equal(<<SASS, css2sass(<<CSS))
279
- @keyframes dash
280
- from
281
- stroke-dasharray: 1,200
282
- stroke-dashoffset: 0
283
-
284
- 50%
285
- stroke-dasharray: 89,200
286
- stroke-dashoffset: -35
287
-
288
- to
289
- stroke-dasharray: 89,200
290
- stroke-dashoffset: -124
291
- SASS
292
- @keyframes dash {
293
- from {
294
- stroke-dasharray: 1,200;
295
- stroke-dashoffset: 0;
296
- }
297
- 50% {
298
- stroke-dasharray: 89,200;
299
- stroke-dashoffset: -35;
300
- }
301
- to {
302
- stroke-dasharray: 89,200;
303
- stroke-dashoffset: -124;
304
- }
305
- }
306
- CSS
307
- end
308
-
309
- # Regressions
310
-
311
- def test_nesting_with_matching_property
312
- assert_equal(<<SASS, css2sass(<<CSS))
313
- ul
314
- width: 10px
315
-
316
- div
317
- width: 20px
318
-
319
- article
320
- width: 10px
321
-
322
- p
323
- width: 20px
324
- SASS
325
- ul {width: 10px}
326
- ul div {width: 20px}
327
- article {width: 10px}
328
- article p {width: 20px}
329
- CSS
330
- end
331
-
332
- def test_empty_rule
333
- assert_equal(<<SASS, css2sass(<<CSS))
334
- a
335
- SASS
336
- a {}
337
- CSS
338
- end
339
-
340
- def test_empty_rule_with_selector_combinator
341
- assert_equal(<<SASS, css2sass(<<CSS))
342
- a
343
- color: red
344
-
345
- > b
346
- SASS
347
- a {color: red}
348
- a > b {}
349
- CSS
350
- end
351
-
352
- def test_nesting_within_media
353
- assert_equal(<<SASS, css2sass(<<CSS))
354
- @media all
355
- .next .vevent
356
- padding-left: 0
357
- padding-right: 0
358
- SASS
359
- @media all {
360
- .next .vevent {
361
- padding-left: 0;
362
- padding-right: 0; } }
363
- CSS
364
- end
365
-
366
- def test_multiline_selector_within_media_and_with_child_selector
367
- assert_equal(<<SASS, css2sass(<<CSS))
368
- @media all
369
- foo bar, baz
370
- padding-left: 0
371
- padding-right: 0
372
- SASS
373
- @media all {
374
- foo bar,
375
- baz {
376
- padding-left: 0;
377
- padding-right: 0; } }
378
- CSS
379
- end
380
-
381
- def test_double_comma
382
- assert_equal(<<SASS, css2sass(<<CSS))
383
- foo, bar
384
- a: b
385
- SASS
386
- foo, , bar { a: b }
387
- CSS
388
- end
389
-
390
- def test_selector_splitting
391
- assert_equal(<<SASS, css2sass(<<CSS))
392
- .foo >
393
- .bar
394
- a: b
395
-
396
- .baz
397
- c: d
398
- SASS
399
- .foo>.bar {a: b}
400
- .foo>.baz {c: d}
401
- CSS
402
-
403
- assert_equal(<<SASS, css2sass(<<CSS))
404
- .foo
405
- &::bar
406
- a: b
407
-
408
- &::baz
409
- c: d
410
- SASS
411
- .foo::bar {a: b}
412
- .foo::baz {c: d}
413
- CSS
414
- end
415
-
416
- def test_triple_nesting
417
- assert_equal(<<SASS, css2sass(<<CSS))
418
- .foo .bar .baz
419
- a: b
420
- SASS
421
- .foo .bar .baz {a: b}
422
- CSS
423
-
424
- assert_equal(<<SASS, css2sass(<<CSS))
425
- .bar > .baz
426
- c: d
427
- SASS
428
- .bar > .baz {c: d}
429
- CSS
430
- end
431
-
432
- # Error reporting
433
-
434
- def test_error_reporting
435
- css2sass("foo")
436
- assert(false, "Expected exception")
437
- rescue Sass::SyntaxError => err
438
- assert_equal(1, err.sass_line)
439
- assert_equal('Invalid CSS after "foo": expected "{", was ""', err.message)
440
- end
441
-
442
- def test_error_reporting_in_line
443
- css2sass("foo\nbar }\nbaz")
444
- assert(false, "Expected exception")
445
- rescue Sass::SyntaxError => err
446
- assert_equal(2, err.sass_line)
447
- assert_equal('Invalid CSS after "bar ": expected "{", was "}"', err.message)
448
- end
449
-
450
- def test_error_truncate_after
451
- css2sass("#{"a" * 16}foo")
452
- assert(false, "Expected exception")
453
- rescue Sass::SyntaxError => err
454
- assert_equal(1, err.sass_line)
455
- assert_equal('Invalid CSS after "...aaaaaaaaaaaafoo": expected "{", was ""', err.message)
456
- end
457
-
458
- def test_error_truncate_was
459
- css2sass("foo }foo#{"a" * 15}")
460
- assert(false, "Expected exception")
461
- rescue Sass::SyntaxError => err
462
- assert_equal(1, err.sass_line)
463
- assert_equal('Invalid CSS after "foo ": expected "{", was "}fooaaaaaaaaaaa..."', err.message)
464
- end
465
-
466
- def test_error_doesnt_truncate_after_when_elipsis_would_add_length
467
- css2sass("#{"a" * 15}foo")
468
- assert(false, "Expected exception")
469
- rescue Sass::SyntaxError => err
470
- assert_equal(1, err.sass_line)
471
- assert_equal('Invalid CSS after "aaaaaaaaaaaaaaafoo": expected "{", was ""', err.message)
472
- end
473
-
474
- def test_error_doesnt_truncate_was_when_elipsis_would_add_length
475
- css2sass("foo }foo#{"a" * 14}")
476
- assert(false, "Expected exception")
477
- rescue Sass::SyntaxError => err
478
- assert_equal(1, err.sass_line)
479
- assert_equal('Invalid CSS after "foo ": expected "{", was "}fooaaaaaaaaaaaaaa"', err.message)
480
- end
481
-
482
- def test_error_gets_rid_of_trailing_newline_for_after
483
- css2sass("foo \n ")
484
- assert(false, "Expected exception")
485
- rescue Sass::SyntaxError => err
486
- assert_equal(2, err.sass_line)
487
- assert_equal('Invalid CSS after "foo": expected "{", was ""', err.message)
488
- end
489
-
490
- def test_error_gets_rid_of_trailing_newline_for_was
491
- css2sass("foo \n }foo")
492
- assert(false, "Expected exception")
493
- rescue Sass::SyntaxError => err
494
- assert_equal(2, err.sass_line)
495
- assert_equal('Invalid CSS after "foo": expected "{", was "}foo"', err.message)
496
- end
497
-
498
- # Encodings
499
-
500
- def test_encoding_error
501
- css2sass("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
502
- assert(false, "Expected exception")
503
- rescue Sass::SyntaxError => e
504
- assert_equal(3, e.sass_line)
505
- assert_equal('Invalid UTF-8 character "\xFE"', e.message)
506
- end
507
-
508
- def test_ascii_incompatible_encoding_error
509
- template = "foo\nbar\nb_z".encode("utf-16le")
510
- template[9] = "\xFE".force_encoding("utf-16le")
511
- css2sass(template)
512
- assert(false, "Expected exception")
513
- rescue Sass::SyntaxError => e
514
- assert_equal(3, e.sass_line)
515
- assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
516
- end
517
-
518
- private
519
-
520
- def css2sass(string, opts={})
521
- Sass::CSS.new(string, opts).render
522
- end
523
- end