oreorenasass 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +11 -0
  3. data/CONTRIBUTING +3 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +221 -0
  6. data/Rakefile +370 -0
  7. data/VERSION +1 -0
  8. data/VERSION_NAME +1 -0
  9. data/bin/sass +13 -0
  10. data/bin/sass-convert +12 -0
  11. data/bin/scss +13 -0
  12. data/extra/update_watch.rb +13 -0
  13. data/init.rb +18 -0
  14. data/lib/sass/cache_stores/base.rb +88 -0
  15. data/lib/sass/cache_stores/chain.rb +34 -0
  16. data/lib/sass/cache_stores/filesystem.rb +60 -0
  17. data/lib/sass/cache_stores/memory.rb +47 -0
  18. data/lib/sass/cache_stores/null.rb +25 -0
  19. data/lib/sass/cache_stores.rb +15 -0
  20. data/lib/sass/callbacks.rb +67 -0
  21. data/lib/sass/css.rb +407 -0
  22. data/lib/sass/engine.rb +1181 -0
  23. data/lib/sass/environment.rb +191 -0
  24. data/lib/sass/error.rb +198 -0
  25. data/lib/sass/exec/base.rb +187 -0
  26. data/lib/sass/exec/sass_convert.rb +264 -0
  27. data/lib/sass/exec/sass_scss.rb +424 -0
  28. data/lib/sass/exec.rb +9 -0
  29. data/lib/sass/features.rb +47 -0
  30. data/lib/sass/importers/base.rb +182 -0
  31. data/lib/sass/importers/filesystem.rb +211 -0
  32. data/lib/sass/importers.rb +22 -0
  33. data/lib/sass/logger/base.rb +30 -0
  34. data/lib/sass/logger/log_level.rb +45 -0
  35. data/lib/sass/logger.rb +12 -0
  36. data/lib/sass/media.rb +210 -0
  37. data/lib/sass/plugin/compiler.rb +565 -0
  38. data/lib/sass/plugin/configuration.rb +118 -0
  39. data/lib/sass/plugin/generic.rb +15 -0
  40. data/lib/sass/plugin/merb.rb +48 -0
  41. data/lib/sass/plugin/rack.rb +60 -0
  42. data/lib/sass/plugin/rails.rb +47 -0
  43. data/lib/sass/plugin/staleness_checker.rb +199 -0
  44. data/lib/sass/plugin.rb +133 -0
  45. data/lib/sass/railtie.rb +10 -0
  46. data/lib/sass/repl.rb +57 -0
  47. data/lib/sass/root.rb +7 -0
  48. data/lib/sass/script/css_lexer.rb +33 -0
  49. data/lib/sass/script/css_parser.rb +34 -0
  50. data/lib/sass/script/functions.rb +2626 -0
  51. data/lib/sass/script/lexer.rb +449 -0
  52. data/lib/sass/script/parser.rb +637 -0
  53. data/lib/sass/script/tree/funcall.rb +306 -0
  54. data/lib/sass/script/tree/interpolation.rb +118 -0
  55. data/lib/sass/script/tree/list_literal.rb +77 -0
  56. data/lib/sass/script/tree/literal.rb +45 -0
  57. data/lib/sass/script/tree/map_literal.rb +64 -0
  58. data/lib/sass/script/tree/node.rb +109 -0
  59. data/lib/sass/script/tree/operation.rb +103 -0
  60. data/lib/sass/script/tree/selector.rb +26 -0
  61. data/lib/sass/script/tree/string_interpolation.rb +104 -0
  62. data/lib/sass/script/tree/unary_operation.rb +69 -0
  63. data/lib/sass/script/tree/variable.rb +57 -0
  64. data/lib/sass/script/tree.rb +16 -0
  65. data/lib/sass/script/value/arg_list.rb +36 -0
  66. data/lib/sass/script/value/base.rb +240 -0
  67. data/lib/sass/script/value/bool.rb +35 -0
  68. data/lib/sass/script/value/color.rb +680 -0
  69. data/lib/sass/script/value/helpers.rb +262 -0
  70. data/lib/sass/script/value/list.rb +113 -0
  71. data/lib/sass/script/value/map.rb +70 -0
  72. data/lib/sass/script/value/null.rb +44 -0
  73. data/lib/sass/script/value/number.rb +530 -0
  74. data/lib/sass/script/value/string.rb +97 -0
  75. data/lib/sass/script/value.rb +11 -0
  76. data/lib/sass/script.rb +66 -0
  77. data/lib/sass/scss/css_parser.rb +42 -0
  78. data/lib/sass/scss/parser.rb +1209 -0
  79. data/lib/sass/scss/rx.rb +141 -0
  80. data/lib/sass/scss/script_lexer.rb +15 -0
  81. data/lib/sass/scss/script_parser.rb +25 -0
  82. data/lib/sass/scss/static_parser.rb +368 -0
  83. data/lib/sass/scss.rb +16 -0
  84. data/lib/sass/selector/abstract_sequence.rb +109 -0
  85. data/lib/sass/selector/comma_sequence.rb +175 -0
  86. data/lib/sass/selector/pseudo.rb +256 -0
  87. data/lib/sass/selector/sequence.rb +600 -0
  88. data/lib/sass/selector/simple.rb +117 -0
  89. data/lib/sass/selector/simple_sequence.rb +325 -0
  90. data/lib/sass/selector.rb +326 -0
  91. data/lib/sass/shared.rb +76 -0
  92. data/lib/sass/source/map.rb +210 -0
  93. data/lib/sass/source/position.rb +39 -0
  94. data/lib/sass/source/range.rb +41 -0
  95. data/lib/sass/stack.rb +120 -0
  96. data/lib/sass/supports.rb +227 -0
  97. data/lib/sass/tree/at_root_node.rb +83 -0
  98. data/lib/sass/tree/charset_node.rb +22 -0
  99. data/lib/sass/tree/comment_node.rb +82 -0
  100. data/lib/sass/tree/content_node.rb +9 -0
  101. data/lib/sass/tree/css_import_node.rb +60 -0
  102. data/lib/sass/tree/debug_node.rb +18 -0
  103. data/lib/sass/tree/directive_node.rb +59 -0
  104. data/lib/sass/tree/each_node.rb +24 -0
  105. data/lib/sass/tree/error_node.rb +18 -0
  106. data/lib/sass/tree/extend_node.rb +43 -0
  107. data/lib/sass/tree/for_node.rb +36 -0
  108. data/lib/sass/tree/function_node.rb +39 -0
  109. data/lib/sass/tree/if_node.rb +52 -0
  110. data/lib/sass/tree/import_node.rb +74 -0
  111. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  112. data/lib/sass/tree/media_node.rb +48 -0
  113. data/lib/sass/tree/mixin_def_node.rb +38 -0
  114. data/lib/sass/tree/mixin_node.rb +52 -0
  115. data/lib/sass/tree/node.rb +238 -0
  116. data/lib/sass/tree/prop_node.rb +171 -0
  117. data/lib/sass/tree/return_node.rb +19 -0
  118. data/lib/sass/tree/root_node.rb +44 -0
  119. data/lib/sass/tree/rule_node.rb +145 -0
  120. data/lib/sass/tree/supports_node.rb +38 -0
  121. data/lib/sass/tree/trace_node.rb +33 -0
  122. data/lib/sass/tree/variable_node.rb +36 -0
  123. data/lib/sass/tree/visitors/base.rb +72 -0
  124. data/lib/sass/tree/visitors/check_nesting.rb +177 -0
  125. data/lib/sass/tree/visitors/convert.rb +334 -0
  126. data/lib/sass/tree/visitors/cssize.rb +369 -0
  127. data/lib/sass/tree/visitors/deep_copy.rb +107 -0
  128. data/lib/sass/tree/visitors/extend.rb +68 -0
  129. data/lib/sass/tree/visitors/perform.rb +539 -0
  130. data/lib/sass/tree/visitors/set_options.rb +139 -0
  131. data/lib/sass/tree/visitors/to_css.rb +381 -0
  132. data/lib/sass/tree/warn_node.rb +18 -0
  133. data/lib/sass/tree/while_node.rb +18 -0
  134. data/lib/sass/util/cross_platform_random.rb +19 -0
  135. data/lib/sass/util/multibyte_string_scanner.rb +157 -0
  136. data/lib/sass/util/normalized_map.rb +130 -0
  137. data/lib/sass/util/ordered_hash.rb +192 -0
  138. data/lib/sass/util/subset_map.rb +110 -0
  139. data/lib/sass/util/test.rb +9 -0
  140. data/lib/sass/util.rb +1318 -0
  141. data/lib/sass/version.rb +124 -0
  142. data/lib/sass.rb +102 -0
  143. data/rails/init.rb +1 -0
  144. data/test/sass/cache_test.rb +131 -0
  145. data/test/sass/callbacks_test.rb +61 -0
  146. data/test/sass/compiler_test.rb +232 -0
  147. data/test/sass/conversion_test.rb +2054 -0
  148. data/test/sass/css2sass_test.rb +477 -0
  149. data/test/sass/data/hsl-rgb.txt +319 -0
  150. data/test/sass/encoding_test.rb +219 -0
  151. data/test/sass/engine_test.rb +3301 -0
  152. data/test/sass/exec_test.rb +86 -0
  153. data/test/sass/extend_test.rb +1661 -0
  154. data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  155. data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  156. data/test/sass/functions_test.rb +1926 -0
  157. data/test/sass/importer_test.rb +412 -0
  158. data/test/sass/logger_test.rb +58 -0
  159. data/test/sass/mock_importer.rb +49 -0
  160. data/test/sass/more_results/more1.css +9 -0
  161. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  162. data/test/sass/more_results/more_import.css +29 -0
  163. data/test/sass/more_templates/_more_partial.sass +2 -0
  164. data/test/sass/more_templates/more1.sass +23 -0
  165. data/test/sass/more_templates/more_import.sass +11 -0
  166. data/test/sass/plugin_test.rb +554 -0
  167. data/test/sass/results/alt.css +4 -0
  168. data/test/sass/results/basic.css +9 -0
  169. data/test/sass/results/cached_import_option.css +3 -0
  170. data/test/sass/results/compact.css +5 -0
  171. data/test/sass/results/complex.css +86 -0
  172. data/test/sass/results/compressed.css +1 -0
  173. data/test/sass/results/expanded.css +19 -0
  174. data/test/sass/results/filename_fn.css +3 -0
  175. data/test/sass/results/if.css +3 -0
  176. data/test/sass/results/import.css +31 -0
  177. data/test/sass/results/import_charset.css +5 -0
  178. data/test/sass/results/import_charset_1_8.css +5 -0
  179. data/test/sass/results/import_charset_ibm866.css +5 -0
  180. data/test/sass/results/import_content.css +1 -0
  181. data/test/sass/results/line_numbers.css +49 -0
  182. data/test/sass/results/mixins.css +95 -0
  183. data/test/sass/results/multiline.css +24 -0
  184. data/test/sass/results/nested.css +22 -0
  185. data/test/sass/results/options.css +1 -0
  186. data/test/sass/results/parent_ref.css +13 -0
  187. data/test/sass/results/script.css +16 -0
  188. data/test/sass/results/scss_import.css +31 -0
  189. data/test/sass/results/scss_importee.css +2 -0
  190. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  191. data/test/sass/results/subdir/subdir.css +3 -0
  192. data/test/sass/results/units.css +11 -0
  193. data/test/sass/results/warn.css +0 -0
  194. data/test/sass/results/warn_imported.css +0 -0
  195. data/test/sass/script_conversion_test.rb +328 -0
  196. data/test/sass/script_test.rb +1054 -0
  197. data/test/sass/scss/css_test.rb +1215 -0
  198. data/test/sass/scss/rx_test.rb +156 -0
  199. data/test/sass/scss/scss_test.rb +3900 -0
  200. data/test/sass/scss/test_helper.rb +37 -0
  201. data/test/sass/source_map_test.rb +977 -0
  202. data/test/sass/superselector_test.rb +191 -0
  203. data/test/sass/templates/_cached_import_option_partial.scss +1 -0
  204. data/test/sass/templates/_double_import_loop2.sass +1 -0
  205. data/test/sass/templates/_filename_fn_import.scss +11 -0
  206. data/test/sass/templates/_imported_charset_ibm866.sass +4 -0
  207. data/test/sass/templates/_imported_charset_utf8.sass +4 -0
  208. data/test/sass/templates/_imported_content.sass +3 -0
  209. data/test/sass/templates/_partial.sass +2 -0
  210. data/test/sass/templates/_same_name_different_partiality.scss +1 -0
  211. data/test/sass/templates/alt.sass +16 -0
  212. data/test/sass/templates/basic.sass +23 -0
  213. data/test/sass/templates/bork1.sass +2 -0
  214. data/test/sass/templates/bork2.sass +2 -0
  215. data/test/sass/templates/bork3.sass +2 -0
  216. data/test/sass/templates/bork4.sass +2 -0
  217. data/test/sass/templates/bork5.sass +3 -0
  218. data/test/sass/templates/cached_import_option.scss +3 -0
  219. data/test/sass/templates/compact.sass +17 -0
  220. data/test/sass/templates/complex.sass +305 -0
  221. data/test/sass/templates/compressed.sass +15 -0
  222. data/test/sass/templates/double_import_loop1.sass +1 -0
  223. data/test/sass/templates/expanded.sass +17 -0
  224. data/test/sass/templates/filename_fn.scss +18 -0
  225. data/test/sass/templates/if.sass +11 -0
  226. data/test/sass/templates/import.sass +12 -0
  227. data/test/sass/templates/import_charset.sass +9 -0
  228. data/test/sass/templates/import_charset_1_8.sass +6 -0
  229. data/test/sass/templates/import_charset_ibm866.sass +11 -0
  230. data/test/sass/templates/import_content.sass +4 -0
  231. data/test/sass/templates/importee.less +2 -0
  232. data/test/sass/templates/importee.sass +19 -0
  233. data/test/sass/templates/line_numbers.sass +13 -0
  234. data/test/sass/templates/mixin_bork.sass +5 -0
  235. data/test/sass/templates/mixins.sass +76 -0
  236. data/test/sass/templates/multiline.sass +20 -0
  237. data/test/sass/templates/nested.sass +25 -0
  238. data/test/sass/templates/nested_bork1.sass +2 -0
  239. data/test/sass/templates/nested_bork2.sass +2 -0
  240. data/test/sass/templates/nested_bork3.sass +2 -0
  241. data/test/sass/templates/nested_bork4.sass +2 -0
  242. data/test/sass/templates/nested_import.sass +2 -0
  243. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  244. data/test/sass/templates/options.sass +2 -0
  245. data/test/sass/templates/parent_ref.sass +25 -0
  246. data/test/sass/templates/same_name_different_ext.sass +2 -0
  247. data/test/sass/templates/same_name_different_ext.scss +1 -0
  248. data/test/sass/templates/same_name_different_partiality.scss +1 -0
  249. data/test/sass/templates/script.sass +101 -0
  250. data/test/sass/templates/scss_import.scss +12 -0
  251. data/test/sass/templates/scss_importee.scss +1 -0
  252. data/test/sass/templates/single_import_loop.sass +1 -0
  253. data/test/sass/templates/subdir/import_up1.scss +1 -0
  254. data/test/sass/templates/subdir/import_up2.scss +1 -0
  255. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  256. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  257. data/test/sass/templates/subdir/subdir.sass +6 -0
  258. data/test/sass/templates/units.sass +11 -0
  259. data/test/sass/templates/warn.sass +3 -0
  260. data/test/sass/templates/warn_imported.sass +4 -0
  261. data/test/sass/test_helper.rb +8 -0
  262. data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
  263. data/test/sass/util/normalized_map_test.rb +51 -0
  264. data/test/sass/util/subset_map_test.rb +91 -0
  265. data/test/sass/util_test.rb +467 -0
  266. data/test/sass/value_helpers_test.rb +179 -0
  267. data/test/test_helper.rb +109 -0
  268. metadata +386 -0
