sass 3.3.0 → 3.4.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -1
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/CONTRIBUTING.md +148 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +76 -62
  7. data/Rakefile +104 -24
  8. data/VERSION +1 -1
  9. data/VERSION_DATE +1 -1
  10. data/VERSION_NAME +1 -1
  11. data/bin/sass +1 -1
  12. data/bin/scss +1 -1
  13. data/extra/sass-spec-ref.sh +32 -0
  14. data/extra/update_watch.rb +1 -1
  15. data/lib/sass/cache_stores/filesystem.rb +9 -5
  16. data/lib/sass/cache_stores/memory.rb +4 -5
  17. data/lib/sass/callbacks.rb +2 -2
  18. data/lib/sass/css.rb +12 -13
  19. data/lib/sass/deprecation.rb +55 -0
  20. data/lib/sass/engine.rb +106 -70
  21. data/lib/sass/environment.rb +39 -19
  22. data/lib/sass/error.rb +17 -20
  23. data/lib/sass/exec/base.rb +199 -0
  24. data/lib/sass/exec/sass_convert.rb +283 -0
  25. data/lib/sass/exec/sass_scss.rb +440 -0
  26. data/lib/sass/exec.rb +5 -771
  27. data/lib/sass/features.rb +9 -2
  28. data/lib/sass/importers/base.rb +8 -3
  29. data/lib/sass/importers/filesystem.rb +30 -38
  30. data/lib/sass/logger/base.rb +8 -2
  31. data/lib/sass/logger/delayed.rb +50 -0
  32. data/lib/sass/logger.rb +8 -3
  33. data/lib/sass/media.rb +1 -4
  34. data/lib/sass/plugin/compiler.rb +224 -90
  35. data/lib/sass/plugin/configuration.rb +38 -22
  36. data/lib/sass/plugin/merb.rb +2 -2
  37. data/lib/sass/plugin/rack.rb +3 -3
  38. data/lib/sass/plugin/rails.rb +1 -1
  39. data/lib/sass/plugin/staleness_checker.rb +4 -4
  40. data/lib/sass/plugin.rb +6 -5
  41. data/lib/sass/script/css_lexer.rb +1 -1
  42. data/lib/sass/script/css_parser.rb +2 -3
  43. data/lib/sass/script/css_variable_warning.rb +52 -0
  44. data/lib/sass/script/functions.rb +739 -318
  45. data/lib/sass/script/lexer.rb +134 -54
  46. data/lib/sass/script/parser.rb +252 -56
  47. data/lib/sass/script/tree/funcall.rb +13 -6
  48. data/lib/sass/script/tree/interpolation.rb +127 -4
  49. data/lib/sass/script/tree/list_literal.rb +31 -4
  50. data/lib/sass/script/tree/literal.rb +4 -0
  51. data/lib/sass/script/tree/node.rb +21 -3
  52. data/lib/sass/script/tree/operation.rb +54 -1
  53. data/lib/sass/script/tree/selector.rb +26 -0
  54. data/lib/sass/script/tree/string_interpolation.rb +59 -38
  55. data/lib/sass/script/tree/variable.rb +1 -1
  56. data/lib/sass/script/tree.rb +1 -0
  57. data/lib/sass/script/value/base.rb +17 -14
  58. data/lib/sass/script/value/bool.rb +0 -5
  59. data/lib/sass/script/value/color.rb +78 -42
  60. data/lib/sass/script/value/helpers.rb +119 -2
  61. data/lib/sass/script/value/list.rb +0 -15
  62. data/lib/sass/script/value/map.rb +1 -1
  63. data/lib/sass/script/value/null.rb +0 -5
  64. data/lib/sass/script/value/number.rb +112 -31
  65. data/lib/sass/script/value/string.rb +102 -13
  66. data/lib/sass/script/value.rb +0 -1
  67. data/lib/sass/script.rb +3 -3
  68. data/lib/sass/scss/css_parser.rb +24 -4
  69. data/lib/sass/scss/parser.rb +290 -383
  70. data/lib/sass/scss/rx.rb +17 -9
  71. data/lib/sass/scss/static_parser.rb +306 -4
  72. data/lib/sass/scss.rb +0 -2
  73. data/lib/sass/selector/abstract_sequence.rb +35 -18
  74. data/lib/sass/selector/comma_sequence.rb +114 -19
  75. data/lib/sass/selector/pseudo.rb +266 -0
  76. data/lib/sass/selector/sequence.rb +146 -40
  77. data/lib/sass/selector/simple.rb +22 -33
  78. data/lib/sass/selector/simple_sequence.rb +122 -39
  79. data/lib/sass/selector.rb +57 -197
  80. data/lib/sass/shared.rb +2 -2
  81. data/lib/sass/source/map.rb +31 -14
  82. data/lib/sass/source/position.rb +4 -4
  83. data/lib/sass/stack.rb +2 -8
  84. data/lib/sass/supports.rb +10 -13
  85. data/lib/sass/tree/at_root_node.rb +1 -0
  86. data/lib/sass/tree/charset_node.rb +1 -1
  87. data/lib/sass/tree/comment_node.rb +1 -1
  88. data/lib/sass/tree/css_import_node.rb +9 -1
  89. data/lib/sass/tree/directive_node.rb +8 -2
  90. data/lib/sass/tree/error_node.rb +18 -0
  91. data/lib/sass/tree/extend_node.rb +1 -1
  92. data/lib/sass/tree/function_node.rb +9 -0
  93. data/lib/sass/tree/import_node.rb +6 -5
  94. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  95. data/lib/sass/tree/node.rb +5 -3
  96. data/lib/sass/tree/prop_node.rb +6 -7
  97. data/lib/sass/tree/rule_node.rb +26 -11
  98. data/lib/sass/tree/visitors/check_nesting.rb +56 -32
  99. data/lib/sass/tree/visitors/convert.rb +59 -44
  100. data/lib/sass/tree/visitors/cssize.rb +34 -30
  101. data/lib/sass/tree/visitors/deep_copy.rb +6 -1
  102. data/lib/sass/tree/visitors/extend.rb +15 -13
  103. data/lib/sass/tree/visitors/perform.rb +87 -50
  104. data/lib/sass/tree/visitors/set_options.rb +15 -1
  105. data/lib/sass/tree/visitors/to_css.rb +72 -43
  106. data/lib/sass/util/multibyte_string_scanner.rb +0 -2
  107. data/lib/sass/util/normalized_map.rb +0 -1
  108. data/lib/sass/util/subset_map.rb +2 -3
  109. data/lib/sass/util.rb +334 -154
  110. data/lib/sass/version.rb +7 -7
  111. data/lib/sass.rb +10 -8
  112. data/test/sass/cache_test.rb +62 -20
  113. data/test/sass/callbacks_test.rb +1 -1
  114. data/test/sass/compiler_test.rb +24 -11
  115. data/test/sass/conversion_test.rb +241 -50
  116. data/test/sass/css2sass_test.rb +73 -5
  117. data/test/sass/css_variable_test.rb +132 -0
  118. data/test/sass/encoding_test.rb +219 -0
  119. data/test/sass/engine_test.rb +343 -260
  120. data/test/sass/exec_test.rb +12 -2
  121. data/test/sass/extend_test.rb +333 -44
  122. data/test/sass/functions_test.rb +353 -260
  123. data/test/sass/importer_test.rb +40 -21
  124. data/test/sass/logger_test.rb +1 -1
  125. data/test/sass/more_results/more_import.css +1 -1
  126. data/test/sass/more_templates/more1.sass +10 -10
  127. data/test/sass/more_templates/more_import.sass +2 -2
  128. data/test/sass/plugin_test.rb +24 -21
  129. data/test/sass/results/compact.css +1 -1
  130. data/test/sass/results/complex.css +4 -4
  131. data/test/sass/results/expanded.css +1 -1
  132. data/test/sass/results/import.css +1 -1
  133. data/test/sass/results/import_charset_ibm866.css +2 -2
  134. data/test/sass/results/mixins.css +17 -17
  135. data/test/sass/results/nested.css +1 -1
  136. data/test/sass/results/parent_ref.css +2 -2
  137. data/test/sass/results/script.css +5 -5
  138. data/test/sass/results/scss_import.css +1 -1
  139. data/test/sass/script_conversion_test.rb +71 -39
  140. data/test/sass/script_test.rb +714 -123
  141. data/test/sass/scss/css_test.rb +213 -30
  142. data/test/sass/scss/rx_test.rb +8 -4
  143. data/test/sass/scss/scss_test.rb +766 -22
  144. data/test/sass/source_map_test.rb +263 -95
  145. data/test/sass/superselector_test.rb +210 -0
  146. data/test/sass/templates/_partial.sass +1 -1
  147. data/test/sass/templates/basic.sass +10 -10
  148. data/test/sass/templates/bork1.sass +1 -1
  149. data/test/sass/templates/bork5.sass +1 -1
  150. data/test/sass/templates/compact.sass +10 -10
  151. data/test/sass/templates/complex.sass +187 -187
  152. data/test/sass/templates/compressed.sass +10 -10
  153. data/test/sass/templates/expanded.sass +10 -10
  154. data/test/sass/templates/import.sass +2 -2
  155. data/test/sass/templates/importee.sass +3 -3
  156. data/test/sass/templates/mixins.sass +22 -22
  157. data/test/sass/templates/multiline.sass +4 -4
  158. data/test/sass/templates/nested.sass +13 -13
  159. data/test/sass/templates/parent_ref.sass +12 -12
  160. data/test/sass/templates/script.sass +70 -70
  161. data/test/sass/templates/scss_import.scss +2 -1
  162. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  163. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  164. data/test/sass/templates/subdir/subdir.sass +3 -3
  165. data/test/sass/templates/units.sass +10 -10
  166. data/test/sass/test_helper.rb +1 -1
  167. data/test/sass/util/multibyte_string_scanner_test.rb +11 -3
  168. data/test/sass/util/normalized_map_test.rb +1 -1
  169. data/test/sass/util/subset_map_test.rb +2 -2
  170. data/test/sass/util_test.rb +46 -45
  171. data/test/sass/value_helpers_test.rb +5 -7
  172. data/test/sass-spec.yml +3 -0
  173. data/test/test_helper.rb +7 -6
  174. data/vendor/listen/CHANGELOG.md +1 -228
  175. data/vendor/listen/Gemfile +5 -15
  176. data/vendor/listen/README.md +111 -77
  177. data/vendor/listen/Rakefile +0 -42
  178. data/vendor/listen/lib/listen/adapter.rb +195 -82
  179. data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
  180. data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
  181. data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
  182. data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
  183. data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
  184. data/vendor/listen/lib/listen/directory_record.rb +96 -61
  185. data/vendor/listen/lib/listen/listener.rb +135 -37
  186. data/vendor/listen/lib/listen/turnstile.rb +9 -5
  187. data/vendor/listen/lib/listen/version.rb +1 -1
  188. data/vendor/listen/lib/listen.rb +33 -19
  189. data/vendor/listen/listen.gemspec +6 -0
  190. data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
  191. data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
  192. data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
  193. data/vendor/listen/spec/listen/listener_spec.rb +128 -39
  194. data/vendor/listen/spec/listen_spec.rb +15 -21
  195. data/vendor/listen/spec/spec_helper.rb +4 -0
  196. data/vendor/listen/spec/support/adapter_helper.rb +52 -15
  197. data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
  198. data/vendor/listen/spec/support/listeners_helper.rb +30 -7
  199. metadata +310 -300
  200. data/CONTRIBUTING +0 -3
  201. data/ext/mkrf_conf.rb +0 -27
  202. data/lib/sass/script/value/deprecated_false.rb +0 -55
  203. data/lib/sass/scss/script_lexer.rb +0 -15
  204. data/lib/sass/scss/script_parser.rb +0 -25
  205. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  206. data/vendor/listen/lib/listen/multi_listener.rb +0 -143
  207. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
  208. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
