sass 3.4.25 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +2 -117
  4. data/VERSION +1 -1
  5. data/VERSION_DATE +1 -1
  6. data/VERSION_NAME +1 -1
  7. data/lib/sass/cache_stores/filesystem.rb +1 -1
  8. data/lib/sass/css.rb +1 -2
  9. data/lib/sass/engine.rb +38 -20
  10. data/lib/sass/environment.rb +26 -5
  11. data/lib/sass/error.rb +2 -2
  12. data/lib/sass/exec/base.rb +2 -11
  13. data/lib/sass/features.rb +1 -0
  14. data/lib/sass/importers/filesystem.rb +2 -2
  15. data/lib/sass/plugin/compiler.rb +20 -50
  16. data/lib/sass/plugin/configuration.rb +2 -2
  17. data/lib/sass/railtie.rb +1 -1
  18. data/lib/sass/script/functions.rb +235 -43
  19. data/lib/sass/script/lexer.rb +13 -2
  20. data/lib/sass/script/parser.rb +69 -67
  21. data/lib/sass/script/tree/funcall.rb +35 -30
  22. data/lib/sass/script/tree/list_literal.rb +23 -8
  23. data/lib/sass/script/tree/map_literal.rb +2 -2
  24. data/lib/sass/script/tree/node.rb +0 -8
  25. data/lib/sass/script/tree/operation.rb +0 -7
  26. data/lib/sass/script/value/arg_list.rb +1 -1
  27. data/lib/sass/script/value/base.rb +17 -0
  28. data/lib/sass/script/value/callable.rb +25 -0
  29. data/lib/sass/script/value/color.rb +5 -0
  30. data/lib/sass/script/value/function.rb +19 -0
  31. data/lib/sass/script/value/helpers.rb +29 -9
  32. data/lib/sass/script/value/list.rb +35 -14
  33. data/lib/sass/script/value/map.rb +2 -2
  34. data/lib/sass/script/value/number.rb +1 -1
  35. data/lib/sass/script/value.rb +2 -0
  36. data/lib/sass/scss/parser.rb +99 -40
  37. data/lib/sass/scss/rx.rb +4 -10
  38. data/lib/sass/scss/static_parser.rb +5 -24
  39. data/lib/sass/selector/abstract_sequence.rb +7 -6
  40. data/lib/sass/selector/comma_sequence.rb +7 -4
  41. data/lib/sass/selector/pseudo.rb +19 -2
  42. data/lib/sass/selector/sequence.rb +35 -6
  43. data/lib/sass/selector/simple.rb +9 -2
  44. data/lib/sass/selector/simple_sequence.rb +8 -4
  45. data/lib/sass/selector.rb +4 -0
  46. data/lib/sass/source/map.rb +2 -2
  47. data/lib/sass/stack.rb +21 -1
  48. data/lib/sass/tree/charset_node.rb +1 -1
  49. data/lib/sass/tree/prop_node.rb +45 -53
  50. data/lib/sass/tree/rule_node.rb +3 -2
  51. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  52. data/lib/sass/tree/visitors/convert.rb +2 -3
  53. data/lib/sass/tree/visitors/cssize.rb +4 -15
  54. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  55. data/lib/sass/tree/visitors/extend.rb +2 -8
  56. data/lib/sass/tree/visitors/perform.rb +21 -9
  57. data/lib/sass/tree/visitors/set_options.rb +1 -1
  58. data/lib/sass/tree/visitors/to_css.rb +47 -13
  59. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  60. data/lib/sass/util/normalized_map.rb +1 -8
  61. data/lib/sass/util.rb +12 -290
  62. data/lib/sass/version.rb +0 -2
  63. data/lib/sass.rb +0 -7
  64. data/test/sass/cache_test.rb +0 -1
  65. data/test/sass/callbacks_test.rb +0 -1
  66. data/test/sass/compiler_test.rb +4 -15
  67. data/test/sass/conversion_test.rb +113 -163
  68. data/test/sass/css2sass_test.rb +16 -19
  69. data/test/sass/css_variable_test.rb +176 -71
  70. data/test/sass/encoding_test.rb +2 -33
  71. data/test/sass/engine_test.rb +71 -19
  72. data/test/sass/exec_test.rb +0 -1
  73. data/test/sass/extend_test.rb +37 -92
  74. data/test/sass/functions_test.rb +58 -14
  75. data/test/sass/importer_test.rb +2 -3
  76. data/test/sass/logger_test.rb +0 -1
  77. data/test/sass/plugin_test.rb +6 -10
  78. data/test/sass/results/script.css +1 -1
  79. data/test/sass/results/units.css +2 -2
  80. data/test/sass/script_conversion_test.rb +10 -2
  81. data/test/sass/script_test.rb +22 -24
  82. data/test/sass/scss/css_test.rb +3 -18
  83. data/test/sass/scss/rx_test.rb +0 -1
  84. data/test/sass/scss/scss_test.rb +49 -16
  85. data/test/sass/source_map_test.rb +13 -16
  86. data/test/sass/superselector_test.rb +0 -1
  87. data/test/sass/util/multibyte_string_scanner_test.rb +121 -124
  88. data/test/sass/util/normalized_map_test.rb +0 -1
  89. data/test/sass/util/subset_map_test.rb +0 -1
  90. data/test/sass/util_test.rb +4 -39
  91. data/test/sass/value_helpers_test.rb +0 -1
  92. data/test/sass-spec.yml +1 -1
  93. data/test/test_helper.rb +39 -0
  94. metadata +19 -44
  95. data/lib/sass/script/css_variable_warning.rb +0 -52
  96. data/lib/sass/util/cross_platform_random.rb +0 -19
  97. data/lib/sass/util/ordered_hash.rb +0 -192
  98. data/test/sass/results/import_charset_1_8.css +0 -5
  99. data/test/sass/templates/import_charset_1_8.sass +0 -6
  100. data/vendor/listen/CHANGELOG.md +0 -1
  101. data/vendor/listen/CONTRIBUTING.md +0 -38
  102. data/vendor/listen/Gemfile +0 -20
  103. data/vendor/listen/Guardfile +0 -8
  104. data/vendor/listen/LICENSE +0 -20
  105. data/vendor/listen/README.md +0 -349
  106. data/vendor/listen/Rakefile +0 -5
  107. data/vendor/listen/Vagrantfile +0 -96
  108. data/vendor/listen/lib/listen/adapter.rb +0 -327
  109. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  110. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  111. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  112. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  113. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  114. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  115. data/vendor/listen/lib/listen/listener.rb +0 -323
  116. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  117. data/vendor/listen/lib/listen/version.rb +0 -3
  118. data/vendor/listen/lib/listen.rb +0 -54
  119. data/vendor/listen/listen.gemspec +0 -28
  120. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  121. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  122. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  123. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  124. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  125. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  126. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  127. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  128. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  129. data/vendor/listen/spec/listen_spec.rb +0 -67
  130. data/vendor/listen/spec/spec_helper.rb +0 -25
  131. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  132. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  133. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  134. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  135. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  require File.dirname(__FILE__) + '/../test_helper'
