aliddle-sass 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. data/.yardopts +11 -0
  2. data/CONTRIBUTING +3 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +201 -0
  5. data/Rakefile +347 -0
  6. data/VERSION +1 -0
  7. data/VERSION_NAME +1 -0
  8. data/bin/sass +9 -0
  9. data/bin/sass-convert +8 -0
  10. data/bin/scss +9 -0
  11. data/extra/update_watch.rb +13 -0
  12. data/init.rb +18 -0
  13. data/lib/sass.rb +95 -0
  14. data/lib/sass/cache_stores.rb +15 -0
  15. data/lib/sass/cache_stores/base.rb +88 -0
  16. data/lib/sass/cache_stores/chain.rb +33 -0
  17. data/lib/sass/cache_stores/filesystem.rb +60 -0
  18. data/lib/sass/cache_stores/memory.rb +47 -0
  19. data/lib/sass/cache_stores/null.rb +25 -0
  20. data/lib/sass/callbacks.rb +66 -0
  21. data/lib/sass/css.rb +409 -0
  22. data/lib/sass/engine.rb +928 -0
  23. data/lib/sass/environment.rb +101 -0
  24. data/lib/sass/error.rb +201 -0
  25. data/lib/sass/exec.rb +707 -0
  26. data/lib/sass/importers.rb +22 -0
  27. data/lib/sass/importers/base.rb +139 -0
  28. data/lib/sass/importers/filesystem.rb +190 -0
  29. data/lib/sass/logger.rb +15 -0
  30. data/lib/sass/logger/base.rb +32 -0
  31. data/lib/sass/logger/log_level.rb +49 -0
  32. data/lib/sass/media.rb +213 -0
  33. data/lib/sass/plugin.rb +132 -0
  34. data/lib/sass/plugin/compiler.rb +406 -0
  35. data/lib/sass/plugin/configuration.rb +123 -0
  36. data/lib/sass/plugin/generic.rb +15 -0
  37. data/lib/sass/plugin/merb.rb +48 -0
  38. data/lib/sass/plugin/rack.rb +60 -0
  39. data/lib/sass/plugin/rails.rb +47 -0
  40. data/lib/sass/plugin/staleness_checker.rb +183 -0
  41. data/lib/sass/railtie.rb +9 -0
  42. data/lib/sass/repl.rb +57 -0
  43. data/lib/sass/root.rb +7 -0
  44. data/lib/sass/script.rb +39 -0
  45. data/lib/sass/script/arg_list.rb +52 -0
  46. data/lib/sass/script/bool.rb +18 -0
  47. data/lib/sass/script/color.rb +606 -0
  48. data/lib/sass/script/css_lexer.rb +29 -0
  49. data/lib/sass/script/css_parser.rb +31 -0
  50. data/lib/sass/script/funcall.rb +237 -0
  51. data/lib/sass/script/functions.rb +1543 -0
  52. data/lib/sass/script/interpolation.rb +79 -0
  53. data/lib/sass/script/lexer.rb +348 -0
  54. data/lib/sass/script/list.rb +85 -0
  55. data/lib/sass/script/literal.rb +221 -0
  56. data/lib/sass/script/node.rb +99 -0
  57. data/lib/sass/script/null.rb +37 -0
  58. data/lib/sass/script/number.rb +453 -0
  59. data/lib/sass/script/operation.rb +110 -0
  60. data/lib/sass/script/parser.rb +495 -0
  61. data/lib/sass/script/string.rb +51 -0
  62. data/lib/sass/script/string_interpolation.rb +103 -0
  63. data/lib/sass/script/unary_operation.rb +69 -0
  64. data/lib/sass/script/variable.rb +58 -0
  65. data/lib/sass/scss.rb +16 -0
  66. data/lib/sass/scss/css_parser.rb +36 -0
  67. data/lib/sass/scss/parser.rb +1179 -0
  68. data/lib/sass/scss/rx.rb +133 -0
  69. data/lib/sass/scss/script_lexer.rb +15 -0
  70. data/lib/sass/scss/script_parser.rb +25 -0
  71. data/lib/sass/scss/static_parser.rb +54 -0
  72. data/lib/sass/selector.rb +452 -0
  73. data/lib/sass/selector/abstract_sequence.rb +94 -0
  74. data/lib/sass/selector/comma_sequence.rb +92 -0
  75. data/lib/sass/selector/sequence.rb +507 -0
  76. data/lib/sass/selector/simple.rb +119 -0
  77. data/lib/sass/selector/simple_sequence.rb +212 -0
  78. data/lib/sass/shared.rb +76 -0
  79. data/lib/sass/supports.rb +229 -0
  80. data/lib/sass/tree/charset_node.rb +22 -0
  81. data/lib/sass/tree/comment_node.rb +82 -0
  82. data/lib/sass/tree/content_node.rb +9 -0
  83. data/lib/sass/tree/css_import_node.rb +60 -0
  84. data/lib/sass/tree/debug_node.rb +18 -0
  85. data/lib/sass/tree/directive_node.rb +42 -0
  86. data/lib/sass/tree/each_node.rb +24 -0
  87. data/lib/sass/tree/extend_node.rb +36 -0
  88. data/lib/sass/tree/for_node.rb +36 -0
  89. data/lib/sass/tree/function_node.rb +34 -0
  90. data/lib/sass/tree/if_node.rb +52 -0
  91. data/lib/sass/tree/import_node.rb +75 -0
  92. data/lib/sass/tree/media_node.rb +58 -0
  93. data/lib/sass/tree/mixin_def_node.rb +38 -0
  94. data/lib/sass/tree/mixin_node.rb +39 -0
  95. data/lib/sass/tree/node.rb +196 -0
  96. data/lib/sass/tree/prop_node.rb +152 -0
  97. data/lib/sass/tree/return_node.rb +18 -0
  98. data/lib/sass/tree/root_node.rb +28 -0
  99. data/lib/sass/tree/rule_node.rb +132 -0
  100. data/lib/sass/tree/supports_node.rb +51 -0
  101. data/lib/sass/tree/trace_node.rb +32 -0
  102. data/lib/sass/tree/variable_node.rb +30 -0
  103. data/lib/sass/tree/visitors/base.rb +75 -0
  104. data/lib/sass/tree/visitors/check_nesting.rb +147 -0
  105. data/lib/sass/tree/visitors/convert.rb +316 -0
  106. data/lib/sass/tree/visitors/cssize.rb +229 -0
  107. data/lib/sass/tree/visitors/deep_copy.rb +102 -0
  108. data/lib/sass/tree/visitors/extend.rb +68 -0
  109. data/lib/sass/tree/visitors/perform.rb +446 -0
  110. data/lib/sass/tree/visitors/set_options.rb +125 -0
  111. data/lib/sass/tree/visitors/to_css.rb +230 -0
  112. data/lib/sass/tree/warn_node.rb +18 -0
  113. data/lib/sass/tree/while_node.rb +18 -0
  114. data/lib/sass/util.rb +906 -0
  115. data/lib/sass/util/multibyte_string_scanner.rb +155 -0
  116. data/lib/sass/util/subset_map.rb +109 -0
  117. data/lib/sass/util/test.rb +10 -0
  118. data/lib/sass/version.rb +126 -0
  119. data/rails/init.rb +1 -0
  120. data/test/Gemfile +3 -0
  121. data/test/Gemfile.lock +10 -0
  122. data/test/sass/cache_test.rb +89 -0
  123. data/test/sass/callbacks_test.rb +61 -0
  124. data/test/sass/conversion_test.rb +1760 -0
  125. data/test/sass/css2sass_test.rb +439 -0
  126. data/test/sass/data/hsl-rgb.txt +319 -0
  127. data/test/sass/engine_test.rb +3243 -0
  128. data/test/sass/exec_test.rb +86 -0
  129. data/test/sass/extend_test.rb +1461 -0
  130. data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  131. data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  132. data/test/sass/functions_test.rb +1139 -0
  133. data/test/sass/importer_test.rb +192 -0
  134. data/test/sass/logger_test.rb +58 -0
  135. data/test/sass/mock_importer.rb +49 -0
  136. data/test/sass/more_results/more1.css +9 -0
  137. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  138. data/test/sass/more_results/more_import.css +29 -0
  139. data/test/sass/more_templates/_more_partial.sass +2 -0
  140. data/test/sass/more_templates/more1.sass +23 -0
  141. data/test/sass/more_templates/more_import.sass +11 -0
  142. data/test/sass/plugin_test.rb +550 -0
  143. data/test/sass/results/alt.css +4 -0
  144. data/test/sass/results/basic.css +9 -0
  145. data/test/sass/results/cached_import_option.css +3 -0
  146. data/test/sass/results/compact.css +5 -0
  147. data/test/sass/results/complex.css +86 -0
  148. data/test/sass/results/compressed.css +1 -0
  149. data/test/sass/results/expanded.css +19 -0
  150. data/test/sass/results/filename_fn.css +3 -0
  151. data/test/sass/results/if.css +3 -0
  152. data/test/sass/results/import.css +31 -0
  153. data/test/sass/results/import_charset.css +5 -0
  154. data/test/sass/results/import_charset_1_8.css +5 -0
  155. data/test/sass/results/import_charset_ibm866.css +5 -0
  156. data/test/sass/results/import_content.css +1 -0
  157. data/test/sass/results/line_numbers.css +49 -0
  158. data/test/sass/results/mixins.css +95 -0
  159. data/test/sass/results/multiline.css +24 -0
  160. data/test/sass/results/nested.css +22 -0
  161. data/test/sass/results/options.css +1 -0
  162. data/test/sass/results/parent_ref.css +13 -0
  163. data/test/sass/results/script.css +16 -0
  164. data/test/sass/results/scss_import.css +31 -0
  165. data/test/sass/results/scss_importee.css +2 -0
  166. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  167. data/test/sass/results/subdir/subdir.css +3 -0
  168. data/test/sass/results/units.css +11 -0
  169. data/test/sass/results/warn.css +0 -0
  170. data/test/sass/results/warn_imported.css +0 -0
  171. data/test/sass/script_conversion_test.rb +299 -0
  172. data/test/sass/script_test.rb +591 -0
  173. data/test/sass/scss/css_test.rb +1093 -0
  174. data/test/sass/scss/rx_test.rb +156 -0
  175. data/test/sass/scss/scss_test.rb +2043 -0
  176. data/test/sass/scss/test_helper.rb +37 -0
  177. data/test/sass/templates/_cached_import_option_partial.scss +1 -0
  178. data/test/sass/templates/_double_import_loop2.sass +1 -0
  179. data/test/sass/templates/_filename_fn_import.scss +11 -0
  180. data/test/sass/templates/_imported_charset_ibm866.sass +4 -0
  181. data/test/sass/templates/_imported_charset_utf8.sass +4 -0
  182. data/test/sass/templates/_imported_content.sass +3 -0
  183. data/test/sass/templates/_partial.sass +2 -0
  184. data/test/sass/templates/_same_name_different_partiality.scss +1 -0
  185. data/test/sass/templates/alt.sass +16 -0
  186. data/test/sass/templates/basic.sass +23 -0
  187. data/test/sass/templates/bork1.sass +2 -0
  188. data/test/sass/templates/bork2.sass +2 -0
  189. data/test/sass/templates/bork3.sass +2 -0
  190. data/test/sass/templates/bork4.sass +2 -0
  191. data/test/sass/templates/bork5.sass +3 -0
  192. data/test/sass/templates/cached_import_option.scss +3 -0
  193. data/test/sass/templates/compact.sass +17 -0
  194. data/test/sass/templates/complex.sass +305 -0
  195. data/test/sass/templates/compressed.sass +15 -0
  196. data/test/sass/templates/double_import_loop1.sass +1 -0
  197. data/test/sass/templates/expanded.sass +17 -0
  198. data/test/sass/templates/filename_fn.scss +18 -0
  199. data/test/sass/templates/if.sass +11 -0
  200. data/test/sass/templates/import.sass +12 -0
  201. data/test/sass/templates/import_charset.sass +9 -0
  202. data/test/sass/templates/import_charset_1_8.sass +6 -0
  203. data/test/sass/templates/import_charset_ibm866.sass +11 -0
  204. data/test/sass/templates/import_content.sass +4 -0
  205. data/test/sass/templates/importee.less +2 -0
  206. data/test/sass/templates/importee.sass +19 -0
  207. data/test/sass/templates/line_numbers.sass +13 -0
  208. data/test/sass/templates/mixin_bork.sass +5 -0
  209. data/test/sass/templates/mixins.sass +76 -0
  210. data/test/sass/templates/multiline.sass +20 -0
  211. data/test/sass/templates/nested.sass +25 -0
  212. data/test/sass/templates/nested_bork1.sass +2 -0
  213. data/test/sass/templates/nested_bork2.sass +2 -0
  214. data/test/sass/templates/nested_bork3.sass +2 -0
  215. data/test/sass/templates/nested_bork4.sass +2 -0
  216. data/test/sass/templates/nested_import.sass +2 -0
  217. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  218. data/test/sass/templates/options.sass +2 -0
  219. data/test/sass/templates/parent_ref.sass +25 -0
  220. data/test/sass/templates/same_name_different_ext.sass +2 -0
  221. data/test/sass/templates/same_name_different_ext.scss +1 -0
  222. data/test/sass/templates/same_name_different_partiality.scss +1 -0
  223. data/test/sass/templates/script.sass +101 -0
  224. data/test/sass/templates/scss_import.scss +11 -0
  225. data/test/sass/templates/scss_importee.scss +1 -0
  226. data/test/sass/templates/single_import_loop.sass +1 -0
  227. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  228. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  229. data/test/sass/templates/subdir/subdir.sass +6 -0
  230. data/test/sass/templates/units.sass +11 -0
  231. data/test/sass/templates/warn.sass +3 -0
  232. data/test/sass/templates/warn_imported.sass +4 -0
  233. data/test/sass/test_helper.rb +8 -0
  234. data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
  235. data/test/sass/util/subset_map_test.rb +91 -0
  236. data/test/sass/util_test.rb +313 -0
  237. data/test/test_helper.rb +80 -0
  238. metadata +348 -0
