sass 3.1.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/.yardopts +11 -0
  2. data/CONTRIBUTING +3 -0
  3. data/EDGE_GEM_VERSION +1 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +201 -0
  6. data/REVISION +1 -0
  7. data/Rakefile +353 -0
  8. data/VERSION +1 -0
  9. data/VERSION_NAME +1 -0
  10. data/bin/css2sass +13 -0
  11. data/bin/sass +8 -0
  12. data/bin/sass-convert +7 -0
  13. data/extra/update_watch.rb +13 -0
  14. data/init.rb +18 -0
  15. data/lib/sass.rb +71 -0
  16. data/lib/sass/cache_store.rb +208 -0
  17. data/lib/sass/callbacks.rb +66 -0
  18. data/lib/sass/css.rb +294 -0
  19. data/lib/sass/engine.rb +792 -0
  20. data/lib/sass/environment.rb +143 -0
  21. data/lib/sass/error.rb +201 -0
  22. data/lib/sass/exec.rb +619 -0
  23. data/lib/sass/importers.rb +22 -0
  24. data/lib/sass/importers/base.rb +138 -0
  25. data/lib/sass/importers/filesystem.rb +121 -0
  26. data/lib/sass/less.rb +363 -0
  27. data/lib/sass/plugin.rb +126 -0
  28. data/lib/sass/plugin/compiler.rb +346 -0
  29. data/lib/sass/plugin/configuration.rb +123 -0
  30. data/lib/sass/plugin/generic.rb +15 -0
  31. data/lib/sass/plugin/merb.rb +48 -0
  32. data/lib/sass/plugin/rack.rb +47 -0
  33. data/lib/sass/plugin/rails.rb +41 -0
  34. data/lib/sass/plugin/staleness_checker.rb +145 -0
  35. data/lib/sass/railtie.rb +8 -0
  36. data/lib/sass/repl.rb +58 -0
  37. data/lib/sass/root.rb +7 -0
  38. data/lib/sass/script.rb +63 -0
  39. data/lib/sass/script/bool.rb +18 -0
  40. data/lib/sass/script/color.rb +490 -0
  41. data/lib/sass/script/css_lexer.rb +29 -0
  42. data/lib/sass/script/css_parser.rb +31 -0
  43. data/lib/sass/script/funcall.rb +78 -0
  44. data/lib/sass/script/functions.rb +852 -0
  45. data/lib/sass/script/interpolation.rb +70 -0
  46. data/lib/sass/script/lexer.rb +337 -0
  47. data/lib/sass/script/literal.rb +236 -0
  48. data/lib/sass/script/node.rb +101 -0
  49. data/lib/sass/script/number.rb +420 -0
  50. data/lib/sass/script/operation.rb +92 -0
  51. data/lib/sass/script/parser.rb +392 -0
  52. data/lib/sass/script/string.rb +67 -0
  53. data/lib/sass/script/string_interpolation.rb +93 -0
  54. data/lib/sass/script/unary_operation.rb +57 -0
  55. data/lib/sass/script/variable.rb +48 -0
  56. data/lib/sass/scss.rb +17 -0
  57. data/lib/sass/scss/css_parser.rb +51 -0
  58. data/lib/sass/scss/parser.rb +838 -0
  59. data/lib/sass/scss/rx.rb +126 -0
  60. data/lib/sass/scss/sass_parser.rb +11 -0
  61. data/lib/sass/scss/script_lexer.rb +15 -0
  62. data/lib/sass/scss/script_parser.rb +25 -0
  63. data/lib/sass/scss/static_parser.rb +40 -0
  64. data/lib/sass/selector.rb +361 -0
  65. data/lib/sass/selector/abstract_sequence.rb +62 -0
  66. data/lib/sass/selector/comma_sequence.rb +82 -0
  67. data/lib/sass/selector/sequence.rb +236 -0
  68. data/lib/sass/selector/simple.rb +113 -0
  69. data/lib/sass/selector/simple_sequence.rb +135 -0
  70. data/lib/sass/shared.rb +78 -0
  71. data/lib/sass/tree/comment_node.rb +128 -0
  72. data/lib/sass/tree/debug_node.rb +36 -0
  73. data/lib/sass/tree/directive_node.rb +75 -0
  74. data/lib/sass/tree/extend_node.rb +65 -0
  75. data/lib/sass/tree/for_node.rb +67 -0
  76. data/lib/sass/tree/if_node.rb +81 -0
  77. data/lib/sass/tree/import_node.rb +124 -0
  78. data/lib/sass/tree/mixin_def_node.rb +60 -0
  79. data/lib/sass/tree/mixin_node.rb +123 -0
  80. data/lib/sass/tree/node.rb +490 -0
  81. data/lib/sass/tree/prop_node.rb +220 -0
  82. data/lib/sass/tree/root_node.rb +125 -0
  83. data/lib/sass/tree/rule_node.rb +273 -0
  84. data/lib/sass/tree/variable_node.rb +39 -0
  85. data/lib/sass/tree/warn_node.rb +42 -0
  86. data/lib/sass/tree/while_node.rb +48 -0
  87. data/lib/sass/util.rb +687 -0
  88. data/lib/sass/util/subset_map.rb +101 -0
  89. data/lib/sass/version.rb +109 -0
  90. data/rails/init.rb +1 -0
  91. data/test/sass/cache_test.rb +74 -0
  92. data/test/sass/callbacks_test.rb +61 -0
  93. data/test/sass/conversion_test.rb +1210 -0
  94. data/test/sass/css2sass_test.rb +364 -0
  95. data/test/sass/data/hsl-rgb.txt +319 -0
  96. data/test/sass/engine_test.rb +2273 -0
  97. data/test/sass/extend_test.rb +1348 -0
  98. data/test/sass/functions_test.rb +565 -0
  99. data/test/sass/importer_test.rb +104 -0
  100. data/test/sass/less_conversion_test.rb +632 -0
  101. data/test/sass/mock_importer.rb +49 -0
  102. data/test/sass/more_results/more1.css +9 -0
  103. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  104. data/test/sass/more_results/more_import.css +29 -0
  105. data/test/sass/more_templates/_more_partial.sass +2 -0
  106. data/test/sass/more_templates/more1.sass +23 -0
  107. data/test/sass/more_templates/more_import.sass +11 -0
  108. data/test/sass/plugin_test.rb +430 -0
  109. data/test/sass/results/alt.css +4 -0
  110. data/test/sass/results/basic.css +9 -0
  111. data/test/sass/results/compact.css +5 -0
  112. data/test/sass/results/complex.css +86 -0
  113. data/test/sass/results/compressed.css +1 -0
  114. data/test/sass/results/expanded.css +19 -0
  115. data/test/sass/results/import.css +31 -0
  116. data/test/sass/results/line_numbers.css +49 -0
  117. data/test/sass/results/mixins.css +95 -0
  118. data/test/sass/results/multiline.css +24 -0
  119. data/test/sass/results/nested.css +22 -0
  120. data/test/sass/results/options.css +1 -0
  121. data/test/sass/results/parent_ref.css +13 -0
  122. data/test/sass/results/script.css +16 -0
  123. data/test/sass/results/scss_import.css +31 -0
  124. data/test/sass/results/scss_importee.css +2 -0
  125. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  126. data/test/sass/results/subdir/subdir.css +3 -0
  127. data/test/sass/results/units.css +11 -0
  128. data/test/sass/results/warn.css +0 -0
  129. data/test/sass/results/warn_imported.css +0 -0
  130. data/test/sass/script_conversion_test.rb +254 -0
  131. data/test/sass/script_test.rb +459 -0
  132. data/test/sass/scss/css_test.rb +897 -0
  133. data/test/sass/scss/rx_test.rb +156 -0
  134. data/test/sass/scss/scss_test.rb +1088 -0
  135. data/test/sass/scss/test_helper.rb +37 -0
  136. data/test/sass/templates/_partial.sass +2 -0
  137. data/test/sass/templates/alt.sass +16 -0
  138. data/test/sass/templates/basic.sass +23 -0
  139. data/test/sass/templates/bork1.sass +2 -0
  140. data/test/sass/templates/bork2.sass +2 -0
  141. data/test/sass/templates/bork3.sass +2 -0
  142. data/test/sass/templates/bork4.sass +2 -0
  143. data/test/sass/templates/compact.sass +17 -0
  144. data/test/sass/templates/complex.sass +305 -0
  145. data/test/sass/templates/compressed.sass +15 -0
  146. data/test/sass/templates/expanded.sass +17 -0
  147. data/test/sass/templates/import.sass +12 -0
  148. data/test/sass/templates/importee.less +2 -0
  149. data/test/sass/templates/importee.sass +19 -0
  150. data/test/sass/templates/line_numbers.sass +13 -0
  151. data/test/sass/templates/mixin_bork.sass +5 -0
  152. data/test/sass/templates/mixins.sass +76 -0
  153. data/test/sass/templates/multiline.sass +20 -0
  154. data/test/sass/templates/nested.sass +25 -0
  155. data/test/sass/templates/nested_bork1.sass +2 -0
  156. data/test/sass/templates/nested_bork2.sass +2 -0
  157. data/test/sass/templates/nested_bork3.sass +2 -0
  158. data/test/sass/templates/nested_bork4.sass +2 -0
  159. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  160. data/test/sass/templates/options.sass +2 -0
  161. data/test/sass/templates/parent_ref.sass +25 -0
  162. data/test/sass/templates/script.sass +101 -0
  163. data/test/sass/templates/scss_import.scss +11 -0
  164. data/test/sass/templates/scss_importee.scss +1 -0
  165. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  166. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  167. data/test/sass/templates/subdir/subdir.sass +6 -0
  168. data/test/sass/templates/units.sass +11 -0
  169. data/test/sass/templates/warn.sass +3 -0
  170. data/test/sass/templates/warn_imported.sass +4 -0
  171. data/test/sass/test_helper.rb +8 -0
  172. data/test/sass/util/subset_map_test.rb +91 -0
  173. data/test/sass/util_test.rb +275 -0
  174. data/test/test_helper.rb +64 -0
  175. data/vendor/fssm/LICENSE +20 -0
  176. data/vendor/fssm/README.markdown +55 -0
  177. data/vendor/fssm/Rakefile +59 -0
  178. data/vendor/fssm/VERSION.yml +5 -0
  179. data/vendor/fssm/example.rb +9 -0
  180. data/vendor/fssm/fssm.gemspec +77 -0
  181. data/vendor/fssm/lib/fssm.rb +33 -0
  182. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  183. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  184. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  185. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  186. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  187. data/vendor/fssm/lib/fssm/path.rb +91 -0
  188. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  189. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  190. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  191. data/vendor/fssm/lib/fssm/support.rb +63 -0
  192. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  193. data/vendor/fssm/profile/prof-cache.rb +40 -0
  194. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  195. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  196. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  197. data/vendor/fssm/profile/prof.html +2379 -0
  198. data/vendor/fssm/spec/path_spec.rb +75 -0
  199. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  200. data/vendor/fssm/spec/root/file.css +0 -0
  201. data/vendor/fssm/spec/root/file.rb +0 -0
  202. data/vendor/fssm/spec/root/file.yml +0 -0
  203. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  204. data/vendor/fssm/spec/spec_helper.rb +14 -0
  205. metadata +297 -0