3
2
 
4
3
  class ExtendTest < MiniTest::Test
@@ -152,10 +151,7 @@ SCSS
152
151
  def test_id_unification
153
152
  assert_unification '.foo.bar', '#baz {@extend .foo}', '.foo.bar, .bar#baz'
154
153
  assert_unification '.foo#baz', '#baz {@extend .foo}', '#baz'
155
-
156
- assert_extend_doesnt_match('#bar', '.foo', :failed_to_unify, 2) do
157
- render_unification '.foo#baz', '#bar {@extend .foo}'
158
- end
154
+ assert_unification '.foo#baz', '#bar {@extend .foo}', '.foo#baz'
159
155
  end
160
156
 
161
157
  def test_universal_unification_with_simple_target
@@ -167,10 +163,7 @@ SCSS
167
163
  end
168
164
 
169
165
  def test_universal_unification_with_namespaceless_universal_target
170
- assert_extend_doesnt_match('ns|*', '.foo', :failed_to_unify, 2) do
171
- render_unification '*.foo', 'ns|* {@extend .foo}'
172
- end
173
-
166
+ assert_unification '*.foo', 'ns|* {@extend .foo}', '*.foo'
174
167
  assert_unification '*.foo', '* {@extend .foo}', '*'
175
168
  assert_unification '*.foo', '*|* {@extend .foo}', '*'
176
169
  assert_unification '*|*.foo', '* {@extend .foo}', '*|*.foo, *'
@@ -179,23 +172,14 @@ SCSS
179
172
  end
180
173
 
181
174
  def test_universal_unification_with_namespaced_universal_target
182
- assert_extend_doesnt_match('*', '.foo', :failed_to_unify, 2) do
183
- render_unification 'ns|*.foo', '* {@extend .foo}'
184
- end
185
-
186
- assert_extend_doesnt_match('ns2|*', '.foo', :failed_to_unify, 2) do
187
- render_unification 'ns1|*.foo', 'ns2|* {@extend .foo}'
188
- end
189
-
175
+ assert_unification 'ns|*.foo', '* {@extend .foo}', 'ns|*.foo'
176
+ assert_unification 'ns1|*.foo', 'ns2|* {@extend .foo}', 'ns1|*.foo'
190
177
  assert_unification 'ns|*.foo', '*|* {@extend .foo}', 'ns|*'
191
178
  assert_unification 'ns|*.foo', 'ns|* {@extend .foo}', 'ns|*'
192
179
  end
193
180
 
194
181
  def test_universal_unification_with_namespaceless_element_target
195
- assert_extend_doesnt_match('ns|*', '.foo', :failed_to_unify, 2) do
196
- render_unification 'a.foo', 'ns|* {@extend .foo}'
197
- end
198
-
182
+ assert_unification 'a.foo', 'ns|* {@extend .foo}', 'a.foo'
199
183
  assert_unification 'a.foo', '* {@extend .foo}', 'a'
200
184
  assert_unification 'a.foo', '*|* {@extend .foo}', 'a'
201
185
  assert_unification '*|a.foo', '* {@extend .foo}', '*|a.foo, a'
@@ -204,14 +188,8 @@ SCSS
204
188
  end
205
189
 
206
190
  def test_universal_unification_with_namespaced_element_target
207
- assert_extend_doesnt_match('*', '.foo', :failed_to_unify, 2) do
208
- render_unification 'ns|a.foo', '* {@extend .foo}'
209
- end
210
-
211
- assert_extend_doesnt_match('ns2|*', '.foo', :failed_to_unify, 2) do
212
- render_unification 'ns1|a.foo', 'ns2|* {@extend .foo}'
213
- end
214
-
191
+ assert_unification 'ns|a.foo', '* {@extend .foo}', 'ns|a.foo'
192
+ assert_unification 'ns1|a.foo', 'ns2|* {@extend .foo}', 'ns1|a.foo'
215
193
  assert_unification 'ns|a.foo', '*|* {@extend .foo}', 'ns|a'