@@ -0,0 +1,439 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../test_helper'
4
+ require 'sass/css'
5
+
6
+ class CSS2SassTest < Test::Unit::TestCase
7
+ def test_basic
8
+ css = <<CSS
9
+ h1 {
10
+ color: red;
11
+ }
12
+ CSS
13
+ assert_equal(<<SASS, css2sass(css))
14
+ h1
15
+ color: red
16
+ SASS
17
+ assert_equal(<<SASS, css2sass(css, :old => true))
18
+ h1
19
+ :color red
20
+ SASS
21
+ end
22
+
23
+ def test_nesting
24
+ assert_equal(<<SASS, css2sass(<<CSS))
25
+ li
26
+ display: none
27
+ a
28
+ text-decoration: none
29
+ span
30
+ color: yellow
31
+ &:hover
32
+ text-decoration: underline
33
+ SASS
34
+ li {
35
+ display: none;
36
+ }
37
+
38
+ li a {
39
+ text-decoration: none;
40
+ }
41
+
42
+ li a span {
43
+ color: yellow;
44
+ }
45
+
46
+ li a:hover {
47
+ text-decoration: underline;
48
+ }
49
+ CSS
50
+ end
51
+
52
+ def test_no_nesting_around_rules
53
+ assert_equal(<<SASS, css2sass(<<CSS))
54
+ div .warning
55
+ color: #d21a19
56
+
57
+ span .debug
58
+ cursor: crosshair
59
+
60
+ div .debug
61
+ cursor: default
62
+ SASS
63
+ div .warning {
64
+ color: #d21a19; }
65
+ span .debug {
66
+ cursor: crosshair;}
67
+ div .debug {
68
+ cursor: default; }
69
+ CSS
70
+ end
71
+
72
+ def test_comments_multiline
73
+ css = <<CSS
74
+ /* comment */
75
+ elephant.rawr {
76
+ rampages: excessively;
77
+ }
78
+
79
+ /* actual multiline
80
+ comment */
81
+ span.turkey {
82
+ isdinner: true;
83
+ }
84
+
85
+ .turducken {
86
+ /* Sounds funny
87
+ doesn't it */
88
+ chimera: not_really;
89
+ }
90
+
91
+ #overhere {
92
+ bored: sorta; /* it's for a good
93
+ cause */
94
+ better_than: thread_pools;
95
+ }
96
+
97
+ #one_more {
98
+ finally: srsly;
99
+ } /* just a line here */
100
+ CSS
101
+ sass = <<SASS
102
+ /* comment
103
+
104
+ elephant.rawr
105
+ rampages: excessively
106
+
107
+ /* actual multiline
108
+ *comment
109
+
110
+ span.turkey
111
+ isdinner: true
112
+
113
+ .turducken
114
+ /* Sounds funny
115
+ * doesn't it
116
+ chimera: not_really
117
+
118
+ #overhere
119
+ bored: sorta
120
+ /* it's for a good
121
+ * cause
122
+ better_than: thread_pools
123
+
124
+ #one_more
125
+ finally: srsly
126
+
127
+ /* just a line here
128
+ SASS
129
+ assert_equal(sass, css2sass(css))
130
+ end
131
+
132
+ def test_fold_commas
133
+ assert_equal(<<SASS, css2sass(<<CSS))
134
+ li
135
+ .one, .two
136
+ color: red
137
+ SASS
138
+ li .one {
139
+ color: red;
140
+ }
141
+ li .two {
142
+ color: red;
143
+ }
144
+ CSS
145
+
146
+ assert_equal(<<SASS, css2sass(<<CSS))
147
+ .one
148
+ color: green
149
+
150
+ .two
151
+ color: green
152
+ color: red
153
+
154
+ .three
155
+ color: red
156
+ SASS
157
+ .one, .two {
158
+ color: green;
159
+ }
160
+
161
+ .two, .three {
162
+ color: red;
163
+ }
164
+ CSS
165
+ end
166
+
167
+ def test_bad_formatting
168
+ assert_equal(<<SASS, css2sass(<<CSS))
169
+ hello
170
+ parent: true
171
+ there
172
+ parent: false
173
+ who
174
+ hoo: false
175
+ why
176
+ y: true
177
+ when
178
+ wen: nao
179
+
180
+ down_here
181
+ yeah: true
182
+ SASS
183
+ hello {
184
+ parent: true;
185
+ }
186
+
187
+ hello there {
188
+ parent: false;
189
+ }
190
+ hello who {
191
+ hoo: false;
192
+ }
193
+ hello why {
194
+ y: true;
195
+ }
196
+ hello when {
197
+ wen: nao;
198
+ }
199
+
200
+
201
+
202
+ down_here { yeah: true; }
203
+ CSS
204
+ end
205
+
206
+ def test_comments_in_selectors
207
+ assert_equal(<<SASS, css2sass(<<CSS))
208
+ .js
209
+ #location-navigation-form .form-submit, #business-listing-form .form-submit, #detailTabs ul, #detailsEnhanced #addTags, #locationSearchList, #moreHoods
210
+ display: none
211
+
212
+ #navListLeft
213
+ display: none
214
+ SASS
215
+ .js #location-navigation-form .form-submit,
216
+ .js #business-listing-form .form-submit,
217
+ .js #detailTabs ul,
218
+ /* .js #addReview, */
219
+ /* .js #addTags, */
220
+ .js #detailsEnhanced #addTags,
221
+ .js #locationSearchList,
222
+ .js #moreHoods,
223
+ #navListLeft
224
+ { display: none; }
225
+ CSS
226
+ end
227
+
228
+ def test_pseudo_classes_are_escaped
229
+ assert_equal(<<SASS, css2sass(<<CSS))
230
+ \\:focus
231
+ a: b
232
+ \\:foo
233
+ bar: baz
234
+ SASS
235
+ :focus {a: b;}
236
+ :focus :foo {bar: baz;}
237
+ CSS
238
+ end
239
+
240
+ def test_subject
241
+ assert_equal(<<SASS, css2sass(<<CSS))
242
+ .foo
243
+ .bar!
244
+ .baz
245
+ a: b
246
+ .bip
247
+ c: d
248
+ .bar .bonk
249
+ e: f
250
+
251
+ .flip!
252
+ &.bar
253
+ a: b
254
+ &.baz
255
+ c: d
256
+ SASS
257
+ .foo .bar! .baz {a: b;}
258
+ .foo .bar! .bip {c: d;}
259
+ .foo .bar .bonk {e: f;}
260
+
261
+ .flip.bar! {a: b;}
262
+ .flip.baz! {c: d;}
263
+ CSS
264
+ end
265
+
266
+ # Regressions
267
+
268
+ def test_nesting_within_media
269
+ assert_equal(<<SASS, css2sass(<<CSS))
270
+ @media all
271
+ .next .vevent
272
+ padding-left: 0
273
+ padding-right: 0
274
+ SASS
275
+ @media all {
276
+ .next .vevent {
277
+ padding-left: 0;
278
+ padding-right: 0; } }
279
+ CSS
280
+ end
281
+
282
+ def test_multiline_selector_within_media_and_with_child_selector
283
+ assert_equal(<<SASS, css2sass(<<CSS))
284
+ @media all
285
+ foo bar, baz
286
+ padding-left: 0
287
+ padding-right: 0
288
+ SASS
289
+ @media all {
290
+ foo bar,
291
+ baz {
292
+ padding-left: 0;
293
+ padding-right: 0; } }
294
+ CSS
295
+ end
296
+
297
+ def test_double_comma
298
+ assert_equal(<<SASS, css2sass(<<CSS))
299
+ foo, bar
300
+ a: b
301
+ SASS
302
+ foo, , bar { a: b }
303
+ CSS
304
+ end
305
+
306
+ def test_selector_splitting
307
+ assert_equal(<<SASS, css2sass(<<CSS))
308
+ .foo >
309
+ .bar
310
+ a: b
311
+ .baz
312
+ c: d
313
+ SASS
314
+ .foo>.bar {a: b}
315
+ .foo>.baz {c: d}
316
+ CSS
317
+
318
+ assert_equal(<<SASS, css2sass(<<CSS))
319
+ .foo
320
+ &::bar
321
+ a: b
322
+ &::baz
323
+ c: d
324
+ SASS
325
+ .foo::bar {a: b}
326
+ .foo::baz {c: d}
327
+ CSS
328
+ end
329
+
330
+ def test_triple_nesting
331
+ assert_equal(<<SASS, css2sass(<<CSS))
332
+ .foo .bar .baz
333
+ a: b
334
+ SASS
335
+ .foo .bar .baz {a: b}
336
+ CSS
337
+
338
+ assert_equal(<<SASS, css2sass(<<CSS))
339
+ .bar > .baz
340
+ c: d
341
+ SASS
342
+ .bar > .baz {c: d}
343
+ CSS
344
+ end
345
+
346
+ # Error reporting
347
+
348
+ def test_error_reporting
349
+ css2sass("foo")
350
+ assert(false, "Expected exception")
351
+ rescue Sass::SyntaxError => err
352
+ assert_equal(1, err.sass_line)
353
+ assert_equal('Invalid CSS after "foo": expected "{", was ""', err.message)
354
+ end
355
+
356
+ def test_error_reporting_in_line
357
+ css2sass("foo\nbar }\nbaz")
358
+ assert(false, "Expected exception")
359
+ rescue Sass::SyntaxError => err
360
+ assert_equal(2, err.sass_line)
361
+ assert_equal('Invalid CSS after "bar ": expected "{", was "}"', err.message)
362
+ end
363
+
364
+ def test_error_truncate_after
365
+ css2sass("#{"a" * 16}foo")
366
+ assert(false, "Expected exception")
367
+ rescue Sass::SyntaxError => err
368
+ assert_equal(1, err.sass_line)
369
+ assert_equal('Invalid CSS after "...aaaaaaaaaaaafoo": expected "{", was ""', err.message)
370
+ end
371
+
372
+ def test_error_truncate_was
373
+ css2sass("foo }foo#{"a" * 15}")
374
+ assert(false, "Expected exception")
375
+ rescue Sass::SyntaxError => err
376
+ assert_equal(1, err.sass_line)
377
+ assert_equal('Invalid CSS after "foo ": expected "{", was "}fooaaaaaaaaaaa..."', err.message)
378
+ end
379
+
380
+ def test_error_doesnt_truncate_after_when_elipsis_would_add_length
381
+ css2sass("#{"a" * 15}foo")
382
+ assert(false, "Expected exception")
383
+ rescue Sass::SyntaxError => err
384
+ assert_equal(1, err.sass_line)
385
+ assert_equal('Invalid CSS after "aaaaaaaaaaaaaaafoo": expected "{", was ""', err.message)
386
+ end
387
+
388
+ def test_error_doesnt_truncate_was_when_elipsis_would_add_length
389
+ css2sass("foo }foo#{"a" * 14}")
390
+ assert(false, "Expected exception")
391
+ rescue Sass::SyntaxError => err
392
+ assert_equal(1, err.sass_line)
393
+ assert_equal('Invalid CSS after "foo ": expected "{", was "}fooaaaaaaaaaaaaaa"', err.message)
394
+ end
395
+
396
+ def test_error_gets_rid_of_trailing_newline_for_after
397
+ css2sass("foo \n ")
398
+ assert(false, "Expected exception")
399
+ rescue Sass::SyntaxError => err
400
+ assert_equal(2, err.sass_line)
401
+ assert_equal('Invalid CSS after "foo": expected "{", was ""', err.message)
402
+ end
403
+
404
+ def test_error_gets_rid_of_trailing_newline_for_was
405
+ css2sass("foo \n }foo")
406
+ assert(false, "Expected exception")
407
+ rescue Sass::SyntaxError => err
408
+ assert_equal(2, err.sass_line)
409
+ assert_equal('Invalid CSS after "foo": expected "{", was "}foo"', err.message)
410
+ end
411
+
412
+ # Encodings
413
+
414
+ unless Sass::Util.ruby1_8?
415
+ def test_encoding_error
416
+ css2sass("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
417
+ assert(false, "Expected exception")
418
+ rescue Sass::SyntaxError => e
419
+ assert_equal(3, e.sass_line)
420
+ assert_equal('Invalid UTF-8 character "\xFE"', e.message)
421
+ end
422
+
423
+ def test_ascii_incompatible_encoding_error
424
+ template = "foo\nbar\nb_z".encode("utf-16le")
425
+ template[9] = "\xFE".force_encoding("utf-16le")
426
+ css2sass(template)
427
+ assert(false, "Expected exception")
428
+ rescue Sass::SyntaxError => e
429
+ assert_equal(3, e.sass_line)
430
+ assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
431
+ end
432
+ end
433
+
434
+ private
435
+
436
+ def css2sass(string, opts={})
437
+ Sass::CSS.new(string, opts).render
438
+ end
439
+ end
@@ -0,0 +1,319 @@
1
+ hsl(0, 100%, 50%)
2
+ hsl(60, 100%, 50%)
3
+ hsl(120, 100%, 50%)
4
+ hsl(180, 100%, 50%)
5
+ hsl(240, 100%, 50%)
6
+ hsl(300, 100%, 50%)
7
+ ====
8
+ rgb(255, 0, 0)
9
+ rgb(255, 255, 0)
10
+ rgb(0, 255, 0)
11
+ rgb(0, 255, 255)
12
+ rgb(0, 0, 255)
13
+ rgb(255, 0, 255)
14
+
15
+ hsl(-360, 100%, 50%)
16
+ hsl(-300, 100%, 50%)
17
+ hsl(-240, 100%, 50%)
18
+ hsl(-180, 100%, 50%)
19
+ hsl(-120, 100%, 50%)
20
+ hsl(-60, 100%, 50%)
21
+ ====
22
+ rgb(255, 0, 0)
23
+ rgb(255, 255, 0)
24
+ rgb(0, 255, 0)
25
+ rgb(0, 255, 255)
26
+ rgb(0, 0, 255)
27
+ rgb(255, 0, 255)
28
+
29
+ hsl(360, 100%, 50%)
30
+ hsl(420, 100%, 50%)
31
+ hsl(480, 100%, 50%)
32
+ hsl(540, 100%, 50%)
33
+ hsl(600, 100%, 50%)
34
+ hsl(660, 100%, 50%)
35
+ ====
36
+ rgb(255, 0, 0)
37
+ rgb(255, 255, 0)
38
+ rgb(0, 255, 0)
39
+ rgb(0, 255, 255)
40
+ rgb(0, 0, 255)
41
+ rgb(255, 0, 255)
42
+
43
+ hsl(6120, 100%, 50%)
44
+ hsl(-9660, 100%, 50%)
45
+ hsl(99840, 100%, 50%)
46
+ hsl(-900, 100%, 50%)
47
+ hsl(-104880, 100%, 50%)
48
+ hsl(2820, 100%, 50%)
49
+ ====
50
+ rgb(255, 0, 0)
51
+ rgb(255, 255, 0)
52
+ rgb(0, 255, 0)
53
+ rgb(0, 255, 255)
54
+ rgb(0, 0, 255)
55
+ rgb(255, 0, 255)
56
+
57
+ hsl(0, 100%, 50%)
58
+ hsl(12, 100%, 50%)
59
+ hsl(24, 100%, 50%)
60
+ hsl(36, 100%, 50%)
61
+ hsl(48, 100%, 50%)
62
+ hsl(60, 100%, 50%)
63
+ hsl(72, 100%, 50%)
64
+ hsl(84, 100%, 50%)
65
+ hsl(96, 100%, 50%)
66
+ hsl(108, 100%, 50%)
67
+ hsl(120, 100%, 50%)
68
+ ====
69
+ rgb(255, 0, 0)
70
+ rgb(255, 51, 0)
71
+ rgb(255, 102, 0)
72
+ rgb(255, 153, 0)
73
+ rgb(255, 204, 0)
74
+ rgb(255, 255, 0)
75
+ rgb(204, 255, 0)
76
+ rgb(153, 255, 0)
77
+ rgb(102, 255, 0)
78
+ rgb(51, 255, 0)
79
+ rgb(0, 255, 0)
80
+
81
+ hsl(120, 100%, 50%)
82
+ hsl(132, 100%, 50%)
83
+ hsl(144, 100%, 50%)
84
+ hsl(156, 100%, 50%)
85
+ hsl(168, 100%, 50%)
86
+ hsl(180, 100%, 50%)
87
+ hsl(192, 100%, 50%)
88
+ hsl(204, 100%, 50%)
89
+ hsl(216, 100%, 50%)
90
+ hsl(228, 100%, 50%)
91
+ hsl(240, 100%, 50%)
92
+ ====
93
+ rgb(0, 255, 0)
94
+ rgb(0, 255, 51)
95
+ rgb(0, 255, 102)
96
+ rgb(0, 255, 153)
97
+ rgb(0, 255, 204)
98
+ rgb(0, 255, 255)
99
+ rgb(0, 204, 255)
100
+ rgb(0, 153, 255)
101
+ rgb(0, 102, 255)
102
+ rgb(0, 51, 255)
103
+ rgb(0, 0, 255)
104
+
105
+ hsl(240, 100%, 50%)
106
+ hsl(252, 100%, 50%)
107
+ hsl(264, 100%, 50%)
108
+ hsl(276, 100%, 50%)
109
+ hsl(288, 100%, 50%)
110
+ hsl(300, 100%, 50%)
111
+ hsl(312, 100%, 50%)
112
+ hsl(324, 100%, 50%)
113
+ hsl(336, 100%, 50%)
114
+ hsl(348, 100%, 50%)
115
+ hsl(360, 100%, 50%)
116
+ ====
117
+ rgb(0, 0, 255)
118
+ rgb(51, 0, 255)
119
+ rgb(102, 0, 255)
120
+ rgb(153, 0, 255)
121
+ rgb(204, 0, 255)
122
+ rgb(255, 0, 255)
123
+ rgb(255, 0, 204)
124
+ rgb(255, 0, 153)
125
+ rgb(255, 0, 102)
126
+ rgb(255, 0, 51)
127
+ rgb(255, 0, 0)
128
+
129
+ hsl(0, 20%, 50%)
130
+ hsl(0, 60%, 50%)
131
+ hsl(0, 100%, 50%)
132
+ ====
133
+ rgb(153, 102, 102)
134
+ rgb(204, 51, 51)
135
+ rgb(255, 0, 0)
136
+
137
+ hsl(60, 20%, 50%)
138
+ hsl(60, 60%, 50%)
139
+ hsl(60, 100%, 50%)
140
+ ====
141
+ rgb(153, 153, 102)
142
+ rgb(204, 204, 51)
143
+ rgb(255, 255, 0)
144
+
145
+ hsl(120, 20%, 50%)
146
+ hsl(120, 60%, 50%)
147
+ hsl(120, 100%, 50%)
148
+ ====
149
+ rgb(102, 153, 102)
150
+ rgb(51, 204, 51)
151
+ rgb(0, 255, 0)
152
+
153
+ hsl(180, 20%, 50%)
154
+ hsl(180, 60%, 50%)
155
+ hsl(180, 100%, 50%)
156
+ ====
157
+ rgb(102, 153, 153)
158
+ rgb(51, 204, 204)
159
+ rgb(0, 255, 255)
160
+
161
+ hsl(240, 20%, 50%)
162
+ hsl(240, 60%, 50%)
163
+ hsl(240, 100%, 50%)
164
+ ====
165
+ rgb(102, 102, 153)
166
+ rgb(51, 51, 204)
167
+ rgb(0, 0, 255)
168
+
169
+ hsl(300, 20%, 50%)
170
+ hsl(300, 60%, 50%)
171
+ hsl(300, 100%, 50%)
172
+ ====
173
+ rgb(153, 102, 153)
174
+ rgb(204, 51, 204)
175
+ rgb(255, 0, 255)
176
+
177
+ hsl(0, 100%, 0%)
178
+ hsl(0, 100%, 10%)
179
+ hsl(0, 100%, 20%)
180
+ hsl(0, 100%, 30%)
181
+ hsl(0, 100%, 40%)
182
+ hsl(0, 100%, 50%)
183
+ hsl(0, 100%, 60%)
184
+ hsl(0, 100%, 70%)
185
+ hsl(0, 100%, 80%)
186
+ hsl(0, 100%, 90%)
187
+ hsl(0, 100%, 100%)
188
+ ====
189
+ rgb(0, 0, 0)
190
+ rgb(51, 0, 0)
191
+ rgb(102, 0, 0)
192
+ rgb(153, 0, 0)
193
+ rgb(204, 0, 0)
194
+ rgb(255, 0, 0)
195
+ rgb(255, 51, 51)
196
+ rgb(255, 102, 102)
197
+ rgb(255, 153, 153)
198
+ rgb(255, 204, 204)
199
+ rgb(255, 255, 255)
200
+
201
+ hsl(60, 100%, 0%)
202
+ hsl(60, 100%, 10%)
203
+ hsl(60, 100%, 20%)
204
+ hsl(60, 100%, 30%)
205
+ hsl(60, 100%, 40%)
206
+ hsl(60, 100%, 50%)
207
+ hsl(60, 100%, 60%)
208
+ hsl(60, 100%, 70%)
209
+ hsl(60, 100%, 80%)
210
+ hsl(60, 100%, 90%)
211
+ hsl(60, 100%, 100%)
212
+ ====
213
+ rgb(0, 0, 0)
214
+ rgb(51, 51, 0)
215
+ rgb(102, 102, 0)
216
+ rgb(153, 153, 0)
217
+ rgb(204, 204, 0)
218
+ rgb(255, 255, 0)
219
+ rgb(255, 255, 51)
220
+ rgb(255, 255, 102)
221
+ rgb(255, 255, 153)
222
+ rgb(255, 255, 204)
223
+ rgb(255, 255, 255)
224
+
225
+ hsl(120, 100%, 0%)
226
+ hsl(120, 100%, 10%)
227
+ hsl(120, 100%, 20%)
228
+ hsl(120, 100%, 30%)
229
+ hsl(120, 100%, 40%)
230
+ hsl(120, 100%, 50%)
231
+ hsl(120, 100%, 60%)
232
+ hsl(120, 100%, 70%)
233
+ hsl(120, 100%, 80%)
234
+ hsl(120, 100%, 90%)
235
+ hsl(120, 100%, 100%)
236
+ ====
237
+ rgb(0, 0, 0)
238
+ rgb(0, 51, 0)
239
+ rgb(0, 102, 0)
240
+ rgb(0, 153, 0)
241
+ rgb(0, 204, 0)
242
+ rgb(0, 255, 0)
243
+ rgb(51, 255, 51)
244
+ rgb(102, 255, 102)
245
+ rgb(153, 255, 153)
246
+ rgb(204, 255, 204)
247
+ rgb(255, 255, 255)
248
+
249
+ hsl(180, 100%, 0%)
250
+ hsl(180, 100%, 10%)
251
+ hsl(180, 100%, 20%)
252
+ hsl(180, 100%, 30%)
253
+ hsl(180, 100%, 40%)
254
+ hsl(180, 100%, 50%)
255
+ hsl(180, 100%, 60%)
256
+ hsl(180, 100%, 70%)
257
+ hsl(180, 100%, 80%)
258
+ hsl(180, 100%, 90%)
259
+ hsl(180, 100%, 100%)
260
+ ====
261
+ rgb(0, 0, 0)
262
+ rgb(0, 51, 51)
263
+ rgb(0, 102, 102)
264
+ rgb(0, 153, 153)
265
+ rgb(0, 204, 204)
266
+ rgb(0, 255, 255)
267
+ rgb(51, 255, 255)
268
+ rgb(102, 255, 255)
269
+ rgb(153, 255, 255)
270
+ rgb(204, 255, 255)
271
+ rgb(255, 255, 255)
272
+
273
+ hsl(240, 100%, 0%)
274
+ hsl(240, 100%, 10%)
275
+ hsl(240, 100%, 20%)
276
+ hsl(240, 100%, 30%)
277
+ hsl(240, 100%, 40%)
278
+ hsl(240, 100%, 50%)
279
+ hsl(240, 100%, 60%)
280
+ hsl(240, 100%, 70%)
281
+ hsl(240, 100%, 80%)
282
+ hsl(240, 100%, 90%)
283
+ hsl(240, 100%, 100%)
284
+ ====
285
+ rgb(0, 0, 0)
286
+ rgb(0, 0, 51)
287
+ rgb(0, 0, 102)
288
+ rgb(0, 0, 153)
289
+ rgb(0, 0, 204)
290
+ rgb(0, 0, 255)
291
+ rgb(51, 51, 255)
292
+ rgb(102, 102, 255)
293
+ rgb(153, 153, 255)
294
+ rgb(204, 204, 255)
295
+ rgb(255, 255, 255)
296
+
297
+ hsl(300, 100%, 0%)
298
+ hsl(300, 100%, 10%)
299
+ hsl(300, 100%, 20%)
300
+ hsl(300, 100%, 30%)
301
+ hsl(300, 100%, 40%)
302
+ hsl(300, 100%, 50%)
303
+ hsl(300, 100%, 60%)
304
+ hsl(300, 100%, 70%)
305
+ hsl(300, 100%, 80%)
306
+ hsl(300, 100%, 90%)
307
+ hsl(300, 100%, 100%)
308
+ ====
309
+ rgb(0, 0, 0)
310
+ rgb(51, 0, 51)
311
+ rgb(102, 0, 102)
312
+ rgb(153, 0, 153)
313
+ rgb(204, 0, 204)
314
+ rgb(255, 0, 255)
315
+ rgb(255, 51, 255)
316
+ rgb(255, 102, 255)
317
+ rgb(255, 153, 255)
318
+ rgb(255, 204, 255)
319
+ rgb(255, 255, 255)