sass 3.4.25 → 3.7.4

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 (237) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/README.md +17 -9
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/extra/sass-spec-ref.sh +9 -1
  9. data/lib/sass.rb +0 -7
  10. data/lib/sass/cache_stores/filesystem.rb +1 -1
  11. data/lib/sass/css.rb +1 -2
  12. data/lib/sass/engine.rb +39 -29
  13. data/lib/sass/environment.rb +26 -5
  14. data/lib/sass/error.rb +2 -2
  15. data/lib/sass/exec/base.rb +2 -13
  16. data/lib/sass/exec/sass_scss.rb +1 -5
  17. data/lib/sass/features.rb +1 -0
  18. data/lib/sass/importers/filesystem.rb +6 -4
  19. data/lib/sass/logger/base.rb +11 -0
  20. data/lib/sass/plugin/compiler.rb +20 -50
  21. data/lib/sass/plugin/configuration.rb +2 -2
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script/css_parser.rb +4 -1
  24. data/lib/sass/script/functions.rb +308 -81
  25. data/lib/sass/script/lexer.rb +63 -9
  26. data/lib/sass/script/parser.rb +287 -118
  27. data/lib/sass/script/tree/funcall.rb +35 -34
  28. data/lib/sass/script/tree/interpolation.rb +0 -3
  29. data/lib/sass/script/tree/list_literal.rb +23 -8
  30. data/lib/sass/script/tree/map_literal.rb +2 -2
  31. data/lib/sass/script/tree/node.rb +0 -8
  32. data/lib/sass/script/tree/operation.rb +1 -8
  33. data/lib/sass/script/value.rb +2 -0
  34. data/lib/sass/script/value/arg_list.rb +1 -1
  35. data/lib/sass/script/value/base.rb +17 -0
  36. data/lib/sass/script/value/callable.rb +25 -0
  37. data/lib/sass/script/value/color.rb +8 -2
  38. data/lib/sass/script/value/function.rb +19 -0
  39. data/lib/sass/script/value/helpers.rb +37 -11
  40. data/lib/sass/script/value/list.rb +35 -14
  41. data/lib/sass/script/value/map.rb +2 -2
  42. data/lib/sass/script/value/number.rb +3 -2
  43. data/lib/sass/scss/css_parser.rb +6 -1
  44. data/lib/sass/scss/parser.rb +145 -56
  45. data/lib/sass/scss/rx.rb +5 -11
  46. data/lib/sass/scss/static_parser.rb +20 -42
  47. data/lib/sass/selector.rb +4 -0
  48. data/lib/sass/selector/abstract_sequence.rb +7 -6
  49. data/lib/sass/selector/comma_sequence.rb +9 -5
  50. data/lib/sass/selector/pseudo.rb +20 -3
  51. data/lib/sass/selector/sequence.rb +35 -10
  52. data/lib/sass/selector/simple.rb +9 -2
  53. data/lib/sass/selector/simple_sequence.rb +8 -4
  54. data/lib/sass/source/map.rb +2 -6
  55. data/lib/sass/stack.rb +21 -1
  56. data/lib/sass/tree/charset_node.rb +1 -1
  57. data/lib/sass/tree/prop_node.rb +45 -53
  58. data/lib/sass/tree/rule_node.rb +6 -8
  59. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  60. data/lib/sass/tree/visitors/convert.rb +2 -3
  61. data/lib/sass/tree/visitors/cssize.rb +4 -15
  62. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  63. data/lib/sass/tree/visitors/extend.rb +2 -8
  64. data/lib/sass/tree/visitors/perform.rb +23 -15
  65. data/lib/sass/tree/visitors/set_options.rb +1 -1
  66. data/lib/sass/tree/visitors/to_css.rb +49 -22
  67. data/lib/sass/util.rb +72 -310
  68. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  69. data/lib/sass/util/normalized_map.rb +1 -8
  70. data/lib/sass/version.rb +0 -4
  71. metadata +55 -202
  72. data/Rakefile +0 -453
  73. data/lib/sass/script/css_variable_warning.rb +0 -52
  74. data/lib/sass/util/cross_platform_random.rb +0 -19
  75. data/lib/sass/util/ordered_hash.rb +0 -192
  76. data/test/sass-spec.yml +0 -3
  77. data/test/sass/cache_test.rb +0 -131
  78. data/test/sass/callbacks_test.rb +0 -61
  79. data/test/sass/compiler_test.rb +0 -236
  80. data/test/sass/conversion_test.rb +0 -2188
  81. data/test/sass/css2sass_test.rb +0 -526
  82. data/test/sass/css_variable_test.rb +0 -132
  83. data/test/sass/data/hsl-rgb.txt +0 -319
  84. data/test/sass/encoding_test.rb +0 -219
  85. data/test/sass/engine_test.rb +0 -3447
  86. data/test/sass/exec_test.rb +0 -96
  87. data/test/sass/extend_test.rb +0 -1733
  88. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  89. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  90. data/test/sass/functions_test.rb +0 -1977
  91. data/test/sass/importer_test.rb +0 -421
  92. data/test/sass/logger_test.rb +0 -58
  93. data/test/sass/mock_importer.rb +0 -49
  94. data/test/sass/more_results/more1.css +0 -9
  95. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  96. data/test/sass/more_results/more_import.css +0 -29
  97. data/test/sass/more_templates/_more_partial.sass +0 -2
  98. data/test/sass/more_templates/more1.sass +0 -23
  99. data/test/sass/more_templates/more_import.sass +0 -11
  100. data/test/sass/plugin_test.rb +0 -556
  101. data/test/sass/results/alt.css +0 -4
  102. data/test/sass/results/basic.css +0 -9
  103. data/test/sass/results/cached_import_option.css +0 -3
  104. data/test/sass/results/compact.css +0 -5
  105. data/test/sass/results/complex.css +0 -86
  106. data/test/sass/results/compressed.css +0 -1
  107. data/test/sass/results/expanded.css +0 -19
  108. data/test/sass/results/filename_fn.css +0 -3
  109. data/test/sass/results/if.css +0 -3
  110. data/test/sass/results/import.css +0 -31
  111. data/test/sass/results/import_charset.css +0 -5
  112. data/test/sass/results/import_charset_1_8.css +0 -5
  113. data/test/sass/results/import_charset_ibm866.css +0 -5
  114. data/test/sass/results/import_content.css +0 -1
  115. data/test/sass/results/line_numbers.css +0 -49
  116. data/test/sass/results/mixins.css +0 -95
  117. data/test/sass/results/multiline.css +0 -24
  118. data/test/sass/results/nested.css +0 -22
  119. data/test/sass/results/options.css +0 -1
  120. data/test/sass/results/parent_ref.css +0 -13
  121. data/test/sass/results/script.css +0 -16
  122. data/test/sass/results/scss_import.css +0 -31
  123. data/test/sass/results/scss_importee.css +0 -2
  124. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  125. data/test/sass/results/subdir/subdir.css +0 -3
  126. data/test/sass/results/units.css +0 -11
  127. data/test/sass/results/warn.css +0 -0
  128. data/test/sass/results/warn_imported.css +0 -0
  129. data/test/sass/script_conversion_test.rb +0 -357
  130. data/test/sass/script_test.rb +0 -1431
  131. data/test/sass/scss/css_test.rb +0 -1281
  132. data/test/sass/scss/rx_test.rb +0 -160
  133. data/test/sass/scss/scss_test.rb +0 -4205
  134. data/test/sass/scss/test_helper.rb +0 -37
  135. data/test/sass/source_map_test.rb +0 -1055
  136. data/test/sass/superselector_test.rb +0 -210
  137. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  138. data/test/sass/templates/_double_import_loop2.sass +0 -1
  139. data/test/sass/templates/_filename_fn_import.scss +0 -11
  140. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  141. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  142. data/test/sass/templates/_imported_content.sass +0 -3
  143. data/test/sass/templates/_partial.sass +0 -2
  144. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/alt.sass +0 -16
  146. data/test/sass/templates/basic.sass +0 -23
  147. data/test/sass/templates/bork1.sass +0 -2
  148. data/test/sass/templates/bork2.sass +0 -2
  149. data/test/sass/templates/bork3.sass +0 -2
  150. data/test/sass/templates/bork4.sass +0 -2
  151. data/test/sass/templates/bork5.sass +0 -3
  152. data/test/sass/templates/cached_import_option.scss +0 -3
  153. data/test/sass/templates/compact.sass +0 -17
  154. data/test/sass/templates/complex.sass +0 -305
  155. data/test/sass/templates/compressed.sass +0 -15
  156. data/test/sass/templates/double_import_loop1.sass +0 -1
  157. data/test/sass/templates/expanded.sass +0 -17
  158. data/test/sass/templates/filename_fn.scss +0 -18
  159. data/test/sass/templates/if.sass +0 -11
  160. data/test/sass/templates/import.sass +0 -12
  161. data/test/sass/templates/import_charset.sass +0 -9
  162. data/test/sass/templates/import_charset_1_8.sass +0 -6
  163. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  164. data/test/sass/templates/import_content.sass +0 -4
  165. data/test/sass/templates/importee.less +0 -2
  166. data/test/sass/templates/importee.sass +0 -19
  167. data/test/sass/templates/line_numbers.sass +0 -13
  168. data/test/sass/templates/mixin_bork.sass +0 -5
  169. data/test/sass/templates/mixins.sass +0 -76
  170. data/test/sass/templates/multiline.sass +0 -20
  171. data/test/sass/templates/nested.sass +0 -25
  172. data/test/sass/templates/nested_bork1.sass +0 -2
  173. data/test/sass/templates/nested_bork2.sass +0 -2
  174. data/test/sass/templates/nested_bork3.sass +0 -2
  175. data/test/sass/templates/nested_bork4.sass +0 -2
  176. data/test/sass/templates/nested_import.sass +0 -2
  177. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  178. data/test/sass/templates/options.sass +0 -2
  179. data/test/sass/templates/parent_ref.sass +0 -25
  180. data/test/sass/templates/same_name_different_ext.sass +0 -2
  181. data/test/sass/templates/same_name_different_ext.scss +0 -1
  182. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  183. data/test/sass/templates/script.sass +0 -101
  184. data/test/sass/templates/scss_import.scss +0 -12
  185. data/test/sass/templates/scss_importee.scss +0 -1
  186. data/test/sass/templates/single_import_loop.sass +0 -1
  187. data/test/sass/templates/subdir/import_up1.scss +0 -1
  188. data/test/sass/templates/subdir/import_up2.scss +0 -1
  189. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  190. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  191. data/test/sass/templates/subdir/subdir.sass +0 -6
  192. data/test/sass/templates/units.sass +0 -11
  193. data/test/sass/templates/warn.sass +0 -3
  194. data/test/sass/templates/warn_imported.sass +0 -4
  195. data/test/sass/test_helper.rb +0 -8
  196. data/test/sass/util/multibyte_string_scanner_test.rb +0 -155
  197. data/test/sass/util/normalized_map_test.rb +0 -51
  198. data/test/sass/util/subset_map_test.rb +0 -91
  199. data/test/sass/util_test.rb +0 -438
  200. data/test/sass/value_helpers_test.rb +0 -179
  201. data/test/test_helper.rb +0 -110
  202. data/vendor/listen/CHANGELOG.md +0 -1
  203. data/vendor/listen/CONTRIBUTING.md +0 -38
  204. data/vendor/listen/Gemfile +0 -20
  205. data/vendor/listen/Guardfile +0 -8
  206. data/vendor/listen/LICENSE +0 -20
  207. data/vendor/listen/README.md +0 -349
  208. data/vendor/listen/Rakefile +0 -5
  209. data/vendor/listen/Vagrantfile +0 -96
  210. data/vendor/listen/lib/listen.rb +0 -54
  211. data/vendor/listen/lib/listen/adapter.rb +0 -327
  212. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  213. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  214. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  215. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  216. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  217. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  218. data/vendor/listen/lib/listen/listener.rb +0 -323
  219. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  220. data/vendor/listen/lib/listen/version.rb +0 -3
  221. data/vendor/listen/listen.gemspec +0 -28
  222. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  223. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  224. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  225. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  226. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  227. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  228. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  229. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  230. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  231. data/vendor/listen/spec/listen_spec.rb +0 -67
  232. data/vendor/listen/spec/spec_helper.rb +0 -25
  233. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  234. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  235. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  236. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  237. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,37 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