216
194
  assert_unification 'ns|a.foo', 'ns|* {@extend .foo}', 'ns|a'
217
195
  end
@@ -224,10 +202,7 @@ SCSS
224
202
  end
225
203
 
226
204
  def test_element_unification_with_namespaceless_universal_target
227
- assert_extend_doesnt_match('ns|a', '.foo', :failed_to_unify, 2) do
228
- render_unification '*.foo', 'ns|a {@extend .foo}'
229
- end
230
-
205
+ assert_unification '*.foo', 'ns|a {@extend .foo}', '*.foo'
231
206
  assert_unification '*.foo', 'a {@extend .foo}', '*.foo, a'
232
207
  assert_unification '*.foo', '*|a {@extend .foo}', '*.foo, a'
233
208
  assert_unification '*|*.foo', 'a {@extend .foo}', '*|*.foo, a'
@@ -236,27 +211,15 @@ SCSS
236
211
  end
237
212
 
238
213
  def test_element_unification_with_namespaced_universal_target
239
- assert_extend_doesnt_match('a', '.foo', :failed_to_unify, 2) do
240
- render_unification 'ns|*.foo', 'a {@extend .foo}'
241
- end
242
-
243
- assert_extend_doesnt_match('ns2|a', '.foo', :failed_to_unify, 2) do
244
- render_unification 'ns1|*.foo', 'ns2|a {@extend .foo}'
245
- end
246
-
214
+ assert_unification 'ns|*.foo', 'a {@extend .foo}', 'ns|*.foo'
215
+ assert_unification 'ns1|*.foo', 'ns2|a {@extend .foo}', 'ns1|*.foo'
247
216
  assert_unification 'ns|*.foo', '*|a {@extend .foo}', 'ns|*.foo, ns|a'
248
217
  assert_unification 'ns|*.foo', 'ns|a {@extend .foo}', 'ns|*.foo, ns|a'
249
218
  end
250
219
 
251
220
  def test_element_unification_with_namespaceless_element_target
252
- assert_extend_doesnt_match('ns|a', '.foo', :failed_to_unify, 2) do
253
- render_unification 'a.foo', 'ns|a {@extend .foo}'
254
- end
255
-
256
- assert_extend_doesnt_match('h1', '.foo', :failed_to_unify, 2) do
257
- render_unification 'a.foo', 'h1 {@extend .foo}'
258
- end
259
-
221
+ assert_unification 'a.foo', 'ns|a {@extend .foo}', 'a.foo'
222
+ assert_unification 'a.foo', 'h1 {@extend .foo}', 'a.foo'
260
223
  assert_unification 'a.foo', 'a {@extend .foo}', 'a'
261
224
  assert_unification 'a.foo', '*|a {@extend .foo}', 'a'
262
225
  assert_unification '*|a.foo', 'a {@extend .foo}', '*|a.foo, a'
@@ -265,14 +228,8 @@ SCSS
265
228
  end
266
229
 
267
230
  def test_element_unification_with_namespaced_element_target
268
- assert_extend_doesnt_match('a', '.foo', :failed_to_unify, 2) do
269
- render_unification 'ns|a.foo', 'a {@extend .foo}'
270
- end
271
-
272
- assert_extend_doesnt_match('ns2|a', '.foo', :failed_to_unify, 2) do
273
- render_unification 'ns1|a.foo', 'ns2|a {@extend .foo}'
274
- end
275
-
231
+ assert_unification 'ns|a.foo', 'a {@extend .foo}', 'ns|a.foo'
232
+ assert_unification 'ns1|a.foo', 'ns2|a {@extend .foo}', 'ns1|a.foo'
276
233
  assert_unification 'ns|a.foo', '*|a {@extend .foo}', 'ns|a'
277
234
  assert_unification 'ns|a.foo', 'ns|a {@extend .foo}', 'ns|a'
278
235
  end
@@ -288,15 +245,8 @@ SCSS
288
245
  def test_pseudo_unification
289
246
  assert_unification ':foo.baz', ':foo(2n+1) {@extend .baz}', ':foo.baz, :foo:foo(2n+1)'
290
247
  assert_unification ':foo.baz', '::foo {@extend .baz}', ':foo.baz, :foo::foo'
291
-
292
- assert_extend_doesnt_match('::bar', '.baz', :failed_to_unify, 2) do
293
- render_unification '::foo.baz', '::bar {@extend .baz}'
294
- end
295
-
296
- assert_extend_doesnt_match('::foo(2n+1)', '.baz', :failed_to_unify, 2) do
297
- render_unification '::foo.baz', '::foo(2n+1) {@extend .baz}'
298
- end
299
-
248
+ assert_unification '::foo.baz', '::bar {@extend .baz}', '::foo.baz'
249
+ assert_unification '::foo.baz', '::foo(2n+1) {@extend .baz}', '::foo.baz'
300
250
  assert_unification '::foo.baz', '::foo {@extend .baz}', '::foo'
301
251
  assert_unification '::foo(2n+1).baz', '::foo(2n+1) {@extend .baz}', '::foo(2n+1)'
302
252
  assert_unification ':foo.baz', ':bar {@extend .baz}', ':foo.baz, :foo:bar'