@@ -0,0 +1,2054 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+
4
+ class ConversionTest < MiniTest::Test
5
+ def test_basic
6
+ assert_renders <<SASS, <<SCSS
7
+ foo bar
8
+ baz: bang
9
+ bip: bop
10
+ SASS
11
+ foo bar {
12
+ baz: bang;
13
+ bip: bop;
14
+ }
15
+ SCSS
16
+ assert_renders <<SASS, <<SCSS, :old => true
17
+ foo bar
18
+ :baz bang
19
+ :bip bop
20
+ SASS
21
+ foo bar {
22
+ baz: bang;
23
+ bip: bop;
24
+ }
25
+ SCSS
26
+ end
27
+
28
+ def test_empty_selector
29
+ assert_renders "foo bar", "foo bar {}"
30
+ end
31
+
32
+ def test_empty_directive
33
+ assert_scss_to_sass "@media screen", "@media screen {}"
34
+ assert_scss_to_scss "@media screen {}"
35
+ end
36
+
37
+ def test_empty_control_directive
38
+ assert_renders "@if false", "@if false {}"
39
+ end
40
+
41
+ def test_nesting
42
+ assert_renders <<SASS, <<SCSS
43
+ foo bar
44
+ baz bang
45
+ baz: bang
46
+ bip: bop
47
+ blat: boo
48
+ SASS
49
+ foo bar {
50
+ baz bang {
51
+ baz: bang;
52
+ bip: bop;
53
+ }
54
+ blat: boo;
55
+ }
56
+ SCSS
57
+ end
58
+
59
+ def test_nesting_with_parent_ref
60
+ assert_renders <<SASS, <<SCSS
61
+ foo bar
62
+ &:hover
63
+ baz: bang
64
+ SASS
65
+ foo bar {
66
+ &:hover {
67
+ baz: bang;
68
+ }
69
+ }
70
+ SCSS
71
+ end
72
+
73
+ def test_selector_interpolation
74
+ assert_renders <<SASS, <<SCSS
75
+ foo \#{$bar + "baz"}.bip
76
+ baz: bang
77
+
78
+ foo /\#{$bar + "baz"}/ .bip
79
+ baz: bang
80
+ SASS
81
+ foo \#{$bar + "baz"}.bip {
82
+ baz: bang;
83
+ }
84
+
85
+ foo /\#{$bar + "baz"}/ .bip {
86
+ baz: bang;
87
+ }
88
+ SCSS
89
+ end
90
+
91
+ def test_multiline_selector_with_commas
92
+ assert_renders <<SASS, <<SCSS
93
+ foo bar,
94
+ baz bang
95
+ baz: bang
96
+ SASS
97
+ foo bar,
98
+ baz bang {
99
+ baz: bang;
100
+ }
101
+ SCSS
102
+
103
+ assert_renders <<SASS, <<SCSS
104
+ blat
105
+ foo bar,
106
+ baz bang
107
+ baz: bang
108
+ SASS
109
+ blat {
110
+ foo bar,
111
+ baz bang {
112
+ baz: bang;
113
+ }
114
+ }
115
+ SCSS
116
+ end
117
+
118
+ def test_multiline_selector_without_commas
119
+ assert_scss_to_sass <<SASS, <<SCSS
120
+ foo bar baz bang
121
+ baz: bang
122
+ SASS
123
+ foo bar
124
+ baz bang {
125
+ baz: bang;
126
+ }
127
+ SCSS
128
+
129
+ assert_scss_to_scss <<SCSS
130
+ foo bar
131
+ baz bang {
132
+ baz: bang;
133
+ }
134
+ SCSS
135
+ end
136
+
137
+ def test_escaped_selector
138
+ assert_renders <<SASS, <<SCSS
139
+ foo bar
140
+ \\:hover
141
+ baz: bang
142
+ SASS
143
+ foo bar {
144
+ :hover {
145
+ baz: bang;
146
+ }
147
+ }
148
+ SCSS
149
+ end
150
+
151
+ def test_property_name_interpolation
152
+ assert_renders <<SASS, <<SCSS
153
+ foo bar
154
+ baz\#{$bang}bip\#{$bop}: 12
155
+ SASS
156
+ foo bar {
157
+ baz\#{$bang}bip\#{$bop}: 12;
158
+ }
159
+ SCSS
160
+ end
161
+
162
+ def test_property_value_interpolation
163
+ assert_renders <<SASS, <<SCSS
164
+ foo bar
165
+ baz: 12 \#{$bang} bip \#{"bop"} blat
166
+ SASS
167
+ foo bar {
168
+ baz: 12 \#{$bang} bip \#{"bop"} blat;
169
+ }
170
+ SCSS
171
+ end
172
+
173
+ def test_dynamic_properties
174
+ assert_renders <<SASS, <<SCSS
175
+ foo bar
176
+ baz: 12 $bang "bip"
177
+ SASS
178
+ foo bar {
179
+ baz: 12 $bang "bip";
180
+ }
181
+ SCSS
182
+ end
183
+
184
+ def test_dynamic_properties_with_old
185
+ assert_renders <<SASS, <<SCSS, :old => true
186
+ foo bar
187
+ :baz 12 $bang "bip"
188
+ SASS
189
+ foo bar {
190
+ baz: 12 $bang "bip";
191
+ }
192
+ SCSS
193
+ end
194
+
195
+ def test_multiline_properties
196
+ assert_scss_to_sass <<SASS, <<SCSS
197
+ foo bar
198
+ baz: bip bam boon
199
+ SASS
200
+ foo bar {
201
+ baz:
202
+ bip
203
+ bam
204
+ boon;
205
+ }
206
+ SCSS
207
+
208
+ assert_scss_to_scss <<OUT, <<IN
209
+ foo bar {
210
+ baz: bip bam boon;
211
+ }
212
+ OUT
213
+ foo bar {
214
+ baz:
215
+ bip
216
+ bam
217
+ boon;
218
+ }
219
+ IN
220
+ end
221
+
222
+ def test_multiline_dynamic_properties
223
+ assert_scss_to_sass <<SASS, <<SCSS
224
+ foo bar
225
+ baz: $bip "bam" 12px
226
+ SASS
227
+ foo bar {
228
+ baz:
229
+ $bip
230
+ "bam"
231
+ 12px;
232
+ }
233
+ SCSS
234
+
235
+ assert_scss_to_scss <<OUT, <<IN
236
+ foo bar {
237
+ baz: $bip "bam" 12px;
238
+ }
239
+ OUT
240
+ foo bar {
241
+ baz:
242
+ $bip
243
+ "bam"
244
+ 12px;
245
+ }
246
+ IN
247
+ end
248
+
249
+ def test_silent_comments
250
+ assert_renders <<SASS, <<SCSS
251
+ // foo
252
+
253
+ // bar
254
+
255
+ // baz
256
+
257
+ foo bar
258
+ a: b
259
+ SASS
260
+ // foo
261
+
262
+ // bar
263
+
264
+ // baz
265
+
266
+ foo bar {
267
+ a: b;
268
+ }
269
+ SCSS
270
+
271
+ assert_renders <<SASS, <<SCSS
272
+ // foo
273
+ // bar
274
+ // baz
275
+ // bang
276
+
277
+ foo bar
278
+ a: b
279
+ SASS
280
+ // foo
281
+ // bar
282
+ // baz
283
+ // bang
284
+
285
+ foo bar {
286
+ a: b;
287
+ }
288
+ SCSS
289
+
290
+ assert_sass_to_scss <<SCSS, <<SASS
291
+ // foo
292
+ // bar
293
+ // baz
294
+ // bang
295
+
296
+ foo bar {
297
+ a: b;
298
+ }
299
+ SCSS
300
+ // foo
301
+ // bar
302
+ // baz
303
+ // bang
304
+
305
+ foo bar
306
+ a: b
307
+ SASS
308
+ end
309
+
310
+ def test_nested_silent_comments
311
+ assert_renders <<SASS, <<SCSS
312
+ foo
313
+ bar: baz
314
+ // bip bop
315
+ // beep boop
316
+ bang: bizz
317
+ // bubble bubble
318
+ // toil trouble
319
+ SASS
320
+ foo {
321
+ bar: baz;
322
+ // bip bop
323
+ // beep boop
324
+ bang: bizz;
325
+ // bubble bubble
326
+ // toil trouble
327
+ }
328
+ SCSS
329
+
330
+ assert_sass_to_scss <<SCSS, <<SASS
331
+ foo {
332
+ bar: baz;
333
+ // bip bop
334
+ // beep boop
335
+ // bap blimp
336
+ bang: bizz;
337
+ // bubble bubble
338
+ // toil trouble
339
+ // gorp
340
+ }
341
+ SCSS
342
+ foo
343
+ bar: baz
344
+ // bip bop
345
+ beep boop
346
+ bap blimp
347
+ bang: bizz
348
+ // bubble bubble
349
+ toil trouble
350
+ gorp
351
+ SASS
352
+ end
353
+
354
+ def test_loud_comments
355
+ assert_renders <<SASS, <<SCSS
356
+ /* foo
357
+
358
+ /* bar
359
+
360
+ /* baz
361
+
362
+ foo bar
363
+ a: b
364
+ SASS
365
+ /* foo */
366
+
367
+ /* bar */
368
+
369
+ /* baz */
370
+
371
+ foo bar {
372
+ a: b;
373
+ }
374
+ SCSS
375
+
376
+ assert_scss_to_sass <<SASS, <<SCSS
377
+ /* foo
378
+ * bar
379
+ * baz
380
+ * bang
381
+
382
+ foo bar
383
+ a: b
384
+ SASS
385
+ /* foo
386
+ bar
387
+ baz
388
+ bang */
389
+
390
+ foo bar {
391
+ a: b;
392
+ }
393
+ SCSS
394
+
395
+ assert_scss_to_scss <<SCSS
396
+ /* foo
397
+ bar
398
+ baz
399
+ bang */
400
+
401
+ foo bar {
402
+ a: b;
403
+ }
404
+ SCSS
405
+
406
+ assert_renders <<SASS, <<SCSS
407
+ /* foo
408
+ * bar
409
+ * baz
410
+ * bang
411
+
412
+ foo bar
413
+ a: b
414
+ SASS
415
+ /* foo
416
+ * bar
417
+ * baz
418
+ * bang */
419
+
420
+ foo bar {
421
+ a: b;
422
+ }
423
+ SCSS
424
+ end
425
+
426
+ def test_nested_loud_comments
427
+ assert_renders <<SASS, <<SCSS
428
+ foo
429
+ bar: baz
430
+ /* bip bop
431
+ * beep boop
432
+ bang: bizz
433
+ /* bubble bubble
434
+ * toil trouble
435
+ SASS
436
+ foo {
437
+ bar: baz;
438
+ /* bip bop
439
+ * beep boop */
440
+ bang: bizz;
441
+ /* bubble bubble
442
+ * toil trouble */
443
+ }
444
+ SCSS
445
+
446
+ assert_sass_to_scss <<SCSS, <<SASS
447
+ foo {
448
+ bar: baz;
449
+ /* bip bop
450
+ * beep boop
451
+ * bap blimp */
452
+ bang: bizz;
453
+ /* bubble bubble
454
+ * toil trouble
455
+ * gorp */
456
+ }
457
+ SCSS
458
+ foo
459
+ bar: baz
460
+ /* bip bop
461
+ beep boop
462
+ bap blimp
463
+ bang: bizz
464
+ /* bubble bubble
465
+ toil trouble
466
+ gorp
467
+ SASS
468
+ end
469
+
470
+ def test_loud_comments_with_weird_indentation
471
+ assert_scss_to_sass <<SASS, <<SCSS
472
+ foo
473
+ /* foo
474
+ * bar
475
+ * baz
476
+ a: b
477
+ SASS
478
+ foo {
479
+ /* foo
480
+ bar
481
+ baz */
482
+ a: b;
483
+ }
484
+ SCSS
485
+
486
+ assert_sass_to_scss <<SCSS, <<SASS
487
+ foo {
488
+ /* foo
489
+ * bar
490
+ * baz */
491
+ a: b;
492
+ }
493
+ SCSS
494
+ foo
495
+ /* foo
496
+ bar
497
+ baz
498
+ a: b
499
+ SASS
500
+ end
501
+
502
+ def test_loud_comment_containing_silent_comment
503
+ assert_scss_to_sass <<SASS, <<SCSS
504
+ /*
505
+ *// foo bar
506
+ SASS
507
+ /*
508
+ // foo bar
509
+ */
510
+ SCSS
511
+ end
512
+
513
+ def test_silent_comment_containing_loud_comment
514
+ assert_scss_to_sass <<SASS, <<SCSS
515
+ // /*
516
+ // * foo bar
517
+ // */
518
+ SASS
519
+ // /*
520
+ // * foo bar
521
+ // */
522
+ SCSS
523
+ end
524
+
525
+ def test_immediately_preceding_comments
526
+ assert_renders <<SASS, <<SCSS
527
+ /* Foo
528
+ * Bar
529
+ * Baz
530
+ .foo#bar
531
+ a: b
532
+ SASS
533
+ /* Foo
534
+ * Bar
535
+ * Baz */
536
+ .foo#bar {
537
+ a: b;
538
+ }
539
+ SCSS
540
+
541
+ assert_renders <<SASS, <<SCSS
542
+ // Foo
543
+ // Bar
544
+ // Baz
545
+ =foo
546
+ a: b
547
+ SASS
548
+ // Foo
549
+ // Bar
550
+ // Baz
551
+ @mixin foo {
552
+ a: b;
553
+ }
554
+ SCSS
555
+ end
556
+
557
+ def test_immediately_following_comments
558
+ assert_sass_to_scss <<SCSS, <<SASS
559
+ .foobar {
560
+ // trailing comment
561
+ a: 1px;
562
+ }
563
+ SCSS
564
+ .foobar // trailing comment
565
+ a: 1px
566
+ SASS
567
+
568
+ assert_sass_to_scss <<SCSS, <<SASS
569
+ .foobar {
570
+ // trailing comment
571
+ a: 1px;
572
+ }
573
+ SCSS
574
+ .foobar /* trailing comment */
575
+ a: 1px
576
+ SASS
577
+ end
578
+
579
+ def test_debug
580
+ assert_renders <<SASS, <<SCSS
581
+ foo
582
+ @debug 12px
583
+ bar: baz
584
+ SASS
585
+ foo {
586
+ @debug 12px;
587
+ bar: baz;
588
+ }
589
+ SCSS
590
+ end
591
+
592
+ def test_error
593
+ assert_renders <<SASS, <<SCSS
594
+ foo
595
+ @error "oh no!"
596
+ bar: baz
597
+ SASS
598
+ foo {
599
+ @error "oh no!";
600
+ bar: baz;
601
+ }
602
+ SCSS
603
+ end
604
+
605
+ def test_directive_without_children
606
+ assert_renders <<SASS, <<SCSS
607
+ foo
608
+ @foo #bar "baz"
609
+ bar: baz
610
+ SASS
611
+ foo {
612
+ @foo #bar "baz";
613
+ bar: baz;
614
+ }
615
+ SCSS
616
+ end
617
+
618
+ def test_directive_with_prop_children
619
+ assert_renders <<SASS, <<SCSS
620
+ foo
621
+ @foo #bar "baz"
622
+ a: b
623
+ c: d
624
+
625
+ bar: baz
626
+ SASS
627
+ foo {
628
+ @foo #bar "baz" {
629
+ a: b;
630
+ c: d;
631
+ }
632
+
633
+ bar: baz;
634
+ }
635
+ SCSS
636
+ end
637
+
638
+ def test_directive_with_rule_children
639
+ assert_renders <<SASS, <<SCSS
640
+ foo
641
+ @foo #bar "baz"
642
+ #blat
643
+ a: b
644
+ .bang
645
+ c: d
646
+ e: f
647
+
648
+ bar: baz
649
+ SASS
650
+ foo {
651
+ @foo #bar "baz" {
652
+ #blat {
653
+ a: b;
654
+ }
655
+ .bang {
656
+ c: d;
657
+ e: f;
658
+ }
659
+ }
660
+
661
+ bar: baz;
662
+ }
663
+ SCSS
664
+ end
665
+
666
+ def test_directive_with_rule_and_prop_children
667
+ assert_renders <<SASS, <<SCSS
668
+ foo
669
+ @foo #bar "baz"
670
+ g: h
671
+ #blat
672
+ a: b
673
+ .bang
674
+ c: d
675
+ e: f
676
+ i: j
677
+
678
+ bar: baz
679
+ SASS
680
+ foo {
681
+ @foo #bar "baz" {
682
+ g: h;
683
+ #blat {
684
+ a: b;
685
+ }
686
+ .bang {
687
+ c: d;
688
+ e: f;
689
+ }
690
+ i: j;
691
+ }
692
+
693
+ bar: baz;
694
+ }
695
+ SCSS
696
+ end
697
+
698
+ def test_charset
699
+ assert_renders <<SASS, <<SCSS
700
+ @charset "utf-8"
701
+ SASS
702
+ @charset "utf-8";
703
+ SCSS
704
+ end
705
+
706
+ def test_for
707
+ assert_renders <<SASS, <<SCSS
708
+ foo
709
+ @for $a from $b to $c
710
+ a: b
711
+ @for $c from 1 to 16
712
+ d: e
713
+ f: g
714
+ SASS
715
+ foo {
716
+ @for $a from $b to $c {
717
+ a: b;
718
+ }
719
+ @for $c from 1 to 16 {
720
+ d: e;
721
+ f: g;
722
+ }
723
+ }
724
+ SCSS
725
+ end
726
+
727
+ def test_while
728
+ assert_renders <<SASS, <<SCSS
729
+ foo
730
+ @while flaz($a + $b)
731
+ a: b
732
+ @while 1
733
+ d: e
734
+ f: g
735
+ SASS
736
+ foo {
737
+ @while flaz($a + $b) {
738
+ a: b;
739
+ }
740
+ @while 1 {
741
+ d: e;
742
+ f: g;
743
+ }
744
+ }
745
+ SCSS
746
+ end
747
+
748
+ def test_if
749
+ assert_renders <<SASS, <<SCSS
750
+ foo
751
+ @if $foo or $bar
752
+ a: b
753
+ @if $baz
754
+ d: e
755
+ @else if $bang
756
+ f: g
757
+ @else
758
+ h: i
759
+ SASS
760
+ foo {
761
+ @if $foo or $bar {
762
+ a: b;
763
+ }
764
+ @if $baz {
765
+ d: e;
766
+ }
767
+ @else if $bang {
768
+ f: g;
769
+ }
770
+ @else {
771
+ h: i;
772
+ }
773
+ }
774
+ SCSS
775
+ end
776
+
777
+ def test_each
778
+ assert_renders <<SASS, <<SCSS
779
+ a
780
+ @each $number in 1px 2px 3px 4px
781
+ b: $number
782
+
783
+ c
784
+ @each $str in foo, bar, baz, bang
785
+ d: $str
786
+
787
+ c
788
+ @each $key, $value in (foo: 1, bar: 2, baz: 3)
789
+ \#{$key}: $value
790
+ SASS
791
+ a {
792
+ @each $number in 1px 2px 3px 4px {
793
+ b: $number;
794
+ }
795
+ }
796
+
797
+ c {
798
+ @each $str in foo, bar, baz, bang {
799
+ d: $str;
800
+ }
801
+ }
802
+
803
+ c {
804
+ @each $key, $value in (foo: 1, bar: 2, baz: 3) {
805
+ \#{$key}: $value;
806
+ }
807
+ }
808
+ SCSS
809
+ end
810
+
811
+ def test_import
812
+ assert_renders <<SASS, <<SCSS
813
+ @import foo
814
+
815
+ @import url(bar.css)
816
+
817
+ foo
818
+ bar: baz
819
+ SASS
820
+ @import "foo";
821
+
822
+ @import url(bar.css);
823
+
824
+ foo {
825
+ bar: baz;
826
+ }
827
+ SCSS
828
+
829
+ assert_renders <<SASS, <<SCSS
830
+ @import foo.css
831
+
832
+ @import url(bar.css)
833
+
834
+ foo
835
+ bar: baz
836
+ SASS
837
+ @import "foo.css";
838
+
839
+ @import url(bar.css);
840
+
841
+ foo {
842
+ bar: baz;
843
+ }
844
+ SCSS
845
+ end
846
+
847
+ def test_import_as_directive_in_sass
848
+ assert_equal "@import foo.css\n", to_sass('@import "foo.css"')
849
+ end
850
+
851
+ def test_import_as_directive_in_scss
852
+ assert_renders <<SASS, <<SCSS
853
+ @import "foo.css" print
854
+ SASS
855
+ @import "foo.css" print;
856
+ SCSS
857
+
858
+ assert_renders <<SASS, <<SCSS
859
+ @import url(foo.css) screen, print
860
+ SASS
861
+ @import url(foo.css) screen, print;
862
+ SCSS
863
+ end
864
+
865
+ def test_adjacent_imports
866
+ assert_renders <<SASS, <<SCSS
867
+ @import foo.sass
868
+ @import bar.scss
869
+ @import baz
870
+ SASS
871
+ @import "foo.sass";
872
+ @import "bar.scss";
873
+ @import "baz";
874
+ SCSS
875
+ end
876
+
877
+ def test_non_adjacent_imports
878
+ assert_renders <<SASS, <<SCSS
879
+ @import foo.sass
880
+
881
+ @import bar.scss
882
+
883
+ @import baz
884
+ SASS
885
+ @import "foo.sass";
886
+
887
+ @import "bar.scss";
888
+
889
+ @import "baz";
890
+ SCSS
891
+ end
892
+
893
+ def test_import_with_interpolation
894
+ assert_renders <<SASS, <<SCSS
895
+ $family: unquote("Droid+Sans")
896
+
897
+ @import url("http://fonts.googleapis.com/css?family=\#{$family}")
898
+ SASS
899
+ $family: unquote("Droid+Sans");
900
+
901
+ @import url("http://fonts.googleapis.com/css?family=\#{$family}");
902
+ SCSS
903
+ end
904
+
905
+ def test_extend
906
+ assert_renders <<SASS, <<SCSS
907
+ .foo
908
+ @extend .bar
909
+ @extend .baz:bang
910
+ SASS
911
+ .foo {
912
+ @extend .bar;
913
+ @extend .baz:bang;
914
+ }
915
+ SCSS
916
+ end
917
+
918
+ def test_comma_extendee
919
+ assert_renders <<SASS, <<SCSS
920
+ .baz
921
+ @extend .foo, .bar
922
+ SASS
923
+ .baz {
924
+ @extend .foo, .bar;
925
+ }
926
+ SCSS
927
+ end
928
+
929
+ def test_argless_mixin_definition
930
+ assert_renders <<SASS, <<SCSS
931
+ =foo-bar
932
+ baz
933
+ a: b
934
+ SASS
935
+ @mixin foo-bar {
936
+ baz {
937
+ a: b;
938
+ }
939
+ }
940
+ SCSS
941
+
942
+ assert_scss_to_sass <<SASS, <<SCSS
943
+ =foo-bar
944
+ baz
945
+ a: b
946
+ SASS
947
+ @mixin foo-bar() {
948
+ baz {
949
+ a: b;
950
+ }
951
+ }
952
+ SCSS
953
+
954
+ assert_sass_to_scss <<SCSS, <<SASS
955
+ @mixin foo-bar {
956
+ baz {
957
+ a: b;
958
+ }
959
+ }
960
+ SCSS
961
+ =foo-bar()
962
+ baz
963
+ a: b
964
+ SASS
965
+ end
966
+
967
+ def test_mixin_definition_without_defaults
968
+ assert_renders <<SASS, <<SCSS
969
+ =foo-bar($baz, $bang)
970
+ baz
971
+ a: $baz $bang
972
+ SASS
973
+ @mixin foo-bar($baz, $bang) {
974
+ baz {
975
+ a: $baz $bang;
976
+ }
977
+ }
978
+ SCSS
979
+ end
980
+
981
+ def test_mixin_definition_with_defaults
982
+ assert_renders <<SASS, <<SCSS
983
+ =foo-bar($baz, $bang: 12px)
984
+ baz
985
+ a: $baz $bang
986
+ SASS
987
+ @mixin foo-bar($baz, $bang: 12px) {
988
+ baz {
989
+ a: $baz $bang;
990
+ }
991
+ }
992
+ SCSS
993
+
994
+ assert_sass_to_scss <<SCSS, <<SASS
995
+ @mixin foo-bar($baz, $bang: foo) {
996
+ baz {
997
+ a: $baz $bang;
998
+ }
999
+ }
1000
+ SCSS
1001
+ =foo-bar($baz, $bang: foo)
1002
+ baz
1003
+ a: $baz $bang
1004
+ SASS
1005
+ end
1006
+
1007
+ def test_argless_mixin_include
1008
+ assert_renders <<SASS, <<SCSS
1009
+ foo
1010
+ +foo-bar
1011
+ a: blip
1012
+ SASS
1013
+ foo {
1014
+ @include foo-bar;
1015
+ a: blip;
1016
+ }
1017
+ SCSS
1018
+ end
1019
+
1020
+ def test_mixin_include
1021
+ assert_renders <<SASS, <<SCSS
1022
+ foo
1023
+ +foo-bar(12px, "blaz")
1024
+ a: blip
1025
+ SASS
1026
+ foo {
1027
+ @include foo-bar(12px, "blaz");
1028
+ a: blip;
1029
+ }
1030
+ SCSS
1031
+ end
1032
+
1033
+ def test_mixin_include_with_keyword_args
1034
+ assert_renders <<SASS, <<SCSS
1035
+ foo
1036
+ +foo-bar(12px, "blaz", $blip: blap, $bloop: blop)
1037
+ +foo-bar($blip: blap, $bloop: blop)
1038
+ a: blip
1039
+ SASS
1040
+ foo {
1041
+ @include foo-bar(12px, "blaz", $blip: blap, $bloop: blop);
1042
+ @include foo-bar($blip: blap, $bloop: blop);
1043
+ a: blip;
1044
+ }
1045
+ SCSS
1046
+ end
1047
+
1048
+ def test_mixin_include_with_hyphen_conversion_keyword_arg
1049
+ assert_renders <<SASS, <<SCSS
1050
+ foo
1051
+ +foo-bar($a-b_c: val)
1052
+ a: blip
1053
+ SASS
1054
+ foo {
1055
+ @include foo-bar($a-b_c: val);
1056
+ a: blip;
1057
+ }
1058
+ SCSS
1059
+ end
1060
+
1061
+ def test_argless_function_definition
1062
+ assert_renders <<SASS, <<SCSS
1063
+ @function foo()
1064
+ $var: 1 + 1
1065
+ @return $var
1066
+ SASS
1067
+ @function foo() {
1068
+ $var: 1 + 1;
1069
+ @return $var;
1070
+ }
1071
+ SCSS
1072
+ end
1073
+
1074
+ def test_function_definition_without_defaults
1075
+ assert_renders <<SASS, <<SCSS
1076
+ @function foo($var1, $var2)
1077
+ @if $var1
1078
+ @return $var1 + $var2
1079
+ SASS
1080
+ @function foo($var1, $var2) {
1081
+ @if $var1 {
1082
+ @return $var1 + $var2;
1083
+ }
1084
+ }
1085
+ SCSS
1086
+ end
1087
+
1088
+ def test_function_definition_with_defaults
1089
+ assert_renders <<SASS, <<SCSS
1090
+ @function foo($var1, $var2: foo)
1091
+ @if $var1
1092
+ @return $var1 + $var2
1093
+ SASS
1094
+ @function foo($var1, $var2: foo) {
1095
+ @if $var1 {
1096
+ @return $var1 + $var2;
1097
+ }
1098
+ }
1099
+ SCSS
1100
+ end
1101
+
1102
+ def test_variable_definition
1103
+ assert_renders <<SASS, <<SCSS
1104
+ $var1: 12px + 15px
1105
+
1106
+ foo
1107
+ $var2: flaz(#abcdef)
1108
+ val: $var1 $var2
1109
+ SASS
1110
+ $var1: 12px + 15px;
1111
+
1112
+ foo {
1113
+ $var2: flaz(#abcdef);
1114
+ val: $var1 $var2;
1115
+ }
1116
+ SCSS
1117
+ end
1118
+
1119
+ def test_guarded_variable_definition
1120
+ assert_renders <<SASS, <<SCSS
1121
+ $var1: 12px + 15px !default
1122
+
1123
+ foo
1124
+ $var2: flaz(#abcdef) !default
1125
+ val: $var1 $var2
1126
+ SASS
1127
+ $var1: 12px + 15px !default;
1128
+
1129
+ foo {
1130
+ $var2: flaz(#abcdef) !default;
1131
+ val: $var1 $var2;
1132
+ }
1133
+ SCSS
1134
+ end
1135
+
1136
+ def test_multiple_variable_definitions
1137
+ assert_renders <<SASS, <<SCSS
1138
+ $var1: foo
1139
+ $var2: bar
1140
+ $var3: baz
1141
+
1142
+ $var4: bip
1143
+ $var5: bap
1144
+ SASS
1145
+ $var1: foo;
1146
+ $var2: bar;
1147
+ $var3: baz;
1148
+
1149
+ $var4: bip;
1150
+ $var5: bap;
1151
+ SCSS
1152
+ end
1153
+
1154
+ def test_division_asserted_with_parens
1155
+ assert_renders <<SASS, <<SCSS
1156
+ foo
1157
+ a: (1px / 2px)
1158
+ SASS
1159
+ foo {
1160
+ a: (1px / 2px);
1161
+ }
1162
+ SCSS
1163
+ end
1164
+
1165
+ def test_division_not_asserted_when_unnecessary
1166
+ assert_renders <<SASS, <<SCSS
1167
+ $var: 1px / 2px
1168
+
1169
+ foo
1170
+ a: $var
1171
+ SASS
1172
+ $var: 1px / 2px;
1173
+
1174
+ foo {
1175
+ a: $var;
1176
+ }
1177
+ SCSS
1178
+
1179
+ assert_renders <<SASS, <<SCSS
1180
+ $var: 1px
1181
+
1182
+ foo
1183
+ a: $var / 2px
1184
+ SASS
1185
+ $var: 1px;
1186
+
1187
+ foo {
1188
+ a: $var / 2px;
1189
+ }
1190
+ SCSS
1191
+
1192
+ assert_renders <<SASS, <<SCSS
1193
+ foo
1194
+ a: 1 + 1px / 2px
1195
+ SASS
1196
+ foo {
1197
+ a: 1 + 1px / 2px;
1198
+ }
1199
+ SCSS
1200
+ end
1201
+
1202
+ def test_literal_slash
1203
+ assert_renders <<SASS, <<SCSS
1204
+ foo
1205
+ a: 1px / 2px
1206
+ SASS
1207
+ foo {
1208
+ a: 1px / 2px;
1209
+ }
1210
+ SCSS
1211
+ end
1212
+
1213
+ def test_directive_with_interpolation
1214
+ assert_renders <<SASS, <<SCSS
1215
+ $baz: 12
1216
+
1217
+ @foo bar\#{$baz} qux
1218
+ a: b
1219
+ SASS
1220
+ $baz: 12;
1221
+
1222
+ @foo bar\#{$baz} qux {
1223
+ a: b;
1224
+ }
1225
+ SCSS
1226
+ end
1227
+
1228
+ def test_media_with_interpolation
1229
+ assert_renders <<SASS, <<SCSS
1230
+ $baz: 12
1231
+
1232
+ @media bar\#{$baz}
1233
+ a: b
1234
+ SASS
1235
+ $baz: 12;
1236
+
1237
+ @media bar\#{$baz} {
1238
+ a: b;
1239
+ }
1240
+ SCSS
1241
+ end
1242
+
1243
+ def test_media_with_expressions
1244
+ assert_sass_to_scss <<SCSS, <<SASS
1245
+ $media1: screen;
1246
+ $media2: print;
1247
+ $var: -webkit-min-device-pixel-ratio;
1248
+ $val: 20;
1249
+
1250
+ @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2} {
1251
+ a: b;
1252
+ }
1253
+ SCSS
1254
+ $media1: screen
1255
+ $media2: print
1256
+ $var: -webkit-min-device-pixel-ratio
1257
+ $val: 20
1258
+
1259
+ @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2}
1260
+ a: b
1261
+ SASS
1262
+
1263
+ assert_scss_to_sass <<SASS, <<SCSS
1264
+ $media1: screen
1265
+ $media2: print
1266
+ $var: -webkit-min-device-pixel-ratio
1267
+ $val: 20
1268
+
1269
+ @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2}
1270
+ a: b
1271
+ SASS
1272
+ $media1: screen;
1273
+ $media2: print;
1274
+ $var: -webkit-min-device-pixel-ratio;
1275
+ $val: 20;
1276
+
1277
+ @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2} {
1278
+ a: b;
1279
+ }
1280
+ SCSS
1281
+ end
1282
+
1283
+ def test_media_with_feature
1284
+ assert_sass_to_scss <<SCSS, <<SASS
1285
+ @media screen and (-webkit-transform-3d) {
1286
+ a: b;
1287
+ }
1288
+ SCSS
1289
+ @media screen and (-webkit-transform-3d)
1290
+ a: b
1291
+ SASS
1292
+ end
1293
+
1294
+ def test_supports_with_expressions
1295
+ assert_renders <<SASS, <<SCSS
1296
+ $query: "(feature1: val)"
1297
+ $feature: feature2
1298
+ $val: val
1299
+
1300
+ @supports \#{$query} and ($feature: $val) or (not ($feature + 3: $val + 4))
1301
+ foo
1302
+ a: b
1303
+ SASS
1304
+ $query: "(feature1: val)";
1305
+ $feature: feature2;
1306
+ $val: val;
1307
+
1308
+ @supports \#{$query} and ($feature: $val) or (not ($feature + 3: $val + 4)) {
1309
+ foo {
1310
+ a: b;
1311
+ }
1312
+ }
1313
+ SCSS
1314
+ end
1315
+
1316
+ # Hacks
1317
+
1318
+ def test_declaration_hacks
1319
+ assert_renders <<SASS, <<SCSS
1320
+ foo
1321
+ _name: val
1322
+ *name: val
1323
+ #name: val
1324
+ .name: val
1325
+ name/**/: val
1326
+ name/*\\**/: val
1327
+ name: val
1328
+ SASS
1329
+ foo {
1330
+ _name: val;
1331
+ *name: val;
1332
+ #name: val;
1333
+ .name: val;
1334
+ name/**/: val;
1335
+ name/*\\**/: val;
1336
+ name: val;
1337
+ }
1338
+ SCSS
1339
+ end
1340
+
1341
+ def test_old_declaration_hacks
1342
+ assert_renders <<SASS, <<SCSS, :old => true
1343
+ foo
1344
+ :_name val
1345
+ :*name val
1346
+ :#name val
1347
+ :.name val
1348
+ :name val
1349
+ SASS
1350
+ foo {
1351
+ _name: val;
1352
+ *name: val;
1353
+ #name: val;
1354
+ .name: val;
1355
+ name: val;
1356
+ }
1357
+ SCSS
1358
+ end
1359
+
1360
+ def test_selector_hacks
1361
+ assert_selector_renders = lambda do |s|
1362
+ assert_renders <<SASS, <<SCSS
1363
+ #{s}
1364
+ a: b
1365
+ SASS
1366
+ #{s} {
1367
+ a: b;
1368
+ }
1369
+ SCSS
1370
+ end
1371
+
1372
+ assert_selector_renders['> E']
1373
+ assert_selector_renders['+ E']
1374
+ assert_selector_renders['~ E']
1375
+ assert_selector_renders['> > E']
1376
+
1377
+ assert_selector_renders['E*']
1378
+ assert_selector_renders['E*.foo']
1379
+ assert_selector_renders['E*:hover']
1380
+ end
1381
+
1382
+ def test_disallowed_colon_hack
1383
+ assert_raise_message(Sass::SyntaxError, 'The ":name: val" hack is not allowed in the Sass indented syntax') do
1384
+ to_sass("foo {:name: val;}", :syntax => :scss)
1385
+ end
1386
+ end
1387
+
1388
+ def test_nested_properties
1389
+ assert_renders <<SASS, <<SCSS
1390
+ div
1391
+ before: before
1392
+ background:
1393
+ color: blue
1394
+ repeat: no-repeat
1395
+ after: after
1396
+ SASS
1397
+ div {
1398
+ before: before;
1399
+ background: {
1400
+ color: blue;
1401
+ repeat: no-repeat;
1402
+ };
1403
+ after: after;
1404
+ }
1405
+
1406
+ SCSS
1407
+ end
1408
+
1409
+ def test_dasherize
1410
+ assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
1411
+ @mixin under-scored-mixin($under-scored-arg: $under-scored-default) {
1412
+ bar: $under-scored-arg;
1413
+ }
1414
+
1415
+ div {
1416
+ foo: under-scored-fn($under-scored-var + "before\#{$another-under-scored-var}after");
1417
+ @include under-scored-mixin($passed-arg);
1418
+ selector-\#{$under-scored-interp}: bold;
1419
+ }
1420
+
1421
+ @if $under-scored {
1422
+ @for $for-var from $from-var to $to-var {
1423
+ @while $while-var == true {
1424
+ $while-var: false;
1425
+ }
1426
+ }
1427
+ }
1428
+ SCSS
1429
+ =under_scored_mixin($under_scored_arg: $under_scored_default)
1430
+ bar: $under_scored_arg
1431
+ div
1432
+ foo: under_scored_fn($under_scored_var + "before\#{$another_under_scored_var}after")
1433
+ +under_scored_mixin($passed_arg)
1434
+ selector-\#{$under_scored_interp}: bold
1435
+ @if $under_scored
1436
+ @for $for_var from $from_var to $to_var
1437
+ @while $while_var == true
1438
+ $while_var : false
1439
+ SASS
1440
+ end
1441
+
1442
+ def test_loud_comment_conversion
1443
+ assert_renders(<<SASS, <<SCSS)
1444
+ /*! \#{"interpolated"}
1445
+ SASS
1446
+ /*! \#{"interpolated"} */
1447
+ SCSS
1448
+ end
1449
+
1450
+ def test_content_conversion
1451
+ assert_renders(<<SASS, <<SCSS)
1452
+ $color: blue
1453
+
1454
+ =context($class, $color: red)
1455
+ .\#{$class}
1456
+ background-color: $color
1457
+ @content
1458
+ border-color: $color
1459
+
1460
+ +context(parent)
1461
+ +context(child, $color: yellow)
1462
+ color: $color
1463
+ SASS
1464
+ $color: blue;
1465
+
1466
+ @mixin context($class, $color: red) {
1467
+ .\#{$class} {
1468
+ background-color: $color;
1469
+ @content;
1470
+ border-color: $color;
1471
+ }
1472
+ }
1473
+
1474
+ @include context(parent) {
1475
+ @include context(child, $color: yellow) {
1476
+ color: $color;
1477
+ }
1478
+ }
1479
+ SCSS
1480
+
1481
+ end
1482
+
1483
+ def test_empty_content
1484
+ assert_scss_to_scss(<<SCSS)
1485
+ @mixin foo {
1486
+ @content;
1487
+ }
1488
+
1489
+ @include foo {}
1490
+ SCSS
1491
+ end
1492
+
1493
+ def test_placeholder_conversion
1494
+ assert_renders(<<SASS, <<SCSS)
1495
+ #content a%foo.bar
1496
+ color: blue
1497
+ SASS
1498
+ #content a%foo.bar {
1499
+ color: blue;
1500
+ }
1501
+ SCSS
1502
+ end
1503
+
1504
+ def test_reference_selector
1505
+ assert_renders(<<SASS, <<SCSS)
1506
+ foo /bar|baz/ bang
1507
+ a: b
1508
+ SASS
1509
+ foo /bar|baz/ bang {
1510
+ a: b;
1511
+ }
1512
+ SCSS
1513
+ end
1514
+
1515
+ def test_subject
1516
+ assert_renders(<<SASS, <<SCSS)
1517
+ foo bar! baz
1518
+ a: b
1519
+ SASS
1520
+ foo bar! baz {
1521
+ a: b;
1522
+ }
1523
+ SCSS
1524
+ end
1525
+
1526
+ def test_placeholder_interoplation_conversion
1527
+ assert_renders(<<SASS, <<SCSS)
1528
+ $foo: foo
1529
+
1530
+ %\#{$foo}
1531
+ color: blue
1532
+
1533
+ .bar
1534
+ @extend %foo
1535
+ SASS
1536
+ $foo: foo;
1537
+
1538
+ %\#{$foo} {
1539
+ color: blue;
1540
+ }
1541
+
1542
+ .bar {
1543
+ @extend %foo;
1544
+ }
1545
+ SCSS
1546
+ end
1547
+
1548
+ def test_indent
1549
+ assert_renders <<SASS, <<SCSS, :indent => " "
1550
+ foo bar
1551
+ baz bang
1552
+ baz: bang
1553
+ bip: bop
1554
+ blat: boo
1555
+ SASS
1556
+ foo bar {
1557
+ baz bang {
1558
+ baz: bang;
1559
+ bip: bop;
1560
+ }
1561
+ blat: boo;
1562
+ }
1563
+ SCSS
1564
+
1565
+ assert_renders <<SASS, <<SCSS, :indent => "\t"
1566
+ foo bar
1567
+ baz bang
1568
+ baz: bang
1569
+ bip: bop
1570
+ blat: boo
1571
+ SASS
1572
+ foo bar {
1573
+ baz bang {
1574
+ baz: bang;
1575
+ bip: bop;
1576
+ }
1577
+ blat: boo;
1578
+ }
1579
+ SCSS
1580
+
1581
+ assert_sass_to_scss <<SCSS, <<SASS, :indent => " "
1582
+ foo bar {
1583
+ baz bang {
1584
+ baz: bang;
1585
+ bip: bop;
1586
+ }
1587
+ blat: boo;
1588
+ }
1589
+ SCSS
1590
+ foo bar
1591
+ baz bang
1592
+ baz: bang
1593
+ bip: bop
1594
+ blat: boo
1595
+ SASS
1596
+
1597
+ assert_sass_to_scss <<SCSS, <<SASS, :indent => "\t"
1598
+ foo bar {
1599
+ baz bang {
1600
+ baz: bang;
1601
+ bip: bop;
1602
+ }
1603
+ blat: boo;
1604
+ }
1605
+ SCSS
1606
+ foo bar
1607
+ baz bang
1608
+ baz: bang
1609
+ bip: bop
1610
+ blat: boo
1611
+ SASS
1612
+
1613
+ assert_scss_to_sass <<SASS, <<SCSS, :indent => " "
1614
+ foo bar
1615
+ baz bang
1616
+ baz: bang
1617
+ bip: bop
1618
+ blat: boo
1619
+ SASS
1620
+ foo bar {
1621
+ baz bang {
1622
+ baz: bang;
1623
+ bip: bop;
1624
+ }
1625
+ blat: boo;
1626
+ }
1627
+ SCSS
1628
+
1629
+ assert_scss_to_sass <<SASS, <<SCSS, :indent => "\t"
1630
+ foo bar
1631
+ baz bang
1632
+ baz: bang
1633
+ bip: bop
1634
+ blat: boo
1635
+ SASS
1636
+ foo bar {
1637
+ baz bang {
1638
+ baz: bang;
1639
+ bip: bop;
1640
+ }
1641
+ blat: boo;
1642
+ }
1643
+ SCSS
1644
+ end
1645
+
1646
+ def test_extend_with_optional
1647
+ assert_scss_to_sass <<SASS, <<SCSS
1648
+ foo
1649
+ @extend .bar !optional
1650
+ SASS
1651
+ foo {
1652
+ @extend .bar !optional;
1653
+ }
1654
+ SCSS
1655
+ end
1656
+
1657
+ def test_mixin_var_args
1658
+ assert_scss_to_sass <<SASS, <<SCSS
1659
+ =foo($args...)
1660
+ a: b
1661
+
1662
+ =bar($a, $args...)
1663
+ a: b
1664
+
1665
+ .foo
1666
+ +foo($list...)
1667
+ +bar(1, $list...)
1668
+ SASS
1669
+ @mixin foo($args...) {
1670
+ a: b;
1671
+ }
1672
+
1673
+ @mixin bar($a, $args...) {
1674
+ a: b;
1675
+ }
1676
+
1677
+ .foo {
1678
+ @include foo($list...);
1679
+ @include bar(1, $list...);
1680
+ }
1681
+ SCSS
1682
+ end
1683
+
1684
+ def test_mixin_var_kwargs
1685
+ assert_scss_to_sass <<SASS, <<SCSS
1686
+ =foo($a: b, $c: d)
1687
+ a: $a
1688
+ c: $c
1689
+
1690
+ .foo
1691
+ +foo($list..., $map...)
1692
+ +foo(pos, $list..., $kwd: val, $map...)
1693
+ SASS
1694
+ @mixin foo($a: b, $c: d) {
1695
+ a: $a;
1696
+ c: $c;
1697
+ }
1698
+
1699
+ .foo {
1700
+ @include foo($list..., $map...);
1701
+ @include foo(pos, $list..., $kwd: val, $map...);
1702
+ }
1703
+ SCSS
1704
+ end
1705
+
1706
+ def test_function_var_args
1707
+ assert_scss_to_sass <<SASS, <<SCSS
1708
+ @function foo($args...)
1709
+ @return foo
1710
+
1711
+ @function bar($a, $args...)
1712
+ @return bar
1713
+
1714
+ .foo
1715
+ a: foo($list...)
1716
+ b: bar(1, $list...)
1717
+ SASS
1718
+ @function foo($args...) {
1719
+ @return foo;
1720
+ }
1721
+
1722
+ @function bar($a, $args...) {
1723
+ @return bar;
1724
+ }
1725
+
1726
+ .foo {
1727
+ a: foo($list...);
1728
+ b: bar(1, $list...);
1729
+ }
1730
+ SCSS
1731
+ end
1732
+
1733
+ def test_function_var_kwargs
1734
+ assert_scss_to_sass <<SASS, <<SCSS
1735
+ @function foo($a: b, $c: d)
1736
+ @return foo
1737
+
1738
+ .foo
1739
+ a: foo($list..., $map...)
1740
+ b: foo(pos, $list..., $kwd: val, $map...)
1741
+ SASS
1742
+ @function foo($a: b, $c: d) {
1743
+ @return foo;
1744
+ }
1745
+
1746
+ .foo {
1747
+ a: foo($list..., $map...);
1748
+ b: foo(pos, $list..., $kwd: val, $map...);
1749
+ }
1750
+ SCSS
1751
+ end
1752
+
1753
+ def test_at_root
1754
+ assert_scss_to_sass <<SASS, <<SCSS
1755
+ .foo
1756
+ @at-root
1757
+ .bar
1758
+ a: b
1759
+ .baz
1760
+ c: d
1761
+ SASS
1762
+ .foo {
1763
+ @at-root {
1764
+ .bar {
1765
+ a: b;
1766
+ }
1767
+ .baz {
1768
+ c: d;
1769
+ }
1770
+ }
1771
+ }
1772
+ SCSS
1773
+ end
1774
+
1775
+ def test_at_root_with_selector
1776
+ assert_scss_to_sass <<SASS, <<SCSS
1777
+ .foo
1778
+ @at-root .bar
1779
+ a: b
1780
+ SASS
1781
+ .foo {
1782
+ @at-root .bar {
1783
+ a: b;
1784
+ }
1785
+ }
1786
+ SCSS
1787
+ end
1788
+
1789
+ def test_at_root_without
1790
+ assert_scss_to_sass <<SASS, <<SCSS
1791
+ .foo
1792
+ @at-root (without: media rule)
1793
+ a: b
1794
+ SASS
1795
+ .foo {
1796
+ @at-root (without: media rule) {
1797
+ a: b;
1798
+ }
1799
+ }
1800
+ SCSS
1801
+ end
1802
+
1803
+ def test_at_root_with
1804
+ assert_scss_to_sass <<SASS, <<SCSS
1805
+ .foo
1806
+ @at-root (with: media rule)
1807
+ a: b
1808
+ SASS
1809
+ .foo {
1810
+ @at-root (with: media rule) {
1811
+ a: b;
1812
+ }
1813
+ }
1814
+ SCSS
1815
+ end
1816
+
1817
+ def test_function_var_kwargs_with_list
1818
+ assert_scss_to_sass <<SASS, <<SCSS
1819
+ @function foo($a: b, $c: d)
1820
+ @return $a, $c
1821
+
1822
+ .foo
1823
+ a: foo($list..., $map...)
1824
+ SASS
1825
+ @function foo($a: b, $c: d) {
1826
+ @return $a, $c;
1827
+ }
1828
+
1829
+ .foo {
1830
+ a: foo($list..., $map...);
1831
+ }
1832
+ SCSS
1833
+ end
1834
+
1835
+ def test_keyframes
1836
+ assert_renders(<<SASS, <<SCSS)
1837
+ @keyframes identifier
1838
+ 0%
1839
+ top: 0
1840
+ left: 0
1841
+ 30%
1842
+ top: 50px
1843
+ 68%, 72%
1844
+ left: 50px
1845
+ 100%
1846
+ top: 100px
1847
+ left: 100%
1848
+ SASS
1849
+ @keyframes identifier {
1850
+ 0% {
1851
+ top: 0;
1852
+ left: 0;
1853
+ }
1854
+ 30% {
1855
+ top: 50px;
1856
+ }
1857
+ 68%, 72% {
1858
+ left: 50px;
1859
+ }
1860
+ 100% {
1861
+ top: 100px;
1862
+ left: 100%;
1863
+ }
1864
+ }
1865
+ SCSS
1866
+ end
1867
+
1868
+ ## Regression Tests
1869
+
1870
+ def test_list_in_args
1871
+ assert_renders(<<SASS, <<SCSS)
1872
+ +mixin((a, b, c))
1873
+
1874
+ +mixin($arg: (a, b, c))
1875
+
1876
+ +mixin(a, b, (c, d, e)...)
1877
+ SASS
1878
+ @include mixin((a, b, c));
1879
+
1880
+ @include mixin($arg: (a, b, c));
1881
+
1882
+ @include mixin(a, b, (c, d, e)...);
1883
+ SCSS
1884
+ end
1885
+
1886
+ def test_media_query_with_expr
1887
+ assert_scss_to_sass <<SASS, <<SCSS
1888
+ @media foo and (bar: baz)
1889
+ a: b
1890
+ SASS
1891
+ @media foo and (bar: baz) {
1892
+ a: b; }
1893
+ SCSS
1894
+ end
1895
+
1896
+ def test_nested_if_statements
1897
+ assert_renders(<<SASS, <<SCSS)
1898
+ @if $foo
1899
+ one
1900
+ a: b
1901
+ @else
1902
+ @if $bar
1903
+ two
1904
+ a: b
1905
+ @else
1906
+ three
1907
+ a: b
1908
+ SASS
1909
+ @if $foo {
1910
+ one {
1911
+ a: b;
1912
+ }
1913
+ }
1914
+ @else {
1915
+ @if $bar {
1916
+ two {
1917
+ a: b;
1918
+ }
1919
+ }
1920
+ @else {
1921
+ three {
1922
+ a: b;
1923
+ }
1924
+ }
1925
+ }
1926
+ SCSS
1927
+ end
1928
+
1929
+ def test_comment_indentation
1930
+ assert_renders(<<SASS, <<SCSS, :indent => ' ')
1931
+ foo
1932
+ // bar
1933
+ /* baz
1934
+ a: b
1935
+ SASS
1936
+ foo {
1937
+ // bar
1938
+ /* baz */
1939
+ a: b;
1940
+ }
1941
+ SCSS
1942
+ end
1943
+
1944
+ def test_keyword_arguments
1945
+ assert_renders(<<SASS, <<SCSS, :dasherize => true)
1946
+ $foo: foo($dash-ed: 2px)
1947
+ SASS
1948
+ $foo: foo($dash-ed: 2px);
1949
+ SCSS
1950
+ assert_scss_to_sass(<<SASS, <<SCSS, :dasherize => true)
1951
+ $foo: foo($dash-ed: 2px)
1952
+ SASS
1953
+ $foo: foo($dash_ed: 2px);
1954
+ SCSS
1955
+ assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
1956
+ $foo: foo($dash-ed: 2px);
1957
+ SCSS
1958
+ $foo: foo($dash_ed: 2px)
1959
+ SASS
1960
+ assert_renders(<<SASS, <<SCSS)
1961
+ $foo: foo($under_scored: 1px)
1962
+ SASS
1963
+ $foo: foo($under_scored: 1px);
1964
+ SCSS
1965
+ assert_renders(<<SASS, <<SCSS)
1966
+ $foo: foo($dash-ed: 2px, $under_scored: 1px)
1967
+ SASS
1968
+ $foo: foo($dash-ed: 2px, $under_scored: 1px);
1969
+ SCSS
1970
+ end
1971
+
1972
+ def test_ambiguous_negation
1973
+ assert_renders(<<SASS, <<SCSS, :indent => ' ')
1974
+ foo
1975
+ ok: -$foo
1976
+ comma: 10px, -$foo
1977
+ needs-parens: 10px (-$foo)
1978
+ no-parens: a 50px + 60px b
1979
+ SASS
1980
+ foo {
1981
+ ok: -$foo;
1982
+ comma: 10px, -$foo;
1983
+ needs-parens: 10px (-$foo);
1984
+ no-parens: a 50px + 60px b;
1985
+ }
1986
+ SCSS
1987
+ end
1988
+
1989
+ def test_variable_with_global
1990
+ assert_renders(<<SASS, <<SCSS)
1991
+ $var: 1
1992
+
1993
+ foo
1994
+ $var: 2 !global
1995
+ $var: 3 !global !default
1996
+ SASS
1997
+ $var: 1;
1998
+
1999
+ foo {
2000
+ $var: 2 !global;
2001
+ $var: 3 !global !default;
2002
+ }
2003
+ SCSS
2004
+ end
2005
+
2006
+ private
2007
+
2008
+ def assert_sass_to_sass(sass, options = {})
2009
+ assert_equal(sass.rstrip, to_sass(sass, options).rstrip,
2010
+ "Expected Sass to transform to itself")
2011
+ end
2012
+
2013
+ def assert_scss_to_sass(sass, scss, options = {})
2014
+ assert_equal(sass.rstrip, to_sass(scss, options.merge(:syntax => :scss)).rstrip,
2015
+ "Expected SCSS to transform to Sass")
2016
+ end
2017
+
2018
+ def assert_scss_to_scss(scss, in_scss = nil, options = nil)
2019
+ if in_scss.is_a?(Hash)
2020
+ options = in_scss
2021
+ in_scss = nil
2022
+ end
2023
+
2024
+ in_scss ||= scss
2025
+ options ||= {}
2026
+
2027
+ assert_equal(scss.rstrip, to_scss(in_scss, options.merge(:syntax => :scss)).rstrip,
2028
+ "Expected SCSS to transform to #{scss == in_scss ? 'itself' : 'SCSS'}")
2029
+ end
2030
+
2031
+ def assert_sass_to_scss(scss, sass, options = {})
2032
+ assert_equal(scss.rstrip, to_scss(sass, options).rstrip,
2033
+ "Expected Sass to transform to SCSS")
2034
+ end
2035
+
2036
+ def assert_renders(sass, scss, options = {})
2037
+ assert_sass_to_sass(sass, options)
2038
+ assert_scss_to_sass(sass, scss, options)
2039
+ assert_scss_to_scss(scss, options)
2040
+ assert_sass_to_scss(scss, sass, options)
2041
+ end
2042
+
2043
+ def to_sass(scss, options = {})
2044
+ Sass::Util.silence_sass_warnings do
2045
+ Sass::Engine.new(scss, options).to_tree.to_sass(options)
2046
+ end
2047
+ end
2048
+
2049
+ def to_scss(sass, options = {})
2050
+ Sass::Util.silence_sass_warnings do
2051
+ Sass::Engine.new(sass, options).to_tree.to_scss(options)
2052
+ end
2053
+ end
2054
+ end