- require 'sass/engine'
3
-
4
- module ScssTestHelper
5
- def assert_parses(scss)
6
- assert_equal scss.rstrip, render(scss).rstrip
7
- end
8
-
9
- def assert_not_parses(expected, scss)
10
- raise "Template must include <err> where an error is expected" unless scss.include?("<err>")
11
-
12
- after, was = scss.split("<err>")
13
- line = after.count("\n") + 1
14
-
15
- after.gsub!(/\s*\n\s*$/, '')
16
- after.gsub!(/.*\n/, '')
17
- after = "..." + after[-15..-1] if after.size > 18
18
-
19
- was.gsub!(/^\s*\n\s*/, '')
20
- was.gsub!(/\n.*/, '')
21
- was = was[0...15] + "..." if was.size > 18
22
-
23
- to_render = scss.sub("<err>", "")
24
- render(to_render)
25
- assert(false, "Expected syntax error for:\n#{to_render}\n")
26
- rescue Sass::SyntaxError => err
27
- assert_equal("Invalid CSS after \"#{after}\": expected #{expected}, was \"#{was}\"",
28
- err.message)
29
- assert_equal line, err.sass_line
30
- end
31
-
32
- def render(scss, options = {})
33
- options[:syntax] ||= :scss
34
- munge_filename options
35
- Sass::Engine.new(scss, options).render
36
- end
37
- end
@@ -1,1055 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- require File.dirname(__FILE__) + '/../test_helper'
4
- require File.dirname(__FILE__) + '/test_helper'
5
-
6
- class SourcemapTest < MiniTest::Test
7
- def test_to_json_requires_args
8
- _, sourcemap = render_with_sourcemap('')
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
- end
13
-
14
- def test_simple_mapping_scss
15
- assert_parses_with_sourcemap <<SCSS, <<CSS, <<JSON
16
- a {
17
- foo: bar;
18
- /* SOME COMMENT */
19
- font-size: 12px;
20
- }
21
- SCSS
22
- a {
23
- foo: bar;
24
- /* SOME COMMENT */
25
- font-size: 12px; }
26
-
27
- /*# sourceMappingURL=test.css.map */
28
- CSS
29
- {
30
- "version": 3,
31
- "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;EACV,kBAAkB;EAChB,SAAS,EAAE,IAAI",
32
- "sources": ["test_simple_mapping_scss_inline.scss"],
33
- "names": [],
34
- "file": "test.css"
35
- }
36
- JSON
37
- end
38
-
39
- def test_simple_mapping_sass
40
- silence_warnings {assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, :syntax => :sass}
41
- a
42
- foo: bar
43
- /* SOME COMMENT */
44
- :font-size 12px
45
- SASS
46
- a {
47
- foo: bar;
48
- /* SOME COMMENT */
49
- font-size: 12px; }
50
-
51
- /*# sourceMappingURL=test.css.map */
52
- CSS
53
- {
54
- "version": 3,
55
- "mappings": "AAAA,CAAC;EACC,GAAG,EAAE,GAAG;;EAEP,SAAS,EAAC,IAAI",
56
- "sources": ["test_simple_mapping_sass_inline.sass"],
57
- "names": [],
58
- "file": "test.css"
59
- }
60
- JSON
61
- end
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
-
89
- def test_mapping_with_directory_scss
90
- options = {:filename => "scss/style.scss", :output => "css/style.css"}
91
- assert_parses_with_sourcemap <<SCSS, <<CSS, <<JSON, options
92
- a {
93
- foo: bar;
94
- /* SOME COMMENT */
95
- font-size: 12px;
96
- }
97
- SCSS
98
- a {
99
- foo: bar;
100
- /* SOME COMMENT */
101
- font-size: 12px; }
102
-
103
- /*# sourceMappingURL=style.css.map */
104
- CSS
105
- {
106
- "version": 3,
107
- "mappings": "AAAA,CAAE;EACA,GAAG,EAAE,GAAG;EACV,kBAAkB;EAChB,SAAS,EAAE,IAAI",
108
- "sources": ["../scss/style.scss"],
109
- "names": [],
110
- "file": "style.css"
111
- }
112
- JSON
113
- end
114
-
115
- def test_mapping_with_directory_sass
116
- options = {:filename => "sass/style.sass", :output => "css/style.css", :syntax => :sass}
117
- silence_warnings {assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, options}
118
- a
119
- foo: bar
120
- /* SOME COMMENT */
121
- :font-size 12px
122
- SASS
123
- a {
124
- foo: bar;
125
- /* SOME COMMENT */
126
- font-size: 12px; }
127
-
128
- /*# sourceMappingURL=style.css.map */
129
- CSS
130
- {
131
- "version": 3,
132
- "mappings": "AAAA,CAAC;EACC,GAAG,EAAE,GAAG;;EAEP,SAAS,EAAC,IAAI",
133
- "sources": ["../sass/style.sass"],
134
- "names": [],
135
- "file": "style.css"
136
- }
137
- JSON
138
- end
139
-
140
- unless Sass::Util.ruby1_8?
141
- def test_simple_charset_mapping_scss
142
- assert_parses_with_sourcemap <<SCSS, <<CSS, <<JSON
143
- a {
144
- fóó: bár;
145
- }
146
- SCSS
147
- @charset "UTF-8";
148
- a {
149
- fóó: bár; }
150
-
151
- /*# sourceMappingURL=test.css.map */
152
- CSS
153
- {
154
- "version": 3,
155
- "mappings": ";AAAA,CAAE;EACA,GAAG,EAAE,GAAG",
156
- "sources": ["test_simple_charset_mapping_scss_inline.scss"],
157
- "names": [],
158
- "file": "test.css"
159
- }
160
- JSON
161
- end
162
-
163
- def test_simple_charset_mapping_sass
164
- assert_parses_with_sourcemap <<SASS, <<CSS, <<JSON, :syntax => :sass
165
- a
166
- fóó: bár
167
- SASS
168
- @charset "UTF-8";
169
- a {
170
- fóó: bár; }
171
-
172
- /*# sourceMappingURL=test.css.map */
173
- CSS
174
- {
175
- "version": 3,
176
- "mappings": ";AAAA,CAAC;EACC,GAAG,EAAE,GAAG",
177
- "sources": ["test_simple_charset_mapping_sass_inline.sass"],
178
- "names": [],
179
- "file": "test.css"
180
- }
181
- JSON
182
- end
183
-
184
- def test_different_charset_than_encoding_scss
185
- assert_parses_with_sourcemap(<<SCSS.force_encoding("IBM866"), <<CSS, <<JSON)
186
- @charset "IBM866";
187
- f\x86\x86 {
188
- \x86: b;
189
- }
190
- SCSS
191
- @charset "UTF-8";
192
- fЖЖ {
193
- Ж: b; }
194
-
195
- /*# sourceMappingURL=test.css.map */
196
- CSS
197
- {
198
- "version": 3,
199
- "mappings": ";AACA,GAAI;EACF,CAAC,EAAE,CAAC",
200
- "sources": ["test_different_charset_than_encoding_scss_inline.scss"],
201
- "names": [],
202
- "file": "test.css"
203
- }
204
- JSON
205
- end
206
-
207
- def test_different_charset_than_encoding_sass
208
- assert_parses_with_sourcemap(<<SASS.force_encoding("IBM866"), <<CSS, <<JSON, :syntax => :sass)
209
- @charset "IBM866"
210
- f\x86\x86
211
- \x86: b
212
- SASS
213
- @charset "UTF-8";
214
- fЖЖ {
215
- Ж: b; }
216
-
217
- /*# sourceMappingURL=test.css.map */
218
- CSS
219
- {
220
- "version": 3,
221
- "mappings": ";AACA,GAAG;EACD,CAAC,EAAE,CAAC",
222
- "sources": ["test_different_charset_than_encoding_sass_inline.sass"],
223
- "names": [],
224
- "file": "test.css"
225
- }
226
- JSON
227
- end
228
- end
229
-
230
- def test_import_sourcemap_scss
231
- assert_parses_with_mapping <<'SCSS', <<'CSS'
232
- @import {{1}}url(foo){{/1}},{{2}}url(moo) {{/2}}, {{3}}url(bar) {{/3}};
233
- @import {{4}}url(baz) screen print{{/4}};
234
- SCSS
235
- {{1}}@import url(foo){{/1}};
236
- {{2}}@import url(moo){{/2}};
237
- {{3}}@import url(bar){{/3}};
238
- {{4}}@import url(baz) screen print{{/4}};
239
-
240
- /*# sourceMappingURL=test.css.map */
241
- CSS
242
- end
243
-
244
- def test_import_sourcemap_sass
245
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
246
- @import {{1}}foo.css{{/1}},{{2}}moo.css{{/2}}, {{3}}bar.css{{/3}}
247
- @import {{4}}url(baz.css){{/4}}
248
- @import {{5}}url(qux.css) screen print{{/5}}
249
- SASS
250
- {{1}}@import url(foo.css){{/1}};
251
- {{2}}@import url(moo.css){{/2}};
252
- {{3}}@import url(bar.css){{/3}};
253
- {{4}}@import url(baz.css){{/4}};
254
- {{5}}@import url(qux.css) screen print{{/5}};
255
-
256
- /*# sourceMappingURL=test.css.map */
257
- CSS
258
- end
259
-
260
- def test_media_sourcemap_scss
261
- assert_parses_with_mapping <<'SCSS', <<'CSS'
262
- {{1}}@media screen, tv {{/1}}{
263
- {{2}}body {{/2}}{
264
- {{3}}max-width{{/3}}: {{4}}1070px{{/4}};
265
- }
266
- }
267
- SCSS
268
- {{1}}@media screen, tv{{/1}} {
269
- {{2}}body{{/2}} {
270
- {{3}}max-width{{/3}}: {{4}}1070px{{/4}}; } }
271
-
272
- /*# sourceMappingURL=test.css.map */
273
- CSS
274
- end
275
-
276
- def test_media_sourcemap_sass
277
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
278
- {{1}}@media screen, tv{{/1}}
279
- {{2}}body{{/2}}
280
- {{3}}max-width{{/3}}: {{4}}1070px{{/4}}
281
- SASS
282
- {{1}}@media screen, tv{{/1}} {
283
- {{2}}body{{/2}} {
284
- {{3}}max-width{{/3}}: {{4}}1070px{{/4}}; } }
285
-
286
- /*# sourceMappingURL=test.css.map */
287
- CSS
288
- end
289
-
290
- def test_interpolation_and_vars_sourcemap_scss
291
- assert_parses_with_mapping <<'SCSS', <<'CSS'
292
- $te: "te";
293
- $teal: {{5}}teal{{/5}};
294
- {{1}}p {{/1}}{
295
- {{2}}con#{$te}nt{{/2}}: {{3}}"I a#{$te} #{5 + 10} pies!"{{/3}};
296
- {{4}}color{{/4}}: $teal;
297
- }
298
-
299
- $name: foo;
300
- $attr: border;
301
- {{6}}p.#{$name} {{/6}}{
302
- {{7}}#{$attr}-color{{/7}}: {{8}}blue{{/8}};
303
- $font-size: 12px;
304
- $line-height: 30px;
305
- {{9}}font{{/9}}: {{10}}#{$font-size}/#{$line-height}{{/10}};
306
- }
307
- SCSS
308
- {{1}}p{{/1}} {
309
- {{2}}content{{/2}}: {{3}}"I ate 15 pies!"{{/3}};
310
- {{4}}color{{/4}}: {{5}}teal{{/5}}; }
311
-
312
- {{6}}p.foo{{/6}} {
313
- {{7}}border-color{{/7}}: {{8}}blue{{/8}};
314
- {{9}}font{{/9}}: {{10}}12px/30px{{/10}}; }
315
-
316
- /*# sourceMappingURL=test.css.map */
317
- CSS
318
- end
319
-
320
- def test_interpolation_and_vars_sourcemap_sass
321
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
322
- $te: "te"
323
- $teal: {{5}}teal{{/5}}
324
- {{1}}p{{/1}}
325
- {{2}}con#{$te}nt{{/2}}: {{3}}"I a#{$te} #{5 + 10} pies!"{{/3}}
326
- {{4}}color{{/4}}: $teal
327
-
328
- $name: foo
329
- $attr: border
330
- {{6}}p.#{$name}{{/6}}
331
- {{7}}#{$attr}-color{{/7}}: {{8}}blue{{/8}}
332
- $font-size: 12px
333
- $line-height: 30px
334
- {{9}}font{{/9}}: {{10}}#{$font-size}/#{$line-height}{{/10}}
335
- SASS
336
- {{1}}p{{/1}} {
337
- {{2}}content{{/2}}: {{3}}"I ate 15 pies!"{{/3}};
338
- {{4}}color{{/4}}: {{5}}teal{{/5}}; }
339
-
340
- {{6}}p.foo{{/6}} {
341
- {{7}}border-color{{/7}}: {{8}}blue{{/8}};
342
- {{9}}font{{/9}}: {{10}}12px/30px{{/10}}; }
343
-
344
- /*# sourceMappingURL=test.css.map */
345
- CSS
346
- end
347
-
348
- def test_selectors_properties_sourcemap_scss
349
- assert_parses_with_mapping <<'SCSS', <<'CSS'
350
- $width: 2px;
351
- $translucent-red: rgba(255, 0, 0, 0.5);
352
- {{1}}a {{/1}}{
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}};
359
- }
360
- {{19}}&:after {{/19}}{
361
- {{20}}content{{/20}}: {{21}}"I ate #{5 + 10} pies #{$width} thick!"{{/21}};
362
- }
363
- }
364
- {{22}}&:active {{/22}}{
365
- {{23}}border{{/23}}: {{24}}$width solid black{{/24}};
366
- }
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}};
371
- }
372
- }
373
- SCSS
374
- {{1}}a{{/1}} {
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}}; }
389
-
390
- /*# sourceMappingURL=test.css.map */
391
- CSS
392
- end
393
-
394
- def test_selectors_properties_sourcemap_sass
395
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
396
- $width: 2px
397
- $translucent-red: rgba(255, 0, 0, 0.5)
398
- {{1}}a{{/1}}
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}}
414
- SASS
415
- {{1}}a{{/1}} {
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}}; }
430
-
431
- /*# sourceMappingURL=test.css.map */
432
- CSS
433
- end
434
-
435
- def test_extend_sourcemap_scss
436
- assert_parses_with_mapping <<'SCSS', <<'CSS'
437
- {{1}}.error {{/1}}{
438
- {{2}}border{{/2}}: {{3}}1px #ff00aa{{/3}};
439
- {{4}}background-color{{/4}}: {{5}}#fdd{{/5}};
440
- }
441
- {{6}}.seriousError {{/6}}{
442
- @extend .error;
443
- {{7}}border-width{{/7}}: {{8}}3px{{/8}};
444
- }
445
- SCSS
446
- {{1}}.error, .seriousError{{/1}} {
447
- {{2}}border{{/2}}: {{3}}1px #ff00aa{{/3}};
448
- {{4}}background-color{{/4}}: {{5}}#fdd{{/5}}; }
449
-
450
- {{6}}.seriousError{{/6}} {
451
- {{7}}border-width{{/7}}: {{8}}3px{{/8}}; }
452
-
453
- /*# sourceMappingURL=test.css.map */
454
- CSS
455
- end
456
-
457
- def test_extend_sourcemap_sass
458
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
459
- {{1}}.error{{/1}}
460
- {{2}}border{{/2}}: {{3}}1px #f00{{/3}}
461
- {{4}}background-color{{/4}}: {{5}}#fdd{{/5}}
462
-
463
- {{6}}.seriousError{{/6}}
464
- @extend .error
465
- {{7}}border-width{{/7}}: {{8}}3px{{/8}}
466
- SASS
467
- {{1}}.error, .seriousError{{/1}} {
468
- {{2}}border{{/2}}: {{3}}1px #f00{{/3}};
469
- {{4}}background-color{{/4}}: {{5}}#fdd{{/5}}; }
470
-
471
- {{6}}.seriousError{{/6}} {
472
- {{7}}border-width{{/7}}: {{8}}3px{{/8}}; }
473
-
474
- /*# sourceMappingURL=test.css.map */
475
- CSS
476
- end
477
-
478
- def test_for_sourcemap_scss
479
- assert_parses_with_mapping <<'SCSS', <<'CSS'
480
- @for $i from 1 through 3 {
481
- {{1}}{{4}}{{7}}.item-#{$i} {{/1}}{{/4}}{{/7}}{ {{2}}{{5}}{{8}}width{{/2}}{{/5}}{{/8}}: {{3}}{{6}}{{9}}2em * $i{{/3}}{{/6}}{{/9}}; }
482
- }
483
- SCSS
484
- {{1}}.item-1{{/1}} {
485
- {{2}}width{{/2}}: {{3}}2em{{/3}}; }
486
-
487
- {{4}}.item-2{{/4}} {
488
- {{5}}width{{/5}}: {{6}}4em{{/6}}; }
489
-
490
- {{7}}.item-3{{/7}} {
491
- {{8}}width{{/8}}: {{9}}6em{{/9}}; }
492
-
493
- /*# sourceMappingURL=test.css.map */
494
- CSS
495
- end
496
-
497
- def test_for_sourcemap_sass
498
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
499
- @for $i from 1 through 3
500
- {{1}}{{4}}{{7}}.item-#{$i}{{/1}}{{/4}}{{/7}}
501
- {{2}}{{5}}{{8}}width{{/2}}{{/5}}{{/8}}: {{3}}{{6}}{{9}}2em * $i{{/3}}{{/6}}{{/9}}
502
- SASS
503
- {{1}}.item-1{{/1}} {
504
- {{2}}width{{/2}}: {{3}}2em{{/3}}; }
505
-
506
- {{4}}.item-2{{/4}} {
507
- {{5}}width{{/5}}: {{6}}4em{{/6}}; }
508
-
509
- {{7}}.item-3{{/7}} {
510
- {{8}}width{{/8}}: {{9}}6em{{/9}}; }
511
-
512
- /*# sourceMappingURL=test.css.map */
513
- CSS
514
- end
515
-
516
- def test_while_sourcemap_scss
517
- assert_parses_with_mapping <<'SCSS', <<'CSS'
518
- $i: 6;
519
- @while $i > 0 {
520
- {{1}}{{4}}{{7}}.item-#{$i} {{/1}}{{/4}}{{/7}}{ {{2}}{{5}}{{8}}width{{/2}}{{/5}}{{/8}}: {{3}}{{6}}{{9}}2em * $i{{/3}}{{/6}}{{/9}}; }
521
- $i: $i - 2 !global;
522
- }
523
- SCSS
524
- {{1}}.item-6{{/1}} {
525
- {{2}}width{{/2}}: {{3}}12em{{/3}}; }
526
-
527
- {{4}}.item-4{{/4}} {
528
- {{5}}width{{/5}}: {{6}}8em{{/6}}; }
529
-
530
- {{7}}.item-2{{/7}} {
531
- {{8}}width{{/8}}: {{9}}4em{{/9}}; }
532
-
533
- /*# sourceMappingURL=test.css.map */
534
- CSS
535
- end
536
-
537
- def test_while_sourcemap_sass
538
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
539
- $i: 6
540
- @while $i > 0
541
- {{1}}{{4}}{{7}}.item-#{$i}{{/1}}{{/4}}{{/7}}
542
- {{2}}{{5}}{{8}}width{{/2}}{{/5}}{{/8}}: {{3}}{{6}}{{9}}2em * $i{{/3}}{{/6}}{{/9}}
543
- $i: $i - 2 !global
544
- SASS
545
- {{1}}.item-6{{/1}} {
546
- {{2}}width{{/2}}: {{3}}12em{{/3}}; }
547
-
548
- {{4}}.item-4{{/4}} {
549
- {{5}}width{{/5}}: {{6}}8em{{/6}}; }
550
-
551
- {{7}}.item-2{{/7}} {
552
- {{8}}width{{/8}}: {{9}}4em{{/9}}; }
553
-
554
- /*# sourceMappingURL=test.css.map */
555
- CSS
556
- end
557
-
558
- def test_each_sourcemap_scss
559
- assert_parses_with_mapping <<'SCSS', <<'CSS'
560
- @each $animal in puma, sea-slug, egret, salamander {
561
- {{1}}{{4}}{{7}}{{10}}.#{$animal}-icon {{/1}}{{/4}}{{/7}}{{/10}}{
562
- {{2}}{{5}}{{8}}{{11}}background-image{{/2}}{{/5}}{{/8}}{{/11}}: {{3}}{{6}}{{9}}{{12}}url('/images/#{$animal}.png'){{/3}}{{/6}}{{/9}}{{/12}};
563
- }
564
- }
565
- SCSS
566
- {{1}}.puma-icon{{/1}} {
567
- {{2}}background-image{{/2}}: {{3}}url("/images/puma.png"){{/3}}; }
568
-
569
- {{4}}.sea-slug-icon{{/4}} {
570
- {{5}}background-image{{/5}}: {{6}}url("/images/sea-slug.png"){{/6}}; }
571
-
572
- {{7}}.egret-icon{{/7}} {
573
- {{8}}background-image{{/8}}: {{9}}url("/images/egret.png"){{/9}}; }
574
-
575
- {{10}}.salamander-icon{{/10}} {
576
- {{11}}background-image{{/11}}: {{12}}url("/images/salamander.png"){{/12}}; }
577
-
578
- /*# sourceMappingURL=test.css.map */
579
- CSS
580
- end
581
-
582
- def test_each_sourcemap_sass
583
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
584
- @each $animal in puma, sea-slug, egret, salamander
585
- {{1}}{{4}}{{7}}{{10}}.#{$animal}-icon{{/1}}{{/4}}{{/7}}{{/10}}
586
- {{2}}{{5}}{{8}}{{11}}background-image{{/2}}{{/5}}{{/8}}{{/11}}: {{3}}{{6}}{{9}}{{12}}url('/images/#{$animal}.png'){{/3}}{{/6}}{{/9}}{{/12}}
587
- SASS
588
- {{1}}.puma-icon{{/1}} {
589
- {{2}}background-image{{/2}}: {{3}}url("/images/puma.png"){{/3}}; }
590
-
591
- {{4}}.sea-slug-icon{{/4}} {
592
- {{5}}background-image{{/5}}: {{6}}url("/images/sea-slug.png"){{/6}}; }
593
-
594
- {{7}}.egret-icon{{/7}} {
595
- {{8}}background-image{{/8}}: {{9}}url("/images/egret.png"){{/9}}; }
596
-
597
- {{10}}.salamander-icon{{/10}} {
598
- {{11}}background-image{{/11}}: {{12}}url("/images/salamander.png"){{/12}}; }
599
-
600
- /*# sourceMappingURL=test.css.map */
601
- CSS
602
- end
603
-
604
- def test_mixin_sourcemap_scss
605
- assert_parses_with_mapping <<'SCSS', <<'CSS'
606
- @mixin large-text {
607
- font: {
608
- {{2}}size{{/2}}: {{3}}20px{{/3}};
609
- {{4}}weight{{/4}}: {{5}}bold{{/5}};
610
- }
611
- {{6}}color{{/6}}: {{7}}#ff0000{{/7}};
612
- }
613
-
614
- {{1}}.page-title {{/1}}{
615
- @include large-text;
616
- {{8}}padding{{/8}}: {{9}}4px{{/9}};
617
- }
618
-
619
- @mixin dashed-border($color, $width: {{14}}1in{{/14}}) {
620
- border: {
621
- {{11}}{{18}}color{{/11}}{{/18}}: $color;
622
- {{13}}{{20}}width{{/13}}{{/20}}: $width;
623
- {{15}}{{22}}style{{/15}}{{/22}}: {{16}}{{23}}dashed{{/16}}{{/23}};
624
- }
625
- }
626
-
627
- {{10}}p {{/10}}{ @include dashed-border({{12}}blue{{/12}}); }
628
- {{17}}h1 {{/17}}{ @include dashed-border({{19}}blue{{/19}}, {{21}}2in{{/21}}); }
629
-
630
- @mixin box-shadow($shadows...) {
631
- {{25}}-moz-box-shadow{{/25}}: {{26}}$shadows{{/26}};
632
- {{27}}-webkit-box-shadow{{/27}}: {{28}}$shadows{{/28}};
633
- {{29}}box-shadow{{/29}}: {{30}}$shadows{{/30}};
634
- }
635
-
636
- {{24}}.shadows {{/24}}{
637
- @include box-shadow(0px 4px 5px #666, 2px 6px 10px #999);
638
- }
639
- SCSS
640
- {{1}}.page-title{{/1}} {
641
- {{2}}font-size{{/2}}: {{3}}20px{{/3}};
642
- {{4}}font-weight{{/4}}: {{5}}bold{{/5}};
643
- {{6}}color{{/6}}: {{7}}#ff0000{{/7}};
644
- {{8}}padding{{/8}}: {{9}}4px{{/9}}; }
645
-
646
- {{10}}p{{/10}} {
647
- {{11}}border-color{{/11}}: {{12}}blue{{/12}};
648
- {{13}}border-width{{/13}}: {{14}}1in{{/14}};
649
- {{15}}border-style{{/15}}: {{16}}dashed{{/16}}; }
650
-
651
- {{17}}h1{{/17}} {
652
- {{18}}border-color{{/18}}: {{19}}blue{{/19}};
653
- {{20}}border-width{{/20}}: {{21}}2in{{/21}};
654
- {{22}}border-style{{/22}}: {{23}}dashed{{/23}}; }
655
-
656
- {{24}}.shadows{{/24}} {
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}}; }
660
-
661
- /*# sourceMappingURL=test.css.map */
662
- CSS
663
- end
664
-
665
- def test_mixin_sourcemap_sass
666
- silence_warnings {assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass}
667
- =large-text
668
- :font
669
- {{2}}size{{/2}}: {{3}}20px{{/3}}
670
- {{4}}weight{{/4}}: {{5}}bold{{/5}}
671
- {{6}}color{{/6}}: {{7}}#ff0000{{/7}}
672
-
673
- {{1}}.page-title{{/1}}
674
- +large-text
675
- {{8}}padding{{/8}}: {{9}}4px{{/9}}
676
-
677
- =dashed-border($color, $width: {{14}}1in{{/14}})
678
- border:
679
- {{11}}{{18}}color{{/11}}{{/18}}: $color
680
- {{13}}{{20}}width{{/13}}{{/20}}: $width
681
- {{15}}{{22}}style{{/15}}{{/22}}: {{16}}{{23}}dashed{{/16}}{{/23}}
682
-
683
- {{10}}p{{/10}}
684
- +dashed-border({{12}}blue{{/12}})
685
-
686
- {{17}}h1{{/17}}
687
- +dashed-border({{19}}blue{{/19}}, {{21}}2in{{/21}})
688
-
689
- =box-shadow($shadows...)
690
- {{25}}-moz-box-shadow{{/25}}: {{26}}$shadows{{/26}}
691
- {{27}}-webkit-box-shadow{{/27}}: {{28}}$shadows{{/28}}
692
- {{29}}box-shadow{{/29}}: {{30}}$shadows{{/30}}
693
-
694
- {{24}}.shadows{{/24}}
695
- +box-shadow(0px 4px 5px #666, 2px 6px 10px #999)
696
- SASS
697
- {{1}}.page-title{{/1}} {
698
- {{2}}font-size{{/2}}: {{3}}20px{{/3}};
699
- {{4}}font-weight{{/4}}: {{5}}bold{{/5}};
700
- {{6}}color{{/6}}: {{7}}#ff0000{{/7}};
701
- {{8}}padding{{/8}}: {{9}}4px{{/9}}; }
702
-
703
- {{10}}p{{/10}} {
704
- {{11}}border-color{{/11}}: {{12}}blue{{/12}};
705
- {{13}}border-width{{/13}}: {{14}}1in{{/14}};
706
- {{15}}border-style{{/15}}: {{16}}dashed{{/16}}; }
707
-
708
- {{17}}h1{{/17}} {
709
- {{18}}border-color{{/18}}: {{19}}blue{{/19}};
710
- {{20}}border-width{{/20}}: {{21}}2in{{/21}};
711
- {{22}}border-style{{/22}}: {{23}}dashed{{/23}}; }
712
-
713
- {{24}}.shadows{{/24}} {
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}}; }
717
-
718
- /*# sourceMappingURL=test.css.map */
719
- CSS
720
- end
721
-
722
- def test_function_sourcemap_scss
723
- assert_parses_with_mapping <<'SCSS', <<'CSS'
724
- $grid-width: 20px;
725
- $gutter-width: 5px;
726
-
727
- @function grid-width($n) {
728
- @return $n * $grid-width + ($n - 1) * $gutter-width;
729
- }
730
- {{1}}sidebar {{/1}}{ {{2}}width{{/2}}: {{3}}grid-width(5){{/3}}; }
731
- SCSS
732
- {{1}}sidebar{{/1}} {
733
- {{2}}width{{/2}}: {{3}}120px{{/3}}; }
734
-
735
- /*# sourceMappingURL=test.css.map */
736
- CSS
737
- end
738
-
739
- def test_function_sourcemap_sass
740
- assert_parses_with_mapping <<'SASS', <<'CSS', :syntax => :sass
741
- $grid-width: 20px
742
- $gutter-width: 5px
743
-
744
- @function grid-width($n)
745
- @return $n * $grid-width + ($n - 1) * $gutter-width
746
-
747
- {{1}}sidebar{{/1}}
748
- {{2}}width{{/2}}: {{3}}grid-width(5){{/3}}
749
- SASS
750
- {{1}}sidebar{{/1}} {
751
- {{2}}width{{/2}}: {{3}}120px{{/3}}; }
752
-
753
- /*# sourceMappingURL=test.css.map */
754
- CSS
755
- end
756
-
757
- # Regression tests
758
-
759
- def test_properties_sass
760
- silence_warnings {assert_parses_with_mapping <<SASS, <<CSS, :syntax => :sass}
761
- {{1}}.foo{{/1}}
762
- :{{2}}name{{/2}} {{3}}value{{/3}}
763
- {{4}}name{{/4}}: {{5}}value{{/5}}
764
- :{{6}}name{{/6}} {{7}}value{{/7}}
765
- {{8}}name{{/8}}: {{9}}value{{/9}}
766
- SASS
767
- {{1}}.foo{{/1}} {
768
- {{2}}name{{/2}}: {{3}}value{{/3}};
769
- {{4}}name{{/4}}: {{5}}value{{/5}};
770
- {{6}}name{{/6}}: {{7}}value{{/7}};
771
- {{8}}name{{/8}}: {{9}}value{{/9}}; }
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
-
907
- /*# sourceMappingURL=test.css.map */
908
- CSS
909
- end
910
-
911
- private
912
-
913
- ANNOTATION_REGEX = /\{\{(\/?)([^}]+)\}\}/
914
-
915
- def build_ranges(text, file_name = nil)
916
- ranges = Hash.new {|h, k| h[k] = []}
917
- start_positions = {}
918
- text.split("\n").each_with_index do |line_text, line|
919
- line += 1 # lines shoud be 1-based
920
- while (match = line_text.match(ANNOTATION_REGEX))
921
- closing = !match[1].empty?
922
- name = match[2]
923
- match_offsets = match.offset(0)
924
- offset = match_offsets[0] + 1 # Offsets are 1-based in source maps.
925
- assert(!closing || start_positions[name], "Closing annotation #{name} found before opening one.")
926
- position = Sass::Source::Position.new(line, offset)
927
- if closing
928
- ranges[name] << Sass::Source::Range.new(
929
- start_positions[name], position, file_name,
930
- Sass::Importers::Filesystem.new('.'))
931
- start_positions.delete name
932
- else
933
- assert(!start_positions[name], "Overlapping range annotation #{name} encountered on line #{line}")
934
- start_positions[name] = position
935
- end
936
- line_text.slice!(match_offsets[0], match_offsets[1] - match_offsets[0])
937
- end
938
- end
939
- ranges
940
- end
941
-
942
- def build_mapping_from_annotations(source, css, source_file_name)
943
- source_ranges = build_ranges(source, source_file_name)
944
- target_ranges = build_ranges(css)
945
- map = Sass::Source::Map.new
946
- source_ranges.map do |(name, sources)|
947
- assert(sources.length == 1, "#{sources.length} source ranges encountered for annotation #{name}")
948
- assert(target_ranges[name], "No target ranges for annotation #{name}")
949
- target_ranges[name].map {|target_range| [sources.first, target_range]}
950
- end.
951
- flatten(1).
952
- sort_by {|(_, target)| [target.start_pos.line, target.start_pos.offset]}.
953
- each {|(s2, target)| map.add(s2, target)}
954
- map
955
- end
956
-
957
- def assert_parses_with_mapping(source, css, options={})
958
- options[:syntax] ||= :scss
959
- input_filename = filename_for_test(options[:syntax])
960
- mapping = build_mapping_from_annotations(source, css, input_filename)
961
- source.gsub!(ANNOTATION_REGEX, "")
962
- css.gsub!(ANNOTATION_REGEX, "")
963
- rendered, sourcemap = render_with_sourcemap(source, options)
964
- assert_equal css.rstrip, rendered.rstrip
965
- assert_sourcemaps_equal source, css, mapping, sourcemap
966
- end
967
-
968
- def assert_positions_equal(expected, actual, lines, message = nil)
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)) + "^"
972
- assert_equal(expected.line, actual.line, prefix +
973
- "Expected #{expected.inspect}\n" +
974
- expected_location + "\n\n" +
975
- "But was #{actual.inspect}\n" +
976
- actual_location)
977
- assert_equal(expected.offset, actual.offset, prefix +
978
- "Expected #{expected.inspect}\n" +
979
- expected_location + "\n\n" +
980
- "But was #{actual.inspect}\n" +
981
- actual_location)
982
- end
983
-
984
- def assert_ranges_equal(expected, actual, lines, prefix)
985
- assert_positions_equal(expected.start_pos, actual.start_pos, lines, prefix + " start position")
986
- assert_positions_equal(expected.end_pos, actual.end_pos, lines, prefix + " end position")
987
- if expected.file.nil?
988
- assert_nil(actual.file)
989
- else
990
- assert_equal(expected.file, actual.file)
991
- end
992
- end
993
-
994
- def assert_sourcemaps_equal(source, css, expected, actual)
995
- assert_equal(expected.data.length, actual.data.length, <<MESSAGE)
996
- Wrong number of mappings. Expected:
997
- #{dump_sourcemap_as_expectation(source, css, expected).gsub(/^/, '| ')}
998
-
999
- Actual:
1000
- #{dump_sourcemap_as_expectation(source, css, actual).gsub(/^/, '| ')}
1001
- MESSAGE
1002
- source_lines = source.split("\n")
1003
- css_lines = css.split("\n")
1004
- expected.data.zip(actual.data) do |expected_mapping, actual_mapping|
1005
- assert_ranges_equal(expected_mapping.input, actual_mapping.input, source_lines, "Input")
1006
- assert_ranges_equal(expected_mapping.output, actual_mapping.output, css_lines, "Output")
1007
- end
1008
- end
1009
-
1010
- def assert_parses_with_sourcemap(source, css, sourcemap_json, options={})
1011
- rendered, sourcemap = render_with_sourcemap(source, options)
1012
- css_path = options[:output] || "test.css"
1013
- sourcemap_path = Sass::Util.sourcemap_name(css_path)
1014
- rendered_json = sourcemap.to_json(:css_path => css_path, :sourcemap_path => sourcemap_path, :type => options[:sourcemap])
1015
-
1016
- assert_equal css.rstrip, rendered.rstrip
1017
- assert_equal sourcemap_json.rstrip, rendered_json
1018
- end
1019
-
1020
- def render_with_sourcemap(source, options={})
1021
- options[:syntax] ||= :scss
1022
- munge_filename options
1023
- engine = Sass::Engine.new(source, options)
1024
- engine.options[:cache] = false
1025
- sourcemap_path = Sass::Util.sourcemap_name(options[:output] || "test.css")
1026
- engine.render_with_sourcemap File.basename(sourcemap_path)
1027
- end
1028
-
1029
- def dump_sourcemap_as_expectation(source, css, sourcemap)
1030
- mappings_to_annotations(source, sourcemap.data.map {|d| d.input}) + "\n\n" +
1031
- "=" * 20 + " maps to:\n\n" +
1032
- mappings_to_annotations(css, sourcemap.data.map {|d| d.output})
1033
- end
1034
-
1035
- def mappings_to_annotations(source, ranges)
1036
- additional_offsets = Hash.new(0)
1037
- lines = source.split("\n")
1038
-
1039
- add_annotation = lambda do |pos, str|
1040
- line_num = pos.line - 1
1041
- line = lines[line_num]
1042
- offset = pos.offset + additional_offsets[line_num] - 1
1043
- line << " " * (offset - line.length) if offset > line.length
1044
- line.insert(offset, str)
1045
- additional_offsets[line_num] += str.length
1046
- end
1047
-
1048
- ranges.each_with_index do |range, i|
1049
- add_annotation[range.start_pos, "{{#{i + 1}}}"]
1050
- add_annotation[range.end_pos, "{{/#{i + 1}}}"]
1051
- end
1052
-
1053
- return lines.join("\n")
1054
- end
1055
- end