@@ -315,6 +265,18 @@ SCSS
315
265
  assert_extends 'a.foo:bar', '.baz {@extend .foo}', 'a.foo:bar, a.baz:bar'
316
266
  end
317
267
 
268
+ def test_id_unification_again
269
+ assert_unification('#id.foo .bar', '#id.baz .qux {@extend .bar}',
270
+ '#id.foo .bar, #id.baz.foo .qux')
271
+ end
272
+
273
+ def test_root_unification
274
+ assert_extends(
275
+ ".foo:root .bar",
276
+ ".baz:root .qux {@extend .bar}",
277
+ ".foo:root .bar, .baz.foo:root .qux")
278
+ end
279
+
318
280
  def test_not_remains_at_end_of_selector
319
281
  assert_extends '.foo:not(.bar)', '.baz {@extend .foo}', '.foo:not(.bar), .baz:not(.bar)'
320
282
  end
@@ -606,14 +568,9 @@ WARNING
606
568
  assert_extends 'ns|*.foo.bar', '*|a.baz {@extend .foo}', 'ns|*.foo.bar, ns|a.bar.baz'
607
569
  end
608
570
 
609
- def test_long_extender_aborts_unification
610
- assert_extend_doesnt_match('h1.baz', '.foo', :failed_to_unify, 2) do
611
- render_extends 'a.foo#bar', 'h1.baz {@extend .foo}'
612
- end
613
-
614
- assert_extend_doesnt_match('.bang#baz', '.foo', :failed_to_unify, 2) do
615
- render_extends 'a.foo#bar', '.bang#baz {@extend .foo}'
616
- end
571
+ def test_long_extender_doesnt_unify
572
+ assert_extends 'a.foo#bar', 'h1.baz {@extend .foo}', 'a.foo#bar'
573
+ assert_extends 'a.foo#bar', '.bang#baz {@extend .foo}', 'a.foo#bar'
617
574
  end
618
575
 
619
576
  ## Nested Extenders
@@ -626,10 +583,8 @@ WARNING
626
583
  assert_extends '.foo.bar', 'foo bar {@extend .foo}', '.foo.bar, foo bar.bar'
627
584
  end
628
585
 
629
- def test_nested_extender_aborts_unification
630
- assert_extend_doesnt_match('foo bar', '.foo', :failed_to_unify, 2) do
631
- render_extends 'baz.foo', 'foo bar {@extend .foo}'
632
- end
586
+ def test_nested_extender_doesnt_unify
587
+ assert_extends 'baz.foo', 'foo bar {@extend .foo}', 'baz.foo'
633
588
  end
634
589
 
635
590
  def test_nested_extender_alternates_parents
@@ -1057,13 +1012,14 @@ SCSS
1057
1012
  end
1058
1013
 
1059
1014
  def test_placeholder_selector_as_modifier
1060
- assert_extend_doesnt_match('div', '%foo', :failed_to_unify, 3) do
1061
- render(<<SCSS)
1015
+ assert_equal <<CSS, render(<<SCSS)
1016
+ a.baz.bar {
1017
+ color: blue; }
1018
+ CSS
1062
1019
  a%foo.baz {color: blue}
1063
1020
  .bar {@extend %foo}
1064
1021
  div {@extend %foo}
1065
1022
  SCSS
1066
- end
1067
1023
  end
1068
1024
 
1069
1025
  def test_placeholder_interpolation
@@ -1331,17 +1287,6 @@ ERR
1331
1287
  SCSS
1332
1288
  end
1333
1289
 
1334
- def test_extend_warns_when_extension_fails
1335
- assert_raise_message(Sass::SyntaxError, <<ERR) {render(<<SCSS)}
1336
- "b.foo" failed to @extend ".bar".
1337
- No selectors matching ".bar" could be unified with "b.foo".
1338
- Use "@extend .bar !optional" if the extend should be able to fail.
1339
- ERR
1340
- a.bar {a: b}
1341
- b.foo {@extend .bar}
1342
- SCSS
1343
- end
1344
-
1345
1290
  def test_extend_succeeds_when_one_extension_fails_but_others_dont
1346
1291
  assert_equal(<<CSS, render(<<SCSS))