@@ -3,12 +3,12 @@
3
3
  require File.dirname(__FILE__) + '/../test_helper'
4
4
  require File.dirname(__FILE__) + '/test_helper'
5
5
 
6
- class SourcemapTest < Test::Unit::TestCase
6
+ class SourcemapTest < MiniTest::Test
7
7
  def test_to_json_requires_args
8
8
  _, sourcemap = render_with_sourcemap('')
9
- assert_raise(ArgumentError) {sourcemap.to_json({})}
10
- assert_raise(ArgumentError) {sourcemap.to_json({:css_path => 'foo'})}
11
- assert_raise(ArgumentError) {sourcemap.to_json({:sourcemap_path => 'foo'})}
9
+ assert_raises(ArgumentError) {sourcemap.to_json({})}
10
+ assert_raises(ArgumentError) {sourcemap.to_json({:css_path => 'foo'})}
11
+ assert_raises(ArgumentError) {sourcemap.to_json({:sourcemap_path => 'foo'})}
12
12
  end
13
13
 
14
14
  def test_simple_mapping_scss
@@ -28,7 +28,7 @@ a {
28
28
  CSS
29
29
  {
30
30
  "version": 3,
31
- "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;;EAER,SAAS,EAAE,IAAI",
31
+ "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;EACV,kBAAkB;EAChB,SAAS,EAAE,IAAI",
32
32
  "sources": ["test_simple_mapping_scss_inline.scss"],
33
33
  "names": [],
34
34
  "file": "test.css"
@@ -37,7 +37,7 @@ JSON
37
37
  end
38
38
 
39
39
  def test_simple_mapping_sass
40
- assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, :syntax => :sass
40
+ silence_warnings {assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, :syntax => :sass}
41
41
  a
42
42
  foo: bar
43
43
  /* SOME COMMENT */
@@ -60,6 +60,32 @@ CSS
60
60
  JSON
61
61
  end
62
62
 
63
+ def test_simple_mapping_with_file_uris
64
+ uri = Sass::Util.file_uri_from_path(Sass::Util.absolute_path(filename_for_test(:scss)))
65
+ assert_parses_with_sourcemap <<SCSS, <<CSS, <<JSON, :sourcemap => :file
66
+ a {
67
+ foo: bar;
68
+ /* SOME COMMENT */
69
+ font-size: 12px;
70
+ }
71
+ SCSS
72
+ a {
73
+ foo: bar;
74
+ /* SOME COMMENT */
75
+ font-size: 12px; }
76
+
77
+ /*# sourceMappingURL=test.css.map */
78
+ CSS
79
+ {
80
+ "version": 3,
81
+ "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;EACV,kBAAkB;EAChB,SAAS,EAAE,IAAI",
82
+ "sources": ["#{uri}"],
83
+ "names": [],
84
+ "file": "test.css"
85
+ }
86
+ JSON
87
+ end
88
+
63
89
  def test_mapping_with_directory_scss
64
90
  options = {:filename => "scss/style.scss", :output => "css/style.css"}
65
91
  assert_parses_with_sourcemap <<SCSS, <<CSS, <<JSON, options
@@ -78,7 +104,7 @@ a {
78
104
  CSS
79
105
  {
80
106
  "version": 3,
81
- "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;;EAER,SAAS,EAAE,IAAI",
107
+ "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;EACV,kBAAkB;EAChB,SAAS,EAAE,IAAI",
82
108
  "sources": ["../scss/style.scss"],
83
109
  "names": [],
84
110
  "file": "style.css"
@@ -88,7 +114,7 @@ JSON
88
114
 
89
115
  def test_mapping_with_directory_sass
90
116
  options = {:filename => "sass/style.sass", :output => "css/style.css", :syntax => :sass}
91
- assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, options
117
+ silence_warnings {assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, options}
92
118
  a
93
119
  foo: bar
94
120
  /* SOME COMMENT */
@@ -156,15 +182,15 @@ JSON
156
182
  end
157
183
 
158
184
  def test_different_charset_than_encoding_scss
159
- assert_parses_with_sourcemap(<<SCSS.force_encoding("IBM866"), <<CSS.force_encoding("IBM866"), <<JSON)
185
+ assert_parses_with_sourcemap(<<SCSS.force_encoding("IBM866"), <<CSS, <<JSON)
160
186
  @charset "IBM866";
161
187
  f\x86\x86 {
162
188
  \x86: b;
163
189
  }
164
190
  SCSS
165
- @charset "IBM866";
166
- f\x86\x86 {
167
- \x86: b; }
191
+ @charset "UTF-8";
192
+ fЖЖ {
193
+ Ж: b; }
168
194
 
169
195
  /*# sourceMappingURL=test.css.map */
170
196
  CSS
@@ -179,14 +205,14 @@ JSON
179
205
  end
180
206
 
181
207
  def test_different_charset_than_encoding_sass
182
- assert_parses_with_sourcemap(<<SASS.force_encoding("IBM866"), <<CSS.force_encoding("IBM866"), <<JSON, :syntax => :sass)
208
+ assert_parses_with_sourcemap(<<SASS.force_encoding("IBM866"), <<CSS, <<JSON, :syntax => :sass)
183
209
  @charset "IBM866"
184
210
  f\x86\x86
185
211
  \x86: b
186
212
  SASS
187
- @charset "IBM866";
188
- f\x86\x86 {
189
- \x86: b; }
213
+ @charset "UTF-8";
214
+ fЖЖ {
215
+ Ж: b; }
190
216
 
191
217
  /*# sourceMappingURL=test.css.map */
192
218
  CSS
@@ -324,44 +350,42 @@ CSS
324
350
  $width: 2px;
325
351
  $translucent-red: rgba(255, 0, 0, 0.5);
326
352
  {{1}}a {{/1}}{
327
- {{8}}.special {{/8}}{
328
- {{9}}color{{/9}}: {{10}}red{{/10}};
329
- {{11}}&:hover {{/11}}{
330
- {{12}}foo{{/12}}: {{13}}bar{{/13}};
331
- {{14}}cursor{{/14}}: {{15}}e + -resize{{/15}};
332
- {{16}}color{{/16}}: {{17}}opacify($translucent-red, 0.3){{/17}};
353
+ {{9}}.special {{/9}}{
354
+ {{10}}color{{/10}}: {{11}}red{{/11}};
355
+ {{12}}&:hover {{/12}}{
356
+ {{13}}foo{{/13}}: {{14}}bar{{/14}};
357
+ {{15}}cursor{{/15}}: {{16}}e + -resize{{/16}};
358
+ {{17}}color{{/17}}: {{18}}opacify($translucent-red, 0.3){{/18}};
333
359
  }
334
- {{18}}&:after {{/18}}{
335
- {{19}}content{{/19}}: {{20}}"I ate #{5 + 10} pies #{$width} thick!"{{/20}};
360
+ {{19}}&:after {{/19}}{
361
+ {{20}}content{{/20}}: {{21}}"I ate #{5 + 10} pies #{$width} thick!"{{/21}};
336
362
  }
337
363
  }
338
- {{21}}&:active {{/21}}{
339
- {{22}}color{{/22}}: {{23}}#010203 + #040506{{/23}};
340
- {{24}}border{{/24}}: {{25}}$width solid black{{/25}};
364
+ {{22}}&:active {{/22}}{
365
+ {{23}}border{{/23}}: {{24}}$width solid black{{/24}};
341
366
  }
342
- /* SOME COMMENT */
343
- {{2}}font{{/2}}: {{3}}2px/3px {{/3}}{
344
- {{4}}family{{/4}}: {{5}}fantasy{{/5}};
345
- {{6}}size{{/6}}: {{7}}1em + (2em * 3){{/7}};
367
+ {{2}}/* SOME COMMENT */{{/2}}
368
+ {{3}}font{{/3}}: {{4}}2px/3px {{/4}}{
369
+ {{5}}family{{/5}}: {{6}}fantasy{{/6}};
370
+ {{7}}size{{/7}}: {{8}}1em + (2em * 3){{/8}};
346
371
  }
347
372
  }
348
373
  SCSS
349
374
  {{1}}a{{/1}} {
350
- /* SOME COMMENT */
351
- {{2}}font{{/2}}: {{3}}2px/3px{{/3}};
352
- {{4}}font-family{{/4}}: {{5}}fantasy{{/5}};
353
- {{6}}font-size{{/6}}: {{7}}7em{{/7}}; }
354
- {{8}}a .special{{/8}} {
355
- {{9}}color{{/9}}: {{10}}red{{/10}}; }
356
- {{11}}a .special:hover{{/11}} {
357
- {{12}}foo{{/12}}: {{13}}bar{{/13}};
358
- {{14}}cursor{{/14}}: {{15}}e-resize{{/15}};
359
- {{16}}color{{/16}}: {{17}}rgba(255, 0, 0, 0.8){{/17}}; }
360
- {{18}}a .special:after{{/18}} {
361
- {{19}}content{{/19}}: {{20}}"I ate 15 pies 2px thick!"{{/20}}; }
362
- {{21}}a:active{{/21}} {
363
- {{22}}color{{/22}}: {{23}}#050709{{/23}};
364
- {{24}}border{{/24}}: {{25}}2px solid black{{/25}}; }
375
+ {{2}}/* SOME COMMENT */{{/2}}
376
+ {{3}}font{{/3}}: {{4}}2px/3px{{/4}};
377
+ {{5}}font-family{{/5}}: {{6}}fantasy{{/6}};
378
+ {{7}}font-size{{/7}}: {{8}}7em{{/8}}; }
379
+ {{9}}a .special{{/9}} {
380
+ {{10}}color{{/10}}: {{11}}red{{/11}}; }
381
+ {{12}}a .special:hover{{/12}} {
382
+ {{13}}foo{{/13}}: {{14}}bar{{/14}};
383
+ {{15}}cursor{{/15}}: {{16}}e-resize{{/16}};
384
+ {{17}}color{{/17}}: {{18}}rgba(255, 0, 0, 0.8){{/18}}; }
385
+ {{19}}a .special:after{{/19}} {
386
+ {{20}}content{{/20}}: {{21}}"I ate 15 pies 2px thick!"{{/21}}; }
387
+ {{22}}a:active{{/22}} {
388
+ {{23}}border{{/23}}: {{24}}2px solid black{{/24}}; }
365
389
 
366
390
  /*# sourceMappingURL=test.css.map */
367
391
  CSS
@@ -372,39 +396,37 @@ CSS
372
396
  $width: 2px
373
397
  $translucent-red: rgba(255, 0, 0, 0.5)
374
398
  {{1}}a{{/1}}
375
- {{8}}.special{{/8}}
376
- {{9}}color{{/9}}: {{10}}red{{/10}}
377
- {{11}}&:hover{{/11}}
378
- {{12}}foo{{/12}}: {{13}}bar{{/13}}
379
- {{14}}cursor{{/14}}: {{15}}e + -resize{{/15}}
380
- {{16}}color{{/16}}: {{17}}opacify($translucent-red, 0.3){{/17}}
381
- {{18}}&:after{{/18}}
382
- {{19}}content{{/19}}: {{20}}"I ate #{5 + 10} pies #{$width} thick!"{{/20}}
383
- {{21}}&:active{{/21}}
384
- {{22}}color{{/22}}: {{23}}#010203 + #040506{{/23}}
385
- {{24}}border{{/24}}: {{25}}$width solid black{{/25}}
386
-
387
- /* SOME COMMENT */
388
- {{2}}font{{/2}}: {{3}}2px/3px{{/3}}
389
- {{4}}family{{/4}}: {{5}}fantasy{{/5}}
390
- {{6}}size{{/6}}: {{7}}1em + (2em * 3){{/7}}
399
+ {{9}}.special{{/9}}
400
+ {{10}}color{{/10}}: {{11}}red{{/11}}
401
+ {{12}}&:hover{{/12}}
402
+ {{13}}foo{{/13}}: {{14}}bar{{/14}}
403
+ {{15}}cursor{{/15}}: {{16}}e + -resize{{/16}}
404
+ {{17}}color{{/17}}: {{18}}opacify($translucent-red, 0.3){{/18}}
405
+ {{19}}&:after{{/19}}
406
+ {{20}}content{{/20}}: {{21}}"I ate #{5 + 10} pies #{$width} thick!"{{/21}}
407
+ {{22}}&:active{{/22}}
408
+ {{23}}border{{/23}}: {{24}}$width solid black{{/24}}
409
+
410
+ {{2}}/* SOME COMMENT */{{/2}}
411
+ {{3}}font{{/3}}: {{4}}2px/3px{{/4}}
412
+ {{5}}family{{/5}}: {{6}}fantasy{{/6}}
413
+ {{7}}size{{/7}}: {{8}}1em + (2em * 3){{/8}}
391
414
  SASS
392
415
  {{1}}a{{/1}} {
393
- /* SOME COMMENT */
394
- {{2}}font{{/2}}: {{3}}2px/3px{{/3}};
395
- {{4}}font-family{{/4}}: {{5}}fantasy{{/5}};
396
- {{6}}font-size{{/6}}: {{7}}7em{{/7}}; }
397
- {{8}}a .special{{/8}} {
398
- {{9}}color{{/9}}: {{10}}red{{/10}}; }
399
- {{11}}a .special:hover{{/11}} {
400
- {{12}}foo{{/12}}: {{13}}bar{{/13}};
401
- {{14}}cursor{{/14}}: {{15}}e-resize{{/15}};
402
- {{16}}color{{/16}}: {{17}}rgba(255, 0, 0, 0.8){{/17}}; }
403
- {{18}}a .special:after{{/18}} {
404
- {{19}}content{{/19}}: {{20}}"I ate 15 pies 2px thick!"{{/20}}; }
405
- {{21}}a:active{{/21}} {
406
- {{22}}color{{/22}}: {{23}}#050709{{/23}};
407
- {{24}}border{{/24}}: {{25}}2px solid black{{/25}}; }
416
+ {{2}}/* SOME COMMENT */{{/2}}
417
+ {{3}}font{{/3}}: {{4}}2px/3px{{/4}};
418
+ {{5}}font-family{{/5}}: {{6}}fantasy{{/6}};
419
+ {{7}}font-size{{/7}}: {{8}}7em{{/8}}; }
420
+ {{9}}a .special{{/9}} {
421
+ {{10}}color{{/10}}: {{11}}red{{/11}}; }
422
+ {{12}}a .special:hover{{/12}} {
423
+ {{13}}foo{{/13}}: {{14}}bar{{/14}};
424
+ {{15}}cursor{{/15}}: {{16}}e-resize{{/16}};
425
+ {{17}}color{{/17}}: {{18}}rgba(255, 0, 0, 0.8){{/18}}; }
426
+ {{19}}a .special:after{{/19}} {
427
+ {{20}}content{{/20}}: {{21}}"I ate 15 pies 2px thick!"{{/21}}; }
428
+ {{22}}a:active{{/22}} {
429
+ {{23}}border{{/23}}: {{24}}2px solid black{{/24}}; }
408
430
 
409
431
  /*# sourceMappingURL=test.css.map */
410
432
  CSS
@@ -443,8 +465,8 @@ CSS
443
465
  {{7}}border-width{{/7}}: {{8}}3px{{/8}}
444
466
  SASS
445
467
  {{1}}.error, .seriousError{{/1}} {
446
- {{2}}border{{/2}}: {{3}}1px red{{/3}};
447
- {{4}}background-color{{/4}}: {{5}}#ffdddd{{/5}}; }
468
+ {{2}}border{{/2}}: {{3}}1px #f00{{/3}};
469
+ {{4}}background-color{{/4}}: {{5}}#fdd{{/5}}; }
448
470
 
449
471
  {{6}}.seriousError{{/6}} {
450
472
  {{7}}border-width{{/7}}: {{8}}3px{{/8}}; }
@@ -632,16 +654,16 @@ SCSS
632
654
  {{22}}border-style{{/22}}: {{23}}dashed{{/23}}; }
633
655
 
634
656
  {{24}}.shadows{{/24}} {
635
- {{25}}-moz-box-shadow{{/25}}: {{26}}0px 4px 5px #666666, 2px 6px 10px #999999{{/26}};
636
- {{27}}-webkit-box-shadow{{/27}}: {{28}}0px 4px 5px #666666, 2px 6px 10px #999999{{/28}};
637
- {{29}}box-shadow{{/29}}: {{30}}0px 4px 5px #666666, 2px 6px 10px #999999{{/30}}; }
657
+ {{25}}-moz-box-shadow{{/25}}: {{26}}0px 4px 5px #666, 2px 6px 10px #999{{/26}};
658
+ {{27}}-webkit-box-shadow{{/27}}: {{28}}0px 4px 5px #666, 2px 6px 10px #999{{/28}};
659
+ {{29}}box-shadow{{/29}}: {{30}}0px 4px 5px #666, 2px 6px 10px #999{{/30}}; }
638
660
 
639
661
  /*# sourceMappingURL=test.css.map */
640
662
  CSS
641
663
  end
642
664
 
643
665
  def test_mixin_sourcemap_sass
644
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
666
+ silence_warnings {assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass}
645
667
  =large-text
646
668
  :font
647
669
  {{2}}size{{/2}}: {{3}}20px{{/3}}
@@ -675,7 +697,7 @@ SASS
675
697
  {{1}}.page-title{{/1}} {
676
698
  {{2}}font-size{{/2}}: {{3}}20px{{/3}};
677
699
  {{4}}font-weight{{/4}}: {{5}}bold{{/5}};
678
- {{6}}color{{/6}}: {{7}}red{{/7}};
700
+ {{6}}color{{/6}}: {{7}}#ff0000{{/7}};
679
701
  {{8}}padding{{/8}}: {{9}}4px{{/9}}; }
680
702
 
681
703
  {{10}}p{{/10}} {
@@ -689,9 +711,9 @@ SASS
689
711
  {{22}}border-style{{/22}}: {{23}}dashed{{/23}}; }
690
712
 
691
713
  {{24}}.shadows{{/24}} {
692
- {{25}}-moz-box-shadow{{/25}}: {{26}}0px 4px 5px #666666, 2px 6px 10px #999999{{/26}};
693
- {{27}}-webkit-box-shadow{{/27}}: {{28}}0px 4px 5px #666666, 2px 6px 10px #999999{{/28}};
694
- {{29}}box-shadow{{/29}}: {{30}}0px 4px 5px #666666, 2px 6px 10px #999999{{/30}}; }
714
+ {{25}}-moz-box-shadow{{/25}}: {{26}}0px 4px 5px #666, 2px 6px 10px #999{{/26}};
715
+ {{27}}-webkit-box-shadow{{/27}}: {{28}}0px 4px 5px #666, 2px 6px 10px #999{{/28}};
716
+ {{29}}box-shadow{{/29}}: {{30}}0px 4px 5px #666, 2px 6px 10px #999{{/30}}; }
695
717
 
696
718
  /*# sourceMappingURL=test.css.map */
697
719
  CSS
@@ -735,7 +757,7 @@ CSS
735
757
  # Regression tests
736
758
 
737
759
  def test_properties_sass
738
- assert_parses_with_mapping <<SASS, <<CSS, :syntax => :sass
760
+ silence_warnings {assert_parses_with_mapping <<SASS, <<CSS, :syntax => :sass}
739
761
  {{1}}.foo{{/1}}
740
762
  :{{2}}name{{/2}} {{3}}value{{/3}}
741
763
  {{4}}name{{/4}}: {{5}}value{{/5}}
@@ -748,6 +770,140 @@ SASS
748
770
  {{6}}name{{/6}}: {{7}}value{{/7}};
749
771
  {{8}}name{{/8}}: {{9}}value{{/9}}; }
750
772
 
773
+ /*# sourceMappingURL=test.css.map */
774
+ CSS
775
+ end
776
+
777
+ def test_multiline_script_scss
778
+ assert_parses_with_mapping <<SCSS, <<CSS, :syntax => :scss
779
+ $var: {{3}}foo +
780
+ bar{{/3}}; {{1}}x {{/1}}{ {{2}}y{{/2}}: $var }
781
+ SCSS
782
+ {{1}}x{{/1}} {
783
+ {{2}}y{{/2}}: {{3}}foobar{{/3}}; }
784
+
785
+ /*# sourceMappingURL=test.css.map */
786
+ CSS
787
+ end
788
+
789
+ def test_multiline_interpolation_source_range
790
+ engine = Sass::Engine.new(<<-SCSS, :cache => false, :syntax => :scss)
791
+ p {
792
+ filter: progid:DXImageTransform(
793
+ '\#{123}');
794
+ }
795
+ SCSS
796
+
797
+ interpolated = engine.to_tree.children.
798
+ first.children.
799
+ first.value.children[1]
800
+ assert_equal "123", interpolated.to_sass
801
+ range = interpolated.source_range
802
+ assert_equal 3, range.start_pos.line
803
+ assert_equal 14, range.start_pos.offset
804
+ assert_equal 3, range.end_pos.line
805
+ assert_equal 17, range.end_pos.offset
806
+ end
807
+
808
+ def test_list_source_range
809
+ engine = Sass::Engine.new(<<-SCSS, :cache => false, :syntax => :scss)
810
+ @each $a, $b in (1, 2), (2, 4), (3, 6) { }
811
+ SCSS
812
+ list = engine.to_tree.children.first.list
813
+ assert_equal 1, list.source_range.start_pos.line
814
+ assert_equal 1, list.source_range.end_pos.line
815
+ assert_equal 16, list.source_range.start_pos.offset
816
+ assert_equal 38, list.source_range.end_pos.offset
817
+ end
818
+
819
+ def test_sources_array_is_uri_escaped
820
+ map = Sass::Source::Map.new
821
+ importer = Sass::Importers::Filesystem.new('.')
822
+ map.add(
823
+ Sass::Source::Range.new(
824
+ Sass::Source::Position.new(0, 0),
825
+ Sass::Source::Position.new(0, 10),
826
+ 'source file.scss',
827
+ importer),
828
+ Sass::Source::Range.new(
829
+ Sass::Source::Position.new(0, 0),
830
+ Sass::Source::Position.new(0, 10),
831
+ nil, nil))
832
+
833
+ json = map.to_json(:css_path => 'output file.css', :sourcemap_path => 'output file.css.map')
834
+ assert_equal json, <<JSON.rstrip
835
+ {
836
+ "version": 3,
837
+ "mappings": "DADD,UAAU",
838
+ "sources": ["source%20file.scss"],
839
+ "names": [],
840
+ "file": "output%20file.css"
841
+ }
842
+ JSON
843
+ end
844
+
845
+ def test_scss_comment_source_range
846
+ assert_parses_with_mapping <<SCSS, <<CSS, :syntax => :scss
847
+ $var: val; {{1}}/* text */{{/1}}
848
+
849
+ {{2}}/* multiline
850
+ comment */{{/2}}
851
+ SCSS
852
+ {{1}}/* text */{{/1}}
853
+ {{2}}/* multiline
854
+ comment */{{/2}}
855
+
856
+ /*# sourceMappingURL=test.css.map */
857
+ CSS
858
+ end
859
+
860
+ def test_sass_comment_source_range
861
+ assert_parses_with_mapping <<SASS, <<CSS, :syntax => :sass
862
+ {{1}}body{{/1}}
863
+ {{2}}/* text */{{/2}}
864
+
865
+ {{3}}/* multiline
866
+ comment */{{/3}}
867
+ SASS
868
+ {{1}}body{{/1}} {
869
+ {{2}}/* text */{{/2}} }
870
+
871
+ {{3}}/* multiline
872
+ * comment */{{/3}}
873
+
874
+ /*# sourceMappingURL=test.css.map */
875
+ CSS
876
+ end
877
+
878
+ def test_scss_comment_interpolation_source_range
879
+ assert_parses_with_mapping <<SCSS, <<CSS, :syntax => :scss
880
+ $var: 2; {{1}}/* two \#{$var} and four \#{2 * $var} */{{/1}}
881
+
882
+ {{2}}/* multiline
883
+ comment \#{ 2 + 2 } and \#{ 2 +
884
+ 2 } */{{/2}}
885
+ SCSS
886
+ {{1}}/* two 2 and four 4 */{{/1}}
887
+ {{2}}/* multiline
888
+ comment 4 and 4 */{{/2}}
889
+
890
+ /*# sourceMappingURL=test.css.map */
891
+ CSS
892
+ end
893
+
894
+ def test_sass_comment_interpolation_source_range
895
+ assert_parses_with_mapping <<SASS, <<CSS, :syntax => :sass
896
+ $var: 2
897
+ {{1}}/* two \#{$var} and four \#{2 * $var} */{{/1}}
898
+
899
+ {{2}}/* multiline
900
+ comment \#{ 2 + 2 } and \#{ 2 +
901
+ 2 } */{{/2}}
902
+ SASS
903
+ {{1}}/* two 2 and four 4 */{{/1}}
904
+ {{2}}/* multiline
905
+ * comment 4 and 4 */{{/2}}
906
+
751
907
  /*# sourceMappingURL=test.css.map */
752
908
  CSS
753
909
  end
@@ -787,11 +943,12 @@ CSS
787
943
  source_ranges = build_ranges(source, source_file_name)
788
944
  target_ranges = build_ranges(css)
789
945
  map = Sass::Source::Map.new
790
- Sass::Util.flatten(source_ranges.map do |(name, sources)|
946
+ source_ranges.map do |(name, sources)|
791
947
  assert(sources.length == 1, "#{sources.length} source ranges encountered for annotation #{name}")
792
948
  assert(target_ranges[name], "No target ranges for annotation #{name}")
793
949
  target_ranges[name].map {|target_range| [sources.first, target_range]}
794
- end, 1).
950
+ end.
951
+ flatten(1).
795
952
  sort_by {|(_, target)| [target.start_pos.line, target.start_pos.offset]}.
796
953
  each {|(s2, target)| map.add(s2, target)}
797
954
  map
@@ -810,17 +967,28 @@ CSS
810
967
 
811
968
  def assert_positions_equal(expected, actual, lines, message = nil)
812
969
  prefix = message ? message + ": " : ""
970
+ expected_location = lines[expected.line - 1] + "\n" + ("-" * (expected.offset - 1)) + "^"
971
+ actual_location = lines[actual.line - 1] + "\n" + ("-" * (actual.offset - 1)) + "^"
813
972
  assert_equal(expected.line, actual.line, prefix +
814
- "Expected #{expected.inspect} but was #{actual.inspect}")
973
+ "Expected #{expected.inspect}\n" +
974
+ expected_location + "\n\n" +
975
+ "But was #{actual.inspect}\n" +
976
+ actual_location)
815
977
  assert_equal(expected.offset, actual.offset, prefix +
816
- "Expected #{expected.inspect} but was #{actual.inspect}\n" +
817
- lines[actual.line - 1] + "\n" + ("-" * (actual.offset - 1)) + "^")
978
+ "Expected #{expected.inspect}\n" +
979
+ expected_location + "\n\n" +
980
+ "But was #{actual.inspect}\n" +
981
+ actual_location)
818
982
  end
819
983
 
820
984
  def assert_ranges_equal(expected, actual, lines, prefix)
821
985
  assert_positions_equal(expected.start_pos, actual.start_pos, lines, prefix + " start position")
822
986
  assert_positions_equal(expected.end_pos, actual.end_pos, lines, prefix + " end position")
823
- assert_equal(expected.file, actual.file)
987
+ if expected.file.nil?
988
+ assert_nil(actual.file)
989
+ else
990
+ assert_equal(expected.file, actual.file)
991
+ end
824
992
  end
825
993
 
826
994
  def assert_sourcemaps_equal(source, css, expected, actual)
@@ -843,7 +1011,7 @@ MESSAGE
843
1011
  rendered, sourcemap = render_with_sourcemap(source, options)
844
1012
  css_path = options[:output] || "test.css"
845
1013
  sourcemap_path = Sass::Util.sourcemap_name(css_path)
846
- rendered_json = sourcemap.to_json(:css_path => css_path, :sourcemap_path => sourcemap_path)
1014
+ rendered_json = sourcemap.to_json(:css_path => css_path, :sourcemap_path => sourcemap_path, :type => options[:sourcemap])
847
1015
 
848
1016
  assert_equal css.rstrip, rendered.rstrip
849
1017
  assert_equal sourcemap_json.rstrip, rendered_json