sass 3.6.0 → 3.7.0

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