1347
1292
  a.bar {
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  require 'minitest/autorun'
3
2
  require File.dirname(__FILE__) + '/../test_helper'
4
3
  require File.dirname(__FILE__) + '/test_helper'
@@ -21,7 +20,9 @@ module Sass::Script::Functions
21
20
  declare :only_kw_args, [], :var_kwargs => true
22
21
 
23
22
  def deprecated_arg_fn(arg1, arg2, arg3 = nil)
24
- Sass::Script::Value::List.new([arg1, arg2, arg3 || Sass::Script::Value::Null.new], :space)
23
+ Sass::Script::Value::List.new(
24
+ [arg1, arg2, arg3 || Sass::Script::Value::Null.new],
25
+ separator: :space)
25
26
  end
26
27
  declare :deprecated_arg_fn, [:arg1, :arg2, :arg3], :deprecated => [:arg_1, :arg_2, :arg3]
27
28
  declare :deprecated_arg_fn, [:arg1, :arg2], :deprecated => [:arg_1, :arg_2]
@@ -411,8 +412,8 @@ WARNING
411
412
  assert_equal("rgba(0, 0, 0, 0.3)", evaluate("transparentize(rgba(0, 0, 0, 0.5), 0.2)"))
412
413
  assert_equal("rgba(0, 0, 0, 0.1)", evaluate("transparentize(rgba(0, 0, 0, 0.2), 0.1)"))
413
414
  assert_equal("rgba(0, 0, 0, 0.2)", evaluate("fade-out(rgba(0, 0, 0, 0.5), 0.3px)"))
414
- assert_equal("transparent", evaluate("fade_out(rgba(0, 0, 0, 0.2), 0.2)"))
415
- assert_equal("transparent", evaluate("transparentize(rgba(0, 0, 0, 0.2), 1)"))
415
+ assert_equal("rgba(0, 0, 0, 0)", evaluate("fade_out(rgba(0, 0, 0, 0.2), 0.2)"))
416
+ assert_equal("rgba(0, 0, 0, 0)", evaluate("transparentize(rgba(0, 0, 0, 0.2), 1)"))
416
417
  assert_equal("rgba(0, 0, 0, 0.2)", evaluate("transparentize(rgba(0, 0, 0, 0.2), 0)"))
417
418
  assert_equal("rgba(0, 0, 0, 0.2)", evaluate("transparentize($color: rgba(0, 0, 0, 0.2), $amount: 0)"))
418
419
  assert_equal("rgba(0, 0, 0, 0.2)", evaluate("fade-out($color: rgba(0, 0, 0, 0.2), $amount: 0)"))
@@ -876,12 +877,22 @@ WARNING
876
877
 
877
878
  def test_invert
878
879
  assert_equal("#112233", evaluate("invert(#edc)"))
880
+ assert_equal("#d8cabd", evaluate("invert(#edc, 10%)"))
879
881
  assert_equal("rgba(245, 235, 225, 0.5)", evaluate("invert(rgba(10, 20, 30, 0.5))"))
882
+ assert_equal("rgba(34, 42, 50, 0.5)", evaluate("invert(rgba(10, 20, 30, 0.5), 10%)"))
880
883
  assert_equal("invert(20%)", evaluate("invert(20%)"))
881
884
  end
882
885
 
883
886
  def test_invert_tests_types
884
887
  assert_error_message("$color: \"foo\" is not a color for `invert'", "invert(\"foo\")")
888
+ assert_error_message("$weight: \"foo\" is not a number for `invert'", "invert(#edc, \"foo\")")
889
+ end
890
+
891
+ def test_invert_tests_bounds
892
+ assert_error_message("Weight -0.001 must be between 0% and 100% for `invert'",
893
+ "invert(#edc, -0.001)")
894
+ assert_error_message("Weight 100.001 must be between 0% and 100% for `invert'",
895
+ "invert(#edc, 100.001)")
885
896
  end
886
897
 
887
898
  def test_unquote
@@ -891,6 +902,7 @@ WARNING
891
902
  assert_warning <<MESSAGE do
892
903
  DEPRECATION WARNING: Passing blue, a non-string value, to unquote()
893
904
  will be an error in future versions of Sass.
905
+ on line 1 of test_unquote_inline.scss
894
906
  MESSAGE
895
907
  assert_equal('blue', evaluate('unquote(blue)'))
896
908
  end
@@ -1467,30 +1479,56 @@ SCSS
1467
1479
  end
1468
1480
 
1469
1481
  def test_call_with_positional_arguments
1470
- assert_equal evaluate("lighten(blue, 5%)"), evaluate("call(lighten, blue, 5%)")
1482
+ # TODO: Remove this block in 4.0
1483
+ Sass::Util.silence_sass_warnings do
1484
+ assert_equal evaluate("lighten(blue, 5%)"), evaluate("call(lighten, blue, 5%)")
1485
+ end
1486
+ assert_equal evaluate("lighten(blue, 5%)"), evaluate("call(get-function(lighten), blue, 5%)")
1471
1487
  end
1472
1488
 
1473
1489
  def test_call_with_keyword_arguments
1490
+ # TODO: Remove this block in 4.0
1491
+ Sass::Util.silence_sass_warnings do
1492
+ assert_equal(
1493
+ evaluate("lighten($color: blue, $amount: 5%)"),
1494
+ evaluate("call(lighten, $color: blue, $amount: 5%)"))
1495
+ end
1474
1496
  assert_equal(
1475
1497
  evaluate("lighten($color: blue, $amount: 5%)"),
1476
- evaluate("call(lighten, $color: blue, $amount: 5%)"))
1498
+ evaluate("call(get-function(lighten), $color: blue, $amount: 5%)"))
1477
1499
  end
1478
1500
 
1479
1501
  def test_call_with_keyword_and_positional_arguments
1502
+ # TODO: Remove this block in 4.0
1503
+ Sass::Util.silence_sass_warnings do
1504
+ assert_equal(
1505
+ evaluate("lighten(blue, $amount: 5%)"),
1506
+ evaluate("call(lighten, blue, $amount: 5%)"))
1507
+ end
1480
1508
  assert_equal(
1481
1509
  evaluate("lighten(blue, $amount: 5%)"),
1482
- evaluate("call(lighten, blue, $amount: 5%)"))
1510
+ evaluate("call(get-function(lighten), blue, $amount: 5%)"))
1483
1511
  end
1484
1512
 
1485
1513
  def test_call_with_dynamic_name