@@ -0,0 +1,1348 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+
4
+ class ExtendTest < Test::Unit::TestCase
5
+ def test_basic
6
+ assert_equal <<CSS, render(<<SCSS)
7
+ .foo, .bar {
8
+ a: b; }
9
+ CSS
10
+ .foo {a: b}
11
+ .bar {@extend .foo}
12
+ SCSS
13
+
14
+ assert_equal <<CSS, render(<<SCSS)
15
+ .foo, .bar {
16
+ a: b; }
17
+ CSS
18
+ .bar {@extend .foo}
19
+ .foo {a: b}
20
+ SCSS
21
+
22
+ assert_equal <<CSS, render(<<SCSS)
23
+ .foo, .bar {
24
+ a: b; }
25
+
26
+ .bar {
27
+ c: d; }
28
+ CSS
29
+ .foo {a: b}
30
+ .bar {c: d; @extend .foo}
31
+ SCSS
32
+
33
+ assert_equal <<CSS, render(<<SCSS)
34
+ .foo, .bar {
35
+ a: b; }
36
+
37
+ .bar {
38
+ c: d; }
39
+ CSS
40
+ .foo {a: b}
41
+ .bar {@extend .foo; c: d}
42
+ SCSS
43
+ end
44
+
45
+ def test_indented_syntax
46
+ assert_equal <<CSS, render(<<SASS, :syntax => :sass)
47
+ .foo, .bar {
48
+ a: b; }
49
+ CSS
50
+ .foo
51
+ a: b
52
+ .bar
53
+ @extend .foo
54
+ SASS
55
+
56
+ assert_equal <<CSS, render(<<SASS, :syntax => :sass)
57
+ .foo, .bar {
58
+ a: b; }
59
+ CSS
60
+ .foo
61
+ a: b
62
+ .bar
63
+ @extend \#{".foo"}
64
+ SASS
65
+ end
66
+
67
+ def test_multiple_targets
68
+ assert_equal <<CSS, render(<<SCSS)
69
+ .foo, .bar {
70
+ a: b; }
71
+
72
+ .blip .foo, .blip .bar {
73
+ c: d; }
74
+ CSS
75
+ .foo {a: b}
76
+ .bar {@extend .foo}
77
+ .blip .foo {c: d}
78
+ SCSS
79
+ end
80
+
81
+ def test_multiple_extendees
82
+ assert_equal <<CSS, render(<<SCSS)
83
+ .foo, .baz {
84
+ a: b; }
85
+
86
+ .bar, .baz {
87
+ c: d; }
88
+ CSS
89
+ .foo {a: b}
90
+ .bar {c: d}
91
+ .baz {@extend .foo; @extend .bar}
92
+ SCSS
93
+ end
94
+
95
+ def test_multiple_extends_with_single_extender_and_single_target
96
+ assert_equal <<CSS, render(<<SCSS)
97
+ .foo .bar, .baz .bar, .foo .baz, .baz .baz {
98
+ a: b; }
99
+ CSS
100
+ .foo .bar {a: b}
101
+ .baz {@extend .foo; @extend .bar}
102
+ SCSS
103
+
104
+ assert_equal <<CSS, render(<<SCSS)
105
+ .foo.bar, .baz {
106
+ a: b; }
107
+ CSS
108
+ .foo.bar {a: b}
109
+ .baz {@extend .foo; @extend .bar}
110
+ SCSS
111
+ end
112
+
113
+ def test_multiple_extends_with_multiple_extenders_and_single_target
114
+ assert_equal <<CSS, render(<<SCSS)
115
+ .foo .bar, .baz .bar, .foo .bang, .baz .bang {
116
+ a: b; }
117
+ CSS
118
+ .foo .bar {a: b}
119
+ .baz {@extend .foo}
120
+ .bang {@extend .bar}
121
+ SCSS
122
+
123
+ assert_equal <<CSS, render(<<SCSS)
124
+ .foo.bar, .bar.baz, .baz.bang, .foo.bang {
125
+ a: b; }
126
+ CSS
127
+ .foo.bar {a: b}
128
+ .baz {@extend .foo}
129
+ .bang {@extend .bar}
130
+ SCSS
131
+ end
132
+
133
+ def test_chained_extends
134
+ assert_equal <<CSS, render(<<SCSS)
135
+ .foo, .bar, .baz, .bip {
136
+ a: b; }
137
+ CSS
138
+ .foo {a: b}
139
+ .bar {@extend .foo}
140
+ .baz {@extend .bar}
141
+ .bip {@extend .bar}
142
+ SCSS
143
+ end
144
+
145
+ def test_dynamic_extendee
146
+ assert_equal <<CSS, render(<<SCSS)
147
+ .foo, .bar {
148
+ a: b; }
149
+ CSS
150
+ .foo {a: b}
151
+ .bar {@extend \#{".foo"}}
152
+ SCSS
153
+
154
+ assert_equal <<CSS, render(<<SCSS)
155
+ [baz^="blip12px"], .bar {
156
+ a: b; }
157
+ CSS
158
+ [baz^="blip12px"] {a: b}
159
+ .bar {@extend [baz^="blip\#{12px}"]}
160
+ SCSS
161
+ end
162
+
163
+ def test_nested_target
164
+ assert_equal <<CSS, render(<<SCSS)
165
+ .foo .bar, .foo .baz {
166
+ a: b; }
167
+ CSS
168
+ .foo .bar {a: b}
169
+ .baz {@extend .bar}
170
+ SCSS
171
+ end
172
+
173
+ def test_target_with_child
174
+ assert_equal <<CSS, render(<<SCSS)
175
+ .foo .bar, .baz .bar {
176
+ a: b; }
177
+ CSS
178
+ .foo .bar {a: b}
179
+ .baz {@extend .foo}
180
+ SCSS
181
+ end
182
+
183
+ def test_class_unification
184
+ assert_equal <<CSS, render(<<SCSS)
185
+ .foo.bar, .bar.baz {
186
+ a: b; }
187
+ CSS
188
+ .foo.bar {a: b}
189
+ .baz {@extend .foo}
190
+ SCSS
191
+
192
+ assert_equal <<CSS, render(<<SCSS)
193
+ .baz {
194
+ a: b; }
195
+ CSS
196
+ .foo.baz {a: b}
197
+ .baz {@extend .foo}
198
+ SCSS
199
+ end
200
+
201
+ def test_id_unification
202
+ assert_equal <<CSS, render(<<SCSS)
203
+ .foo.bar, .bar#baz {
204
+ a: b; }
205
+ CSS
206
+ .foo.bar {a: b}
207
+ #baz {@extend .foo}
208
+ SCSS
209
+
210
+ assert_equal <<CSS, render(<<SCSS)
211
+ #baz {
212
+ a: b; }
213
+ CSS
214
+ .foo#baz {a: b}
215
+ #baz {@extend .foo}
216
+ SCSS
217
+
218
+ assert_equal <<CSS, render(<<SCSS)
219
+ .foo#baz {
220
+ a: b; }
221
+ CSS
222
+ .foo#baz {a: b}
223
+ #bar {@extend .foo}
224
+ SCSS
225
+ end
226
+
227
+ def test_universal_unification_with_simple_target
228
+ assert_equal <<CSS, render(<<SCSS)
229
+ .foo, * {
230
+ a: b; }
231
+ CSS
232
+ .foo {a: b}
233
+ * {@extend .foo}
234
+ SCSS
235
+
236
+ assert_equal <<CSS, render(<<SCSS)
237
+ .foo, *|* {
238
+ a: b; }
239
+ CSS
240
+ .foo {a: b}
241
+ *|* {@extend .foo}
242
+ SCSS
243
+
244
+ assert_equal <<CSS, render(<<SCSS)
245
+ .bar {
246
+ a: b; }
247
+ CSS
248
+ .foo.bar {a: b}
249
+ * {@extend .foo}
250
+ SCSS
251
+
252
+ assert_equal <<CSS, render(<<SCSS)
253
+ .bar {
254
+ a: b; }
255
+ CSS
256
+ .foo.bar {a: b}
257
+ *|* {@extend .foo}
258
+ SCSS
259
+
260
+ assert_equal <<CSS, render(<<SCSS)
261
+ .foo.bar, ns|*.bar {
262
+ a: b; }
263
+ CSS
264
+ .foo.bar {a: b}
265
+ ns|* {@extend .foo}
266
+ SCSS
267
+ end
268
+
269
+ def test_universal_unification_with_namespaceless_universal_target
270
+ assert_equal <<CSS, render(<<SCSS)
271
+ * {
272
+ a: b; }
273
+ CSS
274
+ *.foo {a: b}
275
+ * {@extend .foo}
276
+ SCSS
277
+
278
+ assert_equal <<CSS, render(<<SCSS)
279
+ * {
280
+ a: b; }
281
+ CSS
282
+ *.foo {a: b}
283
+ *|* {@extend .foo}
284
+ SCSS
285
+
286
+ assert_equal <<CSS, render(<<SCSS)
287
+ *|*.foo, * {
288
+ a: b; }
289
+ CSS
290
+ *|*.foo {a: b}
291
+ * {@extend .foo}
292
+ SCSS
293
+
294
+ assert_equal <<CSS, render(<<SCSS)
295
+ *|* {
296
+ a: b; }
297
+ CSS
298
+ *|*.foo {a: b}
299
+ *|* {@extend .foo}
300
+ SCSS
301
+
302
+ assert_equal <<CSS, render(<<SCSS)
303
+ *.foo, ns|* {
304
+ a: b; }
305
+ CSS
306
+ *.foo {a: b}
307
+ ns|* {@extend .foo}
308
+ SCSS
309
+
310
+ assert_equal <<CSS, render(<<SCSS)
311
+ *|*.foo, ns|* {
312
+ a: b; }
313
+ CSS
314
+ *|*.foo {a: b}
315
+ ns|* {@extend .foo}
316
+ SCSS
317
+ end
318
+
319
+ def test_universal_unification_with_namespaced_universal_target
320
+ assert_equal <<CSS, render(<<SCSS)
321
+ ns|* {
322
+ a: b; }
323
+ CSS
324
+ ns|*.foo {a: b}
325
+ * {@extend .foo}
326
+ SCSS
327
+
328
+ assert_equal <<CSS, render(<<SCSS)
329
+ ns|* {
330
+ a: b; }
331
+ CSS
332
+ ns|*.foo {a: b}
333
+ *|* {@extend .foo}
334
+ SCSS
335
+
336
+ assert_equal <<CSS, render(<<SCSS)
337
+ ns1|*.foo {
338
+ a: b; }
339
+ CSS
340
+ ns1|*.foo {a: b}
341
+ ns2|* {@extend .foo}
342
+ SCSS
343
+
344
+ assert_equal <<CSS, render(<<SCSS)
345
+ ns|* {
346
+ a: b; }
347
+ CSS
348
+ ns|*.foo {a: b}
349
+ ns|* {@extend .foo}
350
+ SCSS
351
+ end
352
+
353
+ def test_universal_unification_with_namespaceless_element_target
354
+ assert_equal <<CSS, render(<<SCSS)
355
+ a {
356
+ a: b; }
357
+ CSS
358
+ a.foo {a: b}
359
+ * {@extend .foo}
360
+ SCSS
361
+
362
+ assert_equal <<CSS, render(<<SCSS)
363
+ a {
364
+ a: b; }
365
+ CSS
366
+ a.foo {a: b}
367
+ *|* {@extend .foo}
368
+ SCSS
369
+
370
+ assert_equal <<CSS, render(<<SCSS)
371
+ *|a.foo, a {
372
+ a: b; }
373
+ CSS
374
+ *|a.foo {a: b}
375
+ * {@extend .foo}
376
+ SCSS
377
+
378
+ assert_equal <<CSS, render(<<SCSS)
379
+ *|a {
380
+ a: b; }
381
+ CSS
382
+ *|a.foo {a: b}
383
+ *|* {@extend .foo}
384
+ SCSS
385
+
386
+ assert_equal <<CSS, render(<<SCSS)
387
+ a.foo, ns|a {
388
+ a: b; }
389
+ CSS
390
+ a.foo {a: b}
391
+ ns|* {@extend .foo}
392
+ SCSS
393
+
394
+ assert_equal <<CSS, render(<<SCSS)
395
+ *|a.foo, ns|a {
396
+ a: b; }
397
+ CSS
398
+ *|a.foo {a: b}
399
+ ns|* {@extend .foo}
400
+ SCSS
401
+ end
402
+
403
+ def test_universal_unification_with_namespaced_element_target
404
+ assert_equal <<CSS, render(<<SCSS)
405
+ ns|a {
406
+ a: b; }
407
+ CSS
408
+ ns|a.foo {a: b}
409
+ * {@extend .foo}
410
+ SCSS
411
+
412
+ assert_equal <<CSS, render(<<SCSS)
413
+ ns|a {
414
+ a: b; }
415
+ CSS
416
+ ns|a.foo {a: b}
417
+ *|* {@extend .foo}
418
+ SCSS
419
+
420
+ assert_equal <<CSS, render(<<SCSS)
421
+ ns1|a.foo {
422
+ a: b; }
423
+ CSS
424
+ ns1|a.foo {a: b}
425
+ ns2|* {@extend .foo}
426
+ SCSS
427
+
428
+ assert_equal <<CSS, render(<<SCSS)
429
+ ns|a {
430
+ a: b; }
431
+ CSS
432
+ ns|a.foo {a: b}
433
+ ns|* {@extend .foo}
434
+ SCSS
435
+ end
436
+
437
+ def test_element_unification_with_simple_target
438
+ assert_equal <<CSS, render(<<SCSS)
439
+ .foo, a {
440
+ a: b; }
441
+ CSS
442
+ .foo {a: b}
443
+ a {@extend .foo}
444
+ SCSS
445
+
446
+ assert_equal <<CSS, render(<<SCSS)
447
+ .foo.bar, a.bar {
448
+ a: b; }
449
+ CSS
450
+ .foo.bar {a: b}
451
+ a {@extend .foo}
452
+ SCSS
453
+
454
+ assert_equal <<CSS, render(<<SCSS)
455
+ .foo.bar, *|a.bar {
456
+ a: b; }
457
+ CSS
458
+ .foo.bar {a: b}
459
+ *|a {@extend .foo}
460
+ SCSS
461
+
462
+ assert_equal <<CSS, render(<<SCSS)
463
+ .foo.bar, ns|a.bar {
464
+ a: b; }
465
+ CSS
466
+ .foo.bar {a: b}
467
+ ns|a {@extend .foo}
468
+ SCSS
469
+ end
470
+
471
+ def test_element_unification_with_namespaceless_universal_target
472
+ assert_equal <<CSS, render(<<SCSS)
473
+ *.foo, a {
474
+ a: b; }
475
+ CSS
476
+ *.foo {a: b}
477
+ a {@extend .foo}
478
+ SCSS
479
+
480
+ assert_equal <<CSS, render(<<SCSS)
481
+ *.foo, a {
482
+ a: b; }
483
+ CSS
484
+ *.foo {a: b}
485
+ *|a {@extend .foo}
486
+ SCSS
487
+
488
+ assert_equal <<CSS, render(<<SCSS)
489
+ *|*.foo, a {
490
+ a: b; }
491
+ CSS
492
+ *|*.foo {a: b}
493
+ a {@extend .foo}
494
+ SCSS
495
+
496
+ assert_equal <<CSS, render(<<SCSS)
497
+ *|*.foo, *|a {
498
+ a: b; }
499
+ CSS
500
+ *|*.foo {a: b}
501
+ *|a {@extend .foo}
502
+ SCSS
503
+
504
+ assert_equal <<CSS, render(<<SCSS)
505
+ *.foo, ns|a {
506
+ a: b; }
507
+ CSS
508
+ *.foo {a: b}
509
+ ns|a {@extend .foo}
510
+ SCSS
511
+
512
+ assert_equal <<CSS, render(<<SCSS)
513
+ *|*.foo, ns|a {
514
+ a: b; }
515
+ CSS
516
+ *|*.foo {a: b}
517
+ ns|a {@extend .foo}
518
+ SCSS
519
+ end
520
+
521
+ def test_element_unification_with_namespaced_universal_target
522
+ assert_equal <<CSS, render(<<SCSS)
523
+ ns|*.foo, ns|a {
524
+ a: b; }
525
+ CSS
526
+ ns|*.foo {a: b}
527
+ a {@extend .foo}
528
+ SCSS
529
+
530
+ assert_equal <<CSS, render(<<SCSS)
531
+ ns|*.foo, ns|a {
532
+ a: b; }
533
+ CSS
534
+ ns|*.foo {a: b}
535
+ *|a {@extend .foo}
536
+ SCSS
537
+
538
+ assert_equal <<CSS, render(<<SCSS)
539
+ ns1|*.foo {
540
+ a: b; }
541
+ CSS
542
+ ns1|*.foo {a: b}
543
+ ns2|a {@extend .foo}
544
+ SCSS
545
+
546
+ assert_equal <<CSS, render(<<SCSS)
547
+ ns|*.foo, ns|a {
548
+ a: b; }
549
+ CSS
550
+ ns|*.foo {a: b}
551
+ ns|a {@extend .foo}
552
+ SCSS
553
+ end
554
+
555
+ def test_element_unification_with_namespaceless_element_target
556
+ assert_equal <<CSS, render(<<SCSS)
557
+ a {
558
+ a: b; }
559
+ CSS
560
+ a.foo {a: b}
561
+ a {@extend .foo}
562
+ SCSS
563
+
564
+ assert_equal <<CSS, render(<<SCSS)
565
+ a {
566
+ a: b; }
567
+ CSS
568
+ a.foo {a: b}
569
+ *|a {@extend .foo}
570
+ SCSS
571
+
572
+ assert_equal <<CSS, render(<<SCSS)
573
+ *|a.foo, a {
574
+ a: b; }
575
+ CSS
576
+ *|a.foo {a: b}
577
+ a {@extend .foo}
578
+ SCSS
579
+
580
+ assert_equal <<CSS, render(<<SCSS)
581
+ *|a {
582
+ a: b; }
583
+ CSS
584
+ *|a.foo {a: b}
585
+ *|a {@extend .foo}
586
+ SCSS
587
+
588
+ assert_equal <<CSS, render(<<SCSS)
589
+ a.foo, ns|a {
590
+ a: b; }
591
+ CSS
592
+ a.foo {a: b}
593
+ ns|a {@extend .foo}
594
+ SCSS
595
+
596
+ assert_equal <<CSS, render(<<SCSS)
597
+ *|a.foo, ns|a {
598
+ a: b; }
599
+ CSS
600
+ *|a.foo {a: b}
601
+ ns|a {@extend .foo}
602
+ SCSS
603
+
604
+ assert_equal <<CSS, render(<<SCSS)
605
+ a.foo {
606
+ a: b; }
607
+ CSS
608
+ a.foo {a: b}
609
+ h1 {@extend .foo}
610
+ SCSS
611
+ end
612
+
613
+ def test_element_unification_with_namespaced_element_target
614
+ assert_equal <<CSS, render(<<SCSS)
615
+ ns|a {
616
+ a: b; }
617
+ CSS
618
+ ns|a.foo {a: b}
619
+ a {@extend .foo}
620
+ SCSS
621
+
622
+ assert_equal <<CSS, render(<<SCSS)
623
+ ns|a {
624
+ a: b; }
625
+ CSS
626
+ ns|a.foo {a: b}
627
+ *|a {@extend .foo}
628
+ SCSS
629
+
630
+ assert_equal <<CSS, render(<<SCSS)
631
+ ns1|a.foo {
632
+ a: b; }
633
+ CSS
634
+ ns1|a.foo {a: b}
635
+ ns2|a {@extend .foo}
636
+ SCSS
637
+
638
+ assert_equal <<CSS, render(<<SCSS)
639
+ ns|a {
640
+ a: b; }
641
+ CSS
642
+ ns|a.foo {a: b}
643
+ ns|a {@extend .foo}
644
+ SCSS
645
+ end
646
+
647
+ def test_attribute_unification
648
+ assert_equal <<CSS, render(<<SCSS)
649
+ [foo=bar].baz, [foo=bar][foo=baz] {
650
+ a: b; }
651
+ CSS
652
+ [foo=bar].baz {a: b}
653
+ [foo=baz] {@extend .baz}
654
+ SCSS
655
+
656
+ assert_equal <<CSS, render(<<SCSS)
657
+ [foo=bar].baz, [foo=bar][foo^=bar] {
658
+ a: b; }
659
+ CSS
660
+ [foo=bar].baz {a: b}
661
+ [foo^=bar] {@extend .baz}
662
+ SCSS
663
+
664
+ assert_equal <<CSS, render(<<SCSS)
665
+ [foo=bar].baz, [foo=bar][foot=bar] {
666
+ a: b; }
667
+ CSS
668
+ [foo=bar].baz {a: b}
669
+ [foot=bar] {@extend .baz}
670
+ SCSS
671
+
672
+ assert_equal <<CSS, render(<<SCSS)
673
+ [foo=bar].baz, [foo=bar][ns|foo=bar] {
674
+ a: b; }
675
+ CSS
676
+ [foo=bar].baz {a: b}
677
+ [ns|foo=bar] {@extend .baz}
678
+ SCSS
679
+
680
+ assert_equal <<CSS, render(<<SCSS)
681
+ [foo=bar] {
682
+ a: b; }
683
+ CSS
684
+ [foo=bar].baz {a: b}
685
+ [foo=bar] {@extend .baz}
686
+ SCSS
687
+ end
688
+
689
+ def test_pseudo_unification
690
+ assert_equal <<CSS, render(<<SCSS)
691
+ :foo.baz, :foo:foo(2n+1) {
692
+ a: b; }
693
+ CSS
694
+ :foo.baz {a: b}
695
+ :foo(2n+1) {@extend .baz}
696
+ SCSS
697
+
698
+ assert_equal <<CSS, render(<<SCSS)
699
+ :foo.baz, :foo::foo {
700
+ a: b; }
701
+ CSS
702
+ :foo.baz {a: b}
703
+ ::foo {@extend .baz}
704
+ SCSS
705
+
706
+ assert_equal <<CSS, render(<<SCSS)
707
+ ::foo.baz {
708
+ a: b; }
709
+ CSS
710
+ ::foo.baz {a: b}
711
+ ::bar {@extend .baz}
712
+ SCSS
713
+
714
+ assert_equal <<CSS, render(<<SCSS)
715
+ ::foo.baz {
716
+ a: b; }
717
+ CSS
718
+ ::foo.baz {a: b}
719
+ ::foo(2n+1) {@extend .baz}
720
+ SCSS
721
+
722
+ assert_equal <<CSS, render(<<SCSS)
723
+ ::foo {
724
+ a: b; }
725
+ CSS
726
+ ::foo.baz {a: b}
727
+ ::foo {@extend .baz}
728
+ SCSS
729
+
730
+ assert_equal <<CSS, render(<<SCSS)
731
+ ::foo(2n+1) {
732
+ a: b; }
733
+ CSS
734
+ ::foo(2n+1).baz {a: b}
735
+ ::foo(2n+1) {@extend .baz}
736
+ SCSS
737
+
738
+ assert_equal <<CSS, render(<<SCSS)
739
+ :foo.baz, :foo:bar {
740
+ a: b; }
741
+ CSS
742
+ :foo.baz {a: b}
743
+ :bar {@extend .baz}
744
+ SCSS
745
+
746
+ assert_equal <<CSS, render(<<SCSS)
747
+ :foo {
748
+ a: b; }
749
+ CSS
750
+ :foo.baz {a: b}
751
+ :foo {@extend .baz}
752
+ SCSS
753
+ end
754
+
755
+ def test_pseudoelement_remains_at_end_of_selector
756
+ assert_equal <<CSS, render(<<SCSS)
757
+ .foo::bar, .baz::bar {
758
+ a: b; }
759
+ CSS
760
+ .foo::bar {a: b}
761
+ .baz {@extend .foo}
762
+ SCSS
763
+
764
+ assert_equal <<CSS, render(<<SCSS)
765
+ a.foo::bar, a.baz::bar {
766
+ a: b; }
767
+ CSS
768
+ a.foo::bar {a: b}
769
+ .baz {@extend .foo}
770
+ SCSS
771
+ end
772
+
773
+ def test_pseudoclass_remains_at_end_of_selector
774
+ assert_equal <<CSS, render(<<SCSS)
775
+ .foo:bar, .baz:bar {
776
+ a: b; }
777
+ CSS
778
+ .foo:bar {a: b}
779
+ .baz {@extend .foo}
780
+ SCSS
781
+
782
+ assert_equal <<CSS, render(<<SCSS)
783
+ a.foo:bar, a.baz:bar {
784
+ a: b; }
785
+ CSS
786
+ a.foo:bar {a: b}
787
+ .baz {@extend .foo}
788
+ SCSS
789
+ end
790
+
791
+ def test_not_remains_at_end_of_selector
792
+ assert_equal <<CSS, render(<<SCSS)
793
+ .foo:not(.bar), .baz:not(.bar) {
794
+ a: b; }
795
+ CSS
796
+ .foo:not(.bar) {a: b}
797
+ .baz {@extend .foo}
798
+ SCSS
799
+ end
800
+
801
+ def test_pseudoelement_goes_lefter_than_pseudoclass
802
+ assert_equal <<CSS, render(<<SCSS)
803
+ .foo::bar, .baz:bang::bar {
804
+ a: b; }
805
+ CSS
806
+ .foo::bar {a: b}
807
+ .baz:bang {@extend .foo}
808
+ SCSS
809
+
810
+ assert_equal <<CSS, render(<<SCSS)
811
+ .foo:bar, .baz:bar::bang {
812
+ a: b; }
813
+ CSS
814
+ .foo:bar {a: b}
815
+ .baz::bang {@extend .foo}
816
+ SCSS
817
+ end
818
+
819
+ def test_pseudoelement_goes_lefter_than_not
820
+ assert_equal <<CSS, render(<<SCSS)
821
+ .foo::bar, .baz:not(.bang)::bar {
822
+ a: b; }
823
+ CSS
824
+ .foo::bar {a: b}
825
+ .baz:not(.bang) {@extend .foo}
826
+ SCSS
827
+
828
+ assert_equal <<CSS, render(<<SCSS)
829
+ .foo:not(.bang), .baz:not(.bang)::bar {
830
+ a: b; }
831
+ CSS
832
+ .foo:not(.bang) {a: b}
833
+ .baz::bar {@extend .foo}
834
+ SCSS
835
+ end
836
+
837
+ def test_negation_unification
838
+ assert_equal <<CSS, render(<<SCSS)
839
+ :not(.foo).baz, :not(.foo):not(.bar) {
840
+ a: b; }
841
+ CSS
842
+ :not(.foo).baz {a: b}
843
+ :not(.bar) {@extend .baz}
844
+ SCSS
845
+
846
+ assert_equal <<CSS, render(<<SCSS)
847
+ :not(.foo) {
848
+ a: b; }
849
+ CSS
850
+ :not(.foo).baz {a: b}
851
+ :not(.foo) {@extend .baz}
852
+ SCSS
853
+
854
+ assert_equal <<CSS, render(<<SCSS)
855
+ :not([a=b]) {
856
+ a: b; }
857
+ CSS
858
+ :not([a=b]).baz {a: b}
859
+ :not([a = b]) {@extend .baz}
860
+ SCSS
861
+ end
862
+
863
+ ## Long Extendees
864
+
865
+ def test_long_extendee
866
+ assert_equal <<CSS, render(<<SCSS)
867
+ .foo.bar, .baz {
868
+ a: b; }
869
+ CSS
870
+ .foo.bar {a: b}
871
+ .baz {@extend .foo.bar}
872
+ SCSS
873
+ end
874
+
875
+ def test_long_extendee_requires_all_selectors
876
+ assert_equal <<CSS, render(<<SCSS)
877
+ .foo {
878
+ a: b; }
879
+ CSS
880
+ .foo {a: b}
881
+ .baz {@extend .foo.bar}
882
+ SCSS
883
+ end
884
+
885
+ def test_long_extendee_matches_supersets
886
+ assert_equal <<CSS, render(<<SCSS)
887
+ .foo.bar.bap, .bap.baz {
888
+ a: b; }
889
+ CSS
890
+ .foo.bar.bap {a: b}
891
+ .baz {@extend .foo.bar}
892
+ SCSS
893
+ end
894
+
895
+ def test_long_extendee_runs_unification
896
+ assert_equal <<CSS, render(<<SCSS)
897
+ ns|*.foo.bar, ns|a.baz {
898
+ a: b; }
899
+ CSS
900
+ ns|*.foo.bar {a: b}
901
+ a.baz {@extend .foo.bar}
902
+ SCSS
903
+ end
904
+
905
+ ## Long Extenders
906
+
907
+ def test_long_extender
908
+ assert_equal <<CSS, render(<<SCSS)
909
+ .foo.bar, .bar.baz.bang {
910
+ a: b; }
911
+ CSS
912
+ .foo.bar {a: b}
913
+ .baz.bang {@extend .foo}
914
+ SCSS
915
+ end
916
+
917
+ def test_long_extender_runs_unification
918
+ assert_equal <<CSS, render(<<SCSS)
919
+ ns|*.foo.bar, ns|a.bar.baz {
920
+ a: b; }
921
+ CSS
922
+ ns|*.foo.bar {a: b}
923
+ a.baz {@extend .foo}
924
+ SCSS
925
+ end
926
+
927
+ def test_long_extender_aborts_unification
928
+ assert_equal <<CSS, render(<<SCSS)
929
+ a.foo#bar {
930
+ a: b; }
931
+ CSS
932
+ a.foo#bar {a: b}
933
+ h1.baz {@extend .foo}
934
+ SCSS
935
+
936
+ assert_equal <<CSS, render(<<SCSS)
937
+ a.foo#bar {
938
+ a: b; }
939
+ CSS
940
+ a.foo#bar {a: b}
941
+ .bang#baz {@extend .foo}
942
+ SCSS
943
+ end
944
+
945
+ ## Nested Extenders
946
+
947
+ def test_nested_extender
948
+ assert_equal <<CSS, render(<<SCSS)
949
+ .foo, foo bar {
950
+ a: b; }
951
+ CSS
952
+ .foo {a: b}
953
+ foo bar {@extend .foo}
954
+ SCSS
955
+ end
956
+
957
+ def test_nested_extender_runs_unification
958
+ assert_equal <<CSS, render(<<SCSS)
959
+ .foo.bar, foo bar.bar {
960
+ a: b; }
961
+ CSS
962
+ .foo.bar {a: b}
963
+ foo bar {@extend .foo}
964
+ SCSS
965
+ end
966
+
967
+ def test_nested_extender_aborts_unification
968
+ assert_equal <<CSS, render(<<SCSS)
969
+ baz.foo {
970
+ a: b; }
971
+ CSS
972
+ baz.foo {a: b}
973
+ foo bar {@extend .foo}
974
+ SCSS
975
+ end
976
+
977
+ def test_nested_extender_alternates_parents
978
+ assert_equal <<CSS, render(<<SCSS)
979
+ .baz .bip .foo, .baz .bip foo .grank bar, foo .grank .baz .bip bar {
980
+ a: b; }
981
+ CSS
982
+ .baz .bip .foo {a: b}
983
+ foo .grank bar {@extend .foo}
984
+ SCSS
985
+ end
986
+
987
+ def test_nested_extender_unifies_identical_parents
988
+ assert_equal <<CSS, render(<<SCSS)
989
+ .baz .bip .foo, .baz .bip bar {
990
+ a: b; }
991
+ CSS
992
+ .baz .bip .foo {a: b}
993
+ .baz .bip bar {@extend .foo}
994
+ SCSS
995
+ end
996
+
997
+ def test_nested_extender_unifies_common_substring
998
+ assert_equal <<CSS, render(<<SCSS)
999
+ .baz .bip .bap .bink .foo, .baz .brat .bip .bap .bink bar, .brat .baz .bip .bap .bink bar {
1000
+ a: b; }
1001
+ CSS
1002
+ .baz .bip .bap .bink .foo {a: b}
1003
+ .brat .bip .bap bar {@extend .foo}
1004
+ SCSS
1005
+ end
1006
+
1007
+ def test_nested_extender_unifies_common_subseq
1008
+ assert_equal <<CSS, render(<<SCSS)
1009
+ .a .x .b .y .foo, .a .x .n .b .y .m bar, .a .n .x .b .y .m bar, .a .x .n .b .m .y bar, .a .n .x .b .m .y bar {
1010
+ a: b; }
1011
+ CSS
1012
+ .a .x .b .y .foo {a: b}
1013
+ .a .n .b .m bar {@extend .foo}
1014
+ SCSS
1015
+ end
1016
+
1017
+ def test_nested_extender_chooses_first_subseq
1018
+ assert_equal <<CSS, render(<<SCSS)
1019
+ .a .b .c .d .foo, .a .b .c .d .a .b .bar {
1020
+ a: b; }
1021
+ CSS
1022
+ .a .b .c .d .foo {a: b}
1023
+ .c .d .a .b .bar {@extend .foo}
1024
+ SCSS
1025
+ end
1026
+
1027
+ def test_nested_extender_counts_extended_subselectors
1028
+ assert_equal <<CSS, render(<<SCSS)
1029
+ .a .bip.bop .foo, .a .b .bip.bop .bar, .b .a .bip.bop .bar {
1030
+ a: b; }
1031
+ CSS
1032
+ .a .bip.bop .foo {a: b}
1033
+ .b .bip .bar {@extend .foo}
1034
+ SCSS
1035
+ end
1036
+
1037
+ def test_nested_extender_counts_extended_superselectors
1038
+ assert_equal <<CSS, render(<<SCSS)
1039
+ .a .bip .foo, .a .b .bip.bop .bar, .b .a .bip.bop .bar {
1040
+ a: b; }
1041
+ CSS
1042
+ .a .bip .foo {a: b}
1043
+ .b .bip.bop .bar {@extend .foo}
1044
+ SCSS
1045
+ end
1046
+
1047
+ def test_nested_extender_with_child_selector
1048
+ assert_equal <<CSS, render(<<SCSS)
1049
+ .baz .foo, .baz foo > bar {
1050
+ a: b; }
1051
+ CSS
1052
+ .baz .foo {a: b}
1053
+ foo > bar {@extend .foo}
1054
+ SCSS
1055
+ end
1056
+
1057
+ def test_nested_extender_finds_common_selectors_around_child_selector
1058
+ assert_equal <<CSS, render(<<SCSS)
1059
+ a > b c .c1, a > b c .c2 {
1060
+ a: b; }
1061
+ CSS
1062
+ a > b c .c1 {a: b}
1063
+ a c .c2 {@extend .c1}
1064
+ SCSS
1065
+
1066
+ assert_equal <<CSS, render(<<SCSS)
1067
+ a > b c .c1, a > b c .c2 {
1068
+ a: b; }
1069
+ CSS
1070
+ a > b c .c1 {a: b}
1071
+ b c .c2 {@extend .c1}
1072
+ SCSS
1073
+ end
1074
+
1075
+ def test_nested_extender_doesnt_find_common_selectors_around_adjacent_sibling_selector
1076
+ assert_equal <<CSS, render(<<SCSS)
1077
+ a + b c .c1, a + b a c .c2, a a + b c .c2 {
1078
+ a: b; }
1079
+ CSS
1080
+ a + b c .c1 {a: b}
1081
+ a c .c2 {@extend .c1}
1082
+ SCSS
1083
+
1084
+ assert_equal <<CSS, render(<<SCSS)
1085
+ a + b c .c1, a a + b c .c2 {
1086
+ a: b; }
1087
+ CSS
1088
+ a + b c .c1 {a: b}
1089
+ a b .c2 {@extend .c1}
1090
+ SCSS
1091
+
1092
+ assert_equal <<CSS, render(<<SCSS)
1093
+ a + b c .c1, a + b c .c2 {
1094
+ a: b; }
1095
+ CSS
1096
+ a + b c .c1 {a: b}
1097
+ b c .c2 {@extend .c1}
1098
+ SCSS
1099
+ end
1100
+
1101
+ def test_nested_extender_doesnt_find_common_selectors_around_sibling_selector
1102
+ assert_equal <<CSS, render(<<SCSS)
1103
+ a ~ b c .c1, a ~ b a c .c2, a a ~ b c .c2 {
1104
+ a: b; }
1105
+ CSS
1106
+ a ~ b c .c1 {a: b}
1107
+ a c .c2 {@extend .c1}
1108
+ SCSS
1109
+
1110
+ assert_equal <<CSS, render(<<SCSS)
1111
+ a ~ b c .c1, a a ~ b c .c2 {
1112
+ a: b; }
1113
+ CSS
1114
+ a ~ b c .c1 {a: b}
1115
+ a b .c2 {@extend .c1}
1116
+ SCSS
1117
+
1118
+ assert_equal <<CSS, render(<<SCSS)
1119
+ a ~ b c .c1, a ~ b c .c2 {
1120
+ a: b; }
1121
+ CSS
1122
+ a ~ b c .c1 {a: b}
1123
+ b c .c2 {@extend .c1}
1124
+ SCSS
1125
+ end
1126
+
1127
+ def test_nested_extender_with_early_child_selectors_doesnt_subseq_them
1128
+ assert_equal <<CSS, render(<<SCSS)
1129
+ .bip > .bap .foo, .bip > .bap .grip > .bap .bar, .grip > .bap .bip > .bap .bar {
1130
+ a: b; }
1131
+ CSS
1132
+ .bip > .bap .foo {a: b}
1133
+ .grip > .bap .bar {@extend .foo}
1134
+ SCSS
1135
+
1136
+ assert_equal <<CSS, render(<<SCSS)
1137
+ .bap > .bip .foo, .bap > .bip .bap > .grip .bar, .bap > .grip .bap > .bip .bar {
1138
+ a: b; }
1139
+ CSS
1140
+ .bap > .bip .foo {a: b}
1141
+ .bap > .grip .bar {@extend .foo}
1142
+ SCSS
1143
+ end
1144
+
1145
+ def test_nested_extender_with_child_selector_unifies
1146
+ assert_equal <<CSS, render(<<SCSS)
1147
+ .baz.foo, foo > bar.baz {
1148
+ a: b; }
1149
+ CSS
1150
+ .baz.foo {a: b}
1151
+ foo > bar {@extend .foo}
1152
+ SCSS
1153
+ end
1154
+
1155
+ def test_nested_extender_with_trailing_child_selector
1156
+ assert_raise(Sass::SyntaxError, "bar > can't extend: invalid selector") do
1157
+ render("bar > {@extend .baz}")
1158
+ end
1159
+ end
1160
+
1161
+ def test_nested_extender_with_sibling_selector
1162
+ assert_equal <<CSS, render(<<SCSS)
1163
+ .baz .foo, .baz foo + bar {
1164
+ a: b; }
1165
+ CSS
1166
+ .baz .foo {a: b}
1167
+ foo + bar {@extend .foo}
1168
+ SCSS
1169
+ end
1170
+
1171
+ def test_nested_extender_with_hacky_selector
1172
+ assert_equal <<CSS, render(<<SCSS)
1173
+ .baz .foo, .baz foo + > > + bar {
1174
+ a: b; }
1175
+ CSS
1176
+ .baz .foo {a: b}
1177
+ foo + > > + bar {@extend .foo}
1178
+ SCSS
1179
+
1180
+ assert_equal <<CSS, render(<<SCSS)
1181
+ .baz .foo, .baz > > bar {
1182
+ a: b; }
1183
+ CSS
1184
+ .baz .foo {a: b}
1185
+ > > bar {@extend .foo}
1186
+ SCSS
1187
+ end
1188
+
1189
+ def test_nested_extender_merges_with_same_selector
1190
+ assert_equal <<CSS, render(<<SCSS)
1191
+ .foo .bar, .foo .baz {
1192
+ a: b; }
1193
+ CSS
1194
+ .foo {
1195
+ .bar {a: b}
1196
+ .baz {@extend .bar} }
1197
+ SCSS
1198
+ end
1199
+
1200
+ def test_nested_extender_with_child_selector_merges_with_same_selector
1201
+ assert_equal <<CSS, render(<<SCSS)
1202
+ .foo > .bar .baz, .foo > .bar .bang {
1203
+ a: b; }
1204
+ CSS
1205
+ .foo > .bar .baz {a: b}
1206
+ .foo > .bar .bang {@extend .baz}
1207
+ SCSS
1208
+ end
1209
+
1210
+ # Loops
1211
+
1212
+ def test_extend_self_loop
1213
+ assert_equal <<CSS, render(<<SCSS)
1214
+ .foo {
1215
+ a: b; }
1216
+ CSS
1217
+ .foo {a: b; @extend .foo}
1218
+ SCSS
1219
+ end
1220
+
1221
+ def test_basic_extend_loop
1222
+ assert_equal <<CSS, render(<<SCSS)
1223
+ .bar, .foo {
1224
+ a: b; }
1225
+
1226
+ .foo, .bar {
1227
+ c: d; }
1228
+ CSS
1229
+ .foo {a: b; @extend .bar}
1230
+ .bar {c: d; @extend .foo}
1231
+ SCSS
1232
+ end
1233
+
1234
+ def test_three_level_extend_loop
1235
+ assert_equal <<CSS, render(<<SCSS)
1236
+ .baz, .bar, .foo {
1237
+ a: b; }
1238
+
1239
+ .foo, .baz, .bar {
1240
+ c: d; }
1241
+
1242
+ .bar, .foo, .baz {
1243
+ e: f; }
1244
+ CSS
1245
+ .foo {a: b; @extend .bar}
1246
+ .bar {c: d; @extend .baz}
1247
+ .baz {e: f; @extend .foo}
1248
+ SCSS
1249
+ end
1250
+
1251
+ def test_nested_extend_loop
1252
+ assert_equal <<CSS, render(<<SCSS)
1253
+ .bar, .bar .foo {
1254
+ a: b; }
1255
+ .bar .foo, .bar .foo .foo {
1256
+ c: d; }
1257
+ CSS
1258
+ .bar {
1259
+ a: b;
1260
+ .foo {c: d; @extend .bar}
1261
+ }
1262
+ SCSS
1263
+ end
1264
+
1265
+ def test_multiple_extender_merges_with_superset_selector
1266
+ assert_equal <<CSS, render(<<SCSS)
1267
+ a.bar.baz, a.foo {
1268
+ a: b; }
1269
+ CSS
1270
+ .foo {@extend .bar; @extend .baz}
1271
+ a.bar.baz {a: b}
1272
+ SCSS
1273
+ end
1274
+
1275
+ def test_control_flow_if
1276
+ assert_equal <<CSS, render(<<SCSS)
1277
+ .true, .also-true {
1278
+ color: green; }
1279
+
1280
+ .false, .also-false {
1281
+ color: red; }
1282
+ CSS
1283
+ .true { color: green; }
1284
+ .false { color: red; }
1285
+ .also-true {
1286
+ @if true { @extend .true; }
1287
+ @else { @extend .false; }
1288
+ }
1289
+ .also-false {
1290
+ @if false { @extend .true; }
1291
+ @else { @extend .false; }
1292
+ }
1293
+ SCSS
1294
+ end
1295
+
1296
+ def test_control_flow_for
1297
+ assert_equal <<CSS, render(<<SCSS)
1298
+ .base-0, .added {
1299
+ color: green; }
1300
+
1301
+ .base-1, .added {
1302
+ display: block; }
1303
+
1304
+ .base-2, .added {
1305
+ border: 1px solid blue; }
1306
+ CSS
1307
+ .base-0 { color: green; }
1308
+ .base-1 { display: block; }
1309
+ .base-2 { border: 1px solid blue; }
1310
+ .added {
1311
+ @for $i from 0 to 3 {
1312
+ @extend .base-\#{$i};
1313
+ }
1314
+ }
1315
+ SCSS
1316
+ end
1317
+
1318
+ def test_control_flow_while
1319
+ assert_equal <<CSS, render(<<SCSS)
1320
+ .base-0, .added {
1321
+ color: green; }
1322
+
1323
+ .base-1, .added {
1324
+ display: block; }
1325
+
1326
+ .base-2, .added {
1327
+ border: 1px solid blue; }
1328
+ CSS
1329
+ .base-0 { color: green; }
1330
+ .base-1 { display: block; }
1331
+ .base-2 { border: 1px solid blue; }
1332
+ .added {
1333
+ $i : 0;
1334
+ @while $i < 3 {
1335
+ @extend .base-\#{$i};
1336
+ $i : $i + 1;
1337
+ }
1338
+ }
1339
+ SCSS
1340
+ end
1341
+
1342
+ private
1343
+
1344
+ def render(sass, options = {})
1345
+ munge_filename options
1346
+ Sass::Engine.new(sass, {:syntax => :scss}.merge(options)).render
1347
+ end
1348
+ end