1514
+ # TODO: Remove this block in 4.0
1515
+ Sass::Util.silence_sass_warnings do
1516
+ assert_equal(
1517
+ evaluate("lighten($color: blue, $amount: 5%)"),
1518
+ evaluate("call($fn, $color: blue, $amount: 5%)",
1519
+ env("fn" => Sass::Script::Value::String.new("lighten"))))
1520
+ end
1486
1521
  assert_equal(
1487
1522
  evaluate("lighten($color: blue, $amount: 5%)"),
1488
1523
  evaluate("call($fn, $color: blue, $amount: 5%)",
1489
- env("fn" => Sass::Script::String.new("lighten"))))
1524
+ env("fn" => Sass::Script::Value::Function.new(
1525
+ Sass::Callable.new("lighten", nil, nil, nil, nil, nil, "function", :builtin)))))
1490
1526
  end
1491
1527
 
1528
+ # TODO: Remove this test in 4.0
1492
1529
  def test_call_uses_local_scope
1493
- assert_equal <<CSS, render(<<SCSS)
1530
+ Sass::Util.silence_sass_warnings do
1531
+ assert_equal <<CSS, render(<<SCSS)
1494
1532
  .first-scope {
1495
1533
  a: local; }
1496
1534
 
@@ -1508,18 +1546,24 @@ CSS
1508
1546
  a: call(foo);
1509
1547
  }
1510
1548
  SCSS
1549
+ end
1511
1550
  end
1512
1551
 
1513
1552
  def test_call_unknown_function
1514
- assert_equal evaluate("unknown(red, blue)"), evaluate("call(unknown, red, blue)")
1553
+ # TODO: Remove this block in 4.0
1554
+ Sass::Util.silence_sass_warnings do
1555
+ assert_equal evaluate("unknown(red, blue)"), evaluate("call(unknown, red, blue)")
1556
+ end
1557
+ assert_equal evaluate("unknown(red, blue)"), evaluate("call(get-function(unknown, $css: true), red, blue)")
1515
1558
  end
1516
1559
 
1517
1560
  def test_call_with_non_string_argument
1518
- assert_error_message "$name: 3px is not a string for `call'", "call(3px)"
1561
+ assert_error_message "$function: 3px is not a function for `call'", "call(3px)"
1519
1562
  end
1520
1563
 
1521
1564
  def test_errors_in_called_function
1522
- assert_error_message "$color: 3px is not a color for `lighten'", "call(lighten, 3px, 5%)"
1565
+ assert_error_message "$color: 3px is not a color for `lighten'",
1566
+ "call(get-function(lighten), 3px, 5%)"
1523
1567
  end
1524
1568
 
1525
1569
  def test_variable_exists
@@ -1637,7 +1681,7 @@ SCSS
1637
1681
 
1638
1682
  def test_random
1639
1683
  Sass::Script::Functions.random_seed = 1
1640
- assert_equal "0.41702", evaluate("random()")
1684
+ assert_equal "0.4170220047", evaluate("random()")
1641
1685
  assert_equal "13", evaluate("random(100)")
1642
1686
  end
1643
1687
 
@@ -1958,7 +2002,7 @@ WARNING
1958
2002
  end
1959
2003
 
1960
2004
  def perform(value, environment = env)
1961
- Sass::Script::Parser.parse(value, 0, 0).perform(environment)
2005
+ Sass::Script::Parser.parse(value, 1, 0, {:filename => "#{test_name}_inline.scss"}).perform(environment)
1962
2006
  end
1963
2007
 
1964
2008
  def render(sass, options = {})
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  require File.dirname(__FILE__) + '/../test_helper'
3
2
  require File.dirname(__FILE__) + '/test_helper'
4
3
  require 'mock_importer'
@@ -282,7 +281,7 @@ SCSS
282
281
 
283
282
  _, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
284
283
 
285
- uri = Sass::Util.file_uri_from_path(Sass::Util.absolute_path(filename_for_test(:scss)))
284
+ uri = Sass::Util.file_uri_from_path(File.absolute_path(filename_for_test(:scss)))
286
285
  assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri')
287
286
  {
288
287
  "version": 3,
@@ -309,7 +308,7 @@ SCSS
309
308
 
310
309
  _, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
311
310
 
312
- uri = Sass::Util.file_uri_from_path(Sass::Util.absolute_path(filename_for_test(:scss)))
311
+ uri = Sass::Util.file_uri_from_path(File.absolute_path(filename_for_test(:scss)))
313
312
  assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')
314
313
  {
315
314
  "version": 3,
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  require File.dirname(__FILE__) + '/../test_helper'
3
2
  require 'pathname'
4
3
 
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  require File.dirname(__FILE__) + '/../test_helper'
3
2
  require File.dirname(__FILE__) + '/test_helper'
4
3
  require 'sass/plugin'
@@ -21,10 +20,9 @@ class SassPluginTest < MiniTest::Test
21
20
  @@templates = %w{
22
21
  complex script parent_ref import scss_import alt
23
22
  subdir/subdir subdir/nested_subdir/nested_subdir
24
- options import_content filename_fn
23
+ options import_content filename_fn import_charset
24
+ import_charset_ibm866
25
25
  }
26
- @@templates += %w[import_charset import_charset_ibm866] unless Sass::Util.ruby1_8?
27
- @@templates << 'import_charset_1_8' if Sass::Util.ruby1_8?
28
26
 
29
27
  @@cache_store = Sass::CacheStores::Memory.new
30
28
 
@@ -396,15 +394,13 @@ WARNING
396
394
 
397
395
  expected_str = File.read(result_loc(result_name, prefix))
398
396
  actual_str = File.read(tempfile_loc(tempfile_name, prefix))
399
- unless Sass::Util.ruby1_8?
400
- expected_str = expected_str.force_encoding('IBM866') if result_name == 'import_charset_ibm866'
401
- actual_str = actual_str.force_encoding('IBM866') if tempfile_name == 'import_charset_ibm866'
402
- end
397
+ expected_str = expected_str.force_encoding('IBM866') if result_name == 'import_charset_ibm866'
398
+ actual_str = actual_str.force_encoding('IBM866') if tempfile_name == 'import_charset_ibm866'
403
399
  expected_lines = expected_str.split("\n")
404
400
  actual_lines = actual_str.split("\n")
405
401
 
406
402
  if actual_lines.first == "/*" && expected_lines.first != "/*"
407
- assert(false, actual_lines[0..Sass::Util.enum_with_index(actual_lines).find {|l, i| l == "*/"}.last].join("\n"))
403
+ assert(false, actual_lines[0..actual_lines.each_with_index.find {|l, i| l == "*/"}.last].join("\n"))
408
404
  end
409
405
 
410
406
  expected_lines.zip(actual_lines).each_with_index do |pair, line|
@@ -423,7 +419,7 @@ WARNING
423
419
  expected_lines = File.read(result_loc(name)).split("\n")
424
420
  actual_lines = File.read(tempfile_loc(name)).split("\n")
425
421
  if actual_lines.first == "/*" && expected_lines.first != "/*"
426
- assert(false, actual_lines[0..actual_lines.enum_with_index.find {|l, i| l == "*/"}.last].join("\n"))
422
+ assert(false, actual_lines[0..actual_lines.each_with_index.find {|l, i| l == "*/"}.last].join("\n"))
427
423
  end
428
424
  end
429
425
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  #times { num-num: 7; num-col: #7496b8; col-num: #092345; col-col: #243648; }
9
9
 
10
- #div { num-num: 3.33333; num-num2: 3.33333; col-num: #092345; col-col: #0b0e10; comp: 1px; }
10
+ #div { num-num: 3.3333333333; num-num2: 3.3333333333; col-num: #092345; col-col: #0b0e10; comp: 1px; }
11
11
 
12
12
  #mod { num-num: 2; col-col: #0f0e05; col-num: #020001; }
13
13
 
@@ -1,11 +1,11 @@
1
1
  b {
2
2
  foo: 5px;
3
3
  bar: 24px;
4
- baz: 66.66667%;
4
+ baz: 66.6666666667%;
5
5
  many-units: 32em;
6
6
  mm: 15mm;
7
7
  pc: 2pc;
8
8
  pt: -72pt;
9
9
  inches: 2in;
10
10
  more-inches: 3.5in;
11
- mixed: 2.04167in; }
11
+ mixed: 2.0416666667in; }
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  # -*- coding: utf-8 -*-
3
2
  require File.dirname(__FILE__) + '/../test_helper'
4
3
  require 'sass/engine'
@@ -23,7 +22,7 @@ class SassScriptConversionTest < MiniTest::Test
23
22
  assert_renders "12px"
24
23
  assert_renders "12.45px"
25
24
 
26
- assert_equal "12.34568", render("12.345678901")
25
+ assert_equal "12.3456789013", render("12.34567890129")
27
26
  end
28
27
 
29
28
  def test_string
@@ -343,6 +342,15 @@ RUBY
343
342
  assert_equal '"foo#{$bar}baz"', render("'foo\#{$bar}baz'")
344
343
  end
345
344
 
345
+ def test_bracketed_lists
346
+ assert_renders("[]")
347
+ assert_renders("[foo, bar]")
348
+ assert_renders("[[foo]]")
349
+ assert_renders("[(foo bar)]")
350
+ assert_renders("[foo bar,]")
351
+ assert_renders("[(foo,)]")
352
+ end
353
+
346
354
  private
347
355
 
348
356
  def assert_renders(script, options = {})
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  # -*- coding: utf-8 -*-
3
2
  require File.dirname(__FILE__) + '/../test_helper'
4
3
  require 'sass/engine'
@@ -80,7 +79,7 @@ class SassScriptTest < MiniTest::Test
80
79
  assert_equal "#ffffff", resolve("#ffffff")
81
80
  silence_warnings {assert_equal "#fffffe", resolve("white - #000001")}
82
81
  assert_equal "transparent", resolve("transparent")
83
- assert_equal "transparent", resolve("rgba(0, 0, 0, 0)")
82
+ assert_equal "rgba(0, 0, 0, 0)", resolve("rgba(0, 0, 0, 0)")
84
83
  end
85
84
 
86
85
  def test_rgba_color_literals
@@ -117,7 +116,7 @@ class SassScriptTest < MiniTest::Test
117
116
  end
118
117
 
119
118
  def test_rgba_rounding
120
- assert_equal "rgba(10, 1, 0, 0.12346)", resolve("rgba(10.0, 1.23456789, 0.0, 0.1234567)")
119
+ assert_equal "rgba(10, 1, 0, 0.1234567892)", resolve("rgba(10.0, 1.23456789, 0.0, 0.12345678919)")
121
120
  end
122
121
 
123
122
  def test_rgb_calc
@@ -284,10 +283,10 @@ SASS
284
283
  end
285
284
 
286
285
  def test_adding_functions_directly_to_functions_module
287
- assert !Functions.callable?('nonexistant')
288
- Functions.class_eval { def nonexistant; end }
289
- assert Functions.callable?('nonexistant')
290
- Functions.send :remove_method, :nonexistant
286
+ assert !Functions.callable?('nonexistent')
287
+ Functions.class_eval { def nonexistent; end }
288
+ assert Functions.callable?('nonexistent')
289
+ Functions.send :remove_method, :nonexistent
291
290
  end
292
291
 
293
292
  def test_default_functions
@@ -535,19 +534,19 @@ WARNING
535
534
 
536
535
  def test_length_units
537
536
  assert_equal "2.54", resolve("(1in/1cm)")
538
- assert_equal "2.3622", resolve("(1cm/1pc)")
539
- assert_equal "4.23333", resolve("(1pc/1mm)")
540
- assert_equal "2.83465", resolve("(1mm/1pt)")
541
- assert_equal "1.33333", resolve("(1pt/1px)")
542
- assert_equal "0.01042", resolve("(1px/1in)")
543
- assert_equal "1.05833", resolve("(1px/1q)")
544
- assert_equal "0.05906", resolve("(1q/1pc)")
537
+ assert_equal "2.3622047244", resolve("(1cm/1pc)")
538
+ assert_equal "4.2333333333", resolve("(1pc/1mm)")
539
+ assert_equal "2.8346456693", resolve("(1mm/1pt)")
540
+ assert_equal "1.3333333333", resolve("(1pt/1px)")
541
+ assert_equal "0.0104166667", resolve("(1px/1in)")
542
+ assert_equal "1.0583333333", resolve("(1px/1q)")
543
+ assert_equal "0.0590551181", resolve("(1q/1pc)")
545
544
  end
546
545
 
547
546
  def test_angle_units
548
- assert_equal "1.11111", resolve("(1deg/1grad)")
549
- assert_equal "0.01571", resolve("(1grad/1rad)")
550
- assert_equal "0.15915", resolve("(1rad/1turn)")
547
+ assert_equal "1.1111111111", resolve("(1deg/1grad)")
548
+ assert_equal "0.0157079633", resolve("(1grad/1rad)")
549
+ assert_equal "0.1591549431", resolve("(1rad/1turn)")
551
550
  assert_equal "360", resolve("(1turn/1deg)")
552
551
  end
553
552
 
@@ -560,8 +559,8 @@ WARNING
560
559
  end
561
560
 
562
561
  def test_resolution_units
563
- assert_equal "0.3937", resolve("(1dpi/1dpcm)")
564
- assert_equal "0.02646", resolve("(1dpcm/1dppx)")
562
+ assert_equal "0.3937007874", resolve("(1dpi/1dpcm)")
563
+ assert_equal "0.0264583333", resolve("(1dpcm/1dppx)")
565
564
  assert_equal "96", resolve("(1dppx/1dpi)")
566
565
  end
567
566
 
@@ -1134,9 +1133,8 @@ SASS
1134
1133
  assert_equal "#2", resolve('"##{1 + 1}"')
1135
1134
  end
1136
1135
 
1137
- def test_misplaced_comma_in_funcall
1138
- assert_raise_message(Sass::SyntaxError,
1139
- 'Invalid CSS after "foo(bar, ": expected function argument, was ")"') {eval('foo(bar, )')}
1136
+ def test_func_call_arglist_trailing_comma
1137
+ assert_equal eval('foo(bar)'), eval('foo(bar, )')
1140
1138
  end
1141
1139
 
1142
1140
  def test_color_prefixed_identifier
@@ -1178,8 +1176,8 @@ SASS
1178
1176
  assert_equal "1", resolve("1.0")
1179
1177
  assert_equal "1000000000", resolve("1000000000")
1180
1178
  assert_equal "0.00001", resolve("0.00001")
1181
- assert_equal "1.12121", resolve("1.121214")
1182
- assert_equal "1.12122", resolve("1.121215")
1179
+ assert_equal "1.1212121212", resolve("1.12121212124")
1180
+ assert_equal "1.1212121213", resolve("1.12121212125")
1183
1181
  assert_equal "Infinity", resolve("(1.0/0.0)")
1184
1182
  assert_equal "-Infinity", resolve("(-1.0/0.0)")
1185
1183
  assert_equal "NaN", resolve("(0.0/0.0)")
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  # -*- coding: utf-8 -*-
3
2
  require File.dirname(__FILE__) + '/test_helper'
4
3
  require 'sass/scss/css_parser'
@@ -49,26 +48,13 @@ baz {bar: baz}
49
48
  SCSS
50
49
  end
51
50
 
52
- if Sass::Util.ruby1_8?
53
- def test_unicode
54
- assert_parses <<SCSS
55
- @charset "UTF-8";
56
- foo {
57
- bar: föö bâr; }
58
- SCSS
59
- assert_parses <<SCSS
60
- foo {
61
- bar: föö bâr; }
62
- SCSS
63
- end
64
- else
65
- def test_unicode
66
- assert_parses <<SCSS
51
+ def test_unicode
52
+ assert_parses <<SCSS
67
53
  @charset "UTF-8";
68
54
  foo {
69
55
  bar: föö bâr; }
70
56
  SCSS
71
- assert_equal <<CSS, render(<<SCSS)
57
+ assert_equal <<CSS, render(<<SCSS)
72
58
  @charset "UTF-8";
73
59
  foo {
74
60
  bar: föö bâr; }
@@ -76,7 +62,6 @@ CSS
76
62
  foo {
77
63
  bar: föö bâr; }
78
64
  SCSS
79
- end
80
65
  end
81
66
 
82
67
  def test_invisible_comments