sass 3.3.0 → 3.4.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +58 -50
  4. data/Rakefile +1 -4
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/bin/sass +1 -1
  9. data/bin/scss +1 -1
  10. data/lib/sass/cache_stores/filesystem.rb +6 -2
  11. data/lib/sass/css.rb +1 -3
  12. data/lib/sass/engine.rb +37 -46
  13. data/lib/sass/environment.rb +13 -17
  14. data/lib/sass/error.rb +6 -9
  15. data/lib/sass/exec/base.rb +187 -0
  16. data/lib/sass/exec/sass_convert.rb +264 -0
  17. data/lib/sass/exec/sass_scss.rb +424 -0
  18. data/lib/sass/exec.rb +5 -771
  19. data/lib/sass/features.rb +7 -0
  20. data/lib/sass/importers/base.rb +7 -2
  21. data/lib/sass/importers/filesystem.rb +9 -25
  22. data/lib/sass/importers.rb +0 -1
  23. data/lib/sass/media.rb +1 -4
  24. data/lib/sass/plugin/compiler.rb +200 -83
  25. data/lib/sass/plugin/staleness_checker.rb +1 -1
  26. data/lib/sass/plugin.rb +3 -3
  27. data/lib/sass/script/css_lexer.rb +1 -1
  28. data/lib/sass/script/functions.rb +622 -268
  29. data/lib/sass/script/lexer.rb +99 -34
  30. data/lib/sass/script/parser.rb +24 -23
  31. data/lib/sass/script/tree/funcall.rb +1 -1
  32. data/lib/sass/script/tree/interpolation.rb +20 -2
  33. data/lib/sass/script/tree/selector.rb +26 -0
  34. data/lib/sass/script/tree/string_interpolation.rb +1 -1
  35. data/lib/sass/script/tree.rb +1 -0
  36. data/lib/sass/script/value/base.rb +7 -5
  37. data/lib/sass/script/value/bool.rb +0 -5
  38. data/lib/sass/script/value/color.rb +39 -21
  39. data/lib/sass/script/value/helpers.rb +107 -0
  40. data/lib/sass/script/value/list.rb +0 -15
  41. data/lib/sass/script/value/null.rb +0 -5
  42. data/lib/sass/script/value/number.rb +62 -14
  43. data/lib/sass/script/value/string.rb +59 -11
  44. data/lib/sass/script/value.rb +0 -1
  45. data/lib/sass/scss/css_parser.rb +8 -2
  46. data/lib/sass/scss/parser.rb +190 -328
  47. data/lib/sass/scss/rx.rb +15 -6
  48. data/lib/sass/scss/static_parser.rb +298 -1
  49. data/lib/sass/selector/abstract_sequence.rb +28 -13
  50. data/lib/sass/selector/comma_sequence.rb +92 -13
  51. data/lib/sass/selector/pseudo.rb +256 -0
  52. data/lib/sass/selector/sequence.rb +94 -24
  53. data/lib/sass/selector/simple.rb +14 -25
  54. data/lib/sass/selector/simple_sequence.rb +97 -33
  55. data/lib/sass/selector.rb +57 -194
  56. data/lib/sass/shared.rb +1 -1
  57. data/lib/sass/source/map.rb +26 -12
  58. data/lib/sass/stack.rb +0 -6
  59. data/lib/sass/supports.rb +2 -3
  60. data/lib/sass/tree/at_root_node.rb +1 -0
  61. data/lib/sass/tree/charset_node.rb +1 -1
  62. data/lib/sass/tree/directive_node.rb +8 -2
  63. data/lib/sass/tree/error_node.rb +18 -0
  64. data/lib/sass/tree/extend_node.rb +1 -1
  65. data/lib/sass/tree/function_node.rb +4 -0
  66. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  67. data/lib/sass/tree/prop_node.rb +1 -1
  68. data/lib/sass/tree/rule_node.rb +12 -7
  69. data/lib/sass/tree/visitors/check_nesting.rb +38 -10
  70. data/lib/sass/tree/visitors/convert.rb +16 -18
  71. data/lib/sass/tree/visitors/cssize.rb +29 -29
  72. data/lib/sass/tree/visitors/deep_copy.rb +5 -0
  73. data/lib/sass/tree/visitors/perform.rb +45 -33
  74. data/lib/sass/tree/visitors/set_options.rb +14 -0
  75. data/lib/sass/tree/visitors/to_css.rb +15 -14
  76. data/lib/sass/util/subset_map.rb +1 -1
  77. data/lib/sass/util.rb +222 -99
  78. data/lib/sass/version.rb +5 -5
  79. data/lib/sass.rb +0 -5
  80. data/test/sass/cache_test.rb +62 -20
  81. data/test/sass/callbacks_test.rb +1 -1
  82. data/test/sass/compiler_test.rb +19 -10
  83. data/test/sass/conversion_test.rb +58 -1
  84. data/test/sass/css2sass_test.rb +23 -4
  85. data/test/sass/encoding_test.rb +219 -0
  86. data/test/sass/engine_test.rb +136 -199
  87. data/test/sass/exec_test.rb +2 -2
  88. data/test/sass/extend_test.rb +236 -19
  89. data/test/sass/functions_test.rb +295 -253
  90. data/test/sass/importer_test.rb +31 -21
  91. data/test/sass/logger_test.rb +1 -1
  92. data/test/sass/more_results/more_import.css +1 -1
  93. data/test/sass/plugin_test.rb +14 -13
  94. data/test/sass/results/compact.css +1 -1
  95. data/test/sass/results/complex.css +4 -4
  96. data/test/sass/results/expanded.css +1 -1
  97. data/test/sass/results/import.css +1 -1
  98. data/test/sass/results/import_charset_ibm866.css +2 -2
  99. data/test/sass/results/mixins.css +17 -17
  100. data/test/sass/results/nested.css +1 -1
  101. data/test/sass/results/parent_ref.css +2 -2
  102. data/test/sass/results/script.css +3 -3
  103. data/test/sass/results/scss_import.css +1 -1
  104. data/test/sass/script_conversion_test.rb +10 -7
  105. data/test/sass/script_test.rb +288 -74
  106. data/test/sass/scss/css_test.rb +141 -24
  107. data/test/sass/scss/rx_test.rb +4 -4
  108. data/test/sass/scss/scss_test.rb +457 -18
  109. data/test/sass/source_map_test.rb +115 -25
  110. data/test/sass/superselector_test.rb +191 -0
  111. data/test/sass/templates/scss_import.scss +2 -1
  112. data/test/sass/test_helper.rb +1 -1
  113. data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
  114. data/test/sass/util/normalized_map_test.rb +1 -1
  115. data/test/sass/util/subset_map_test.rb +2 -2
  116. data/test/sass/util_test.rb +31 -1
  117. data/test/sass/value_helpers_test.rb +5 -7
  118. data/test/test_helper.rb +2 -2
  119. data/vendor/listen/CHANGELOG.md +1 -228
  120. data/vendor/listen/Gemfile +5 -15
  121. data/vendor/listen/README.md +111 -77
  122. data/vendor/listen/Rakefile +0 -42
  123. data/vendor/listen/lib/listen/adapter.rb +195 -82
  124. data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
  125. data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
  126. data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
  127. data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
  128. data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
  129. data/vendor/listen/lib/listen/directory_record.rb +96 -61
  130. data/vendor/listen/lib/listen/listener.rb +135 -37
  131. data/vendor/listen/lib/listen/turnstile.rb +9 -5
  132. data/vendor/listen/lib/listen/version.rb +1 -1
  133. data/vendor/listen/lib/listen.rb +33 -19
  134. data/vendor/listen/listen.gemspec +6 -0
  135. data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
  136. data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
  137. data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
  138. data/vendor/listen/spec/listen/listener_spec.rb +128 -39
  139. data/vendor/listen/spec/listen_spec.rb +15 -21
  140. data/vendor/listen/spec/spec_helper.rb +4 -0
  141. data/vendor/listen/spec/support/adapter_helper.rb +52 -15
  142. data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
  143. data/vendor/listen/spec/support/listeners_helper.rb +30 -7
  144. metadata +25 -22
  145. data/ext/mkrf_conf.rb +0 -27
  146. data/lib/sass/importers/deprecated_path.rb +0 -51
  147. data/lib/sass/script/value/deprecated_false.rb +0 -55
  148. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  149. data/vendor/listen/lib/listen/multi_listener.rb +0 -143
  150. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
  151. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require File.dirname(__FILE__) + '/../test_helper'
4
4
  require File.dirname(__FILE__) + '/test_helper'
5
5
  require 'sass/script'
@@ -19,6 +19,12 @@ module Sass::Script::Functions
19
19
  Sass::Script::Value::String.new("only-kw-args(" + kwargs.keys.map {|a| a.to_s}.sort.join(", ") + ")")
20
20
  end
21
21
  declare :only_kw_args, [], :var_kwargs => true
22
+
23
+ def deprecated_arg_fn(arg1, arg2, arg3 = nil)
24
+ Sass::Script::Value::List.new([arg1, arg2, arg3 || Sass::Script::Value::Null.new], :space)
25
+ end
26
+ declare :deprecated_arg_fn, [:arg1, :arg2, :arg3], :deprecated => [:arg_1, :arg_2, :arg3]
27
+ declare :deprecated_arg_fn, [:arg1, :arg2], :deprecated => [:arg_1, :arg_2]
22
28
  end
23
29
 
24
30
  module Sass::Script::Functions::UserFunctions
@@ -45,7 +51,7 @@ module Sass::Script::Functions
45
51
  include Sass::Script::Functions::UserFunctions
46
52
  end
47
53
 
48
- class SassFunctionTest < Test::Unit::TestCase
54
+ class SassFunctionTest < MiniTest::Test
49
55
  # Tests taken from:
50
56
  # http://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-h-rotating-b.htm
51
57
  # http://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-values-b.htm
@@ -84,9 +90,9 @@ class SassFunctionTest < Test::Unit::TestCase
84
90
  assert_equal "#33cccc", evaluate("hsl($hue: 180, $saturation: 60%, $lightness: 50%)")
85
91
  end
86
92
 
87
- def test_hsl_checks_bounds
88
- assert_error_message("Saturation -114 must be between 0% and 100% for `hsl'", "hsl(10, -114, 12)");
89
- assert_error_message("Lightness 256% must be between 0% and 100% for `hsl'", "hsl(10, 10, 256%)");
93
+ def test_hsl_clamps_bounds
94
+ assert_equal("#1f1f1f", evaluate("hsl(10, -114, 12)"))
95
+ assert_equal("white", evaluate("hsl(10, 10, 256%)"))
90
96
  end
91
97
 
92
98
  def test_hsl_checks_types
@@ -102,11 +108,11 @@ class SassFunctionTest < Test::Unit::TestCase
102
108
  assert_equal "rgba(51, 204, 204, 0.4)", evaluate("hsla($hue: 180, $saturation: 60%, $lightness: 50%, $alpha: 0.4)")
103
109
  end
104
110
 
105
- def test_hsla_checks_bounds
106
- assert_error_message("Saturation -114 must be between 0% and 100% for `hsla'", "hsla(10, -114, 12, 1)");
107
- assert_error_message("Lightness 256% must be between 0% and 100% for `hsla'", "hsla(10, 10, 256%, 0)");
108
- assert_error_message("Alpha channel -0.1 must be between 0 and 1 for `hsla'", "hsla(10, 10, 10, -0.1)");
109
- assert_error_message("Alpha channel 1.1 must be between 0 and 1 for `hsla'", "hsla(10, 10, 10, 1.1)");
111
+ def test_hsla_clamps_bounds
112
+ assert_equal("#1f1f1f", evaluate("hsla(10, -114, 12, 1)"))
113
+ assert_equal("rgba(255, 255, 255, 0)", evaluate("hsla(10, 10, 256%, 0)"))
114
+ assert_equal("rgba(28, 24, 23, 0)", evaluate("hsla(10, 10, 10, -0.1)"))
115
+ assert_equal("#1c1817", evaluate("hsla(10, 10, 10, 1.1)"))
110
116
  end
111
117
 
112
118
  def test_hsla_checks_types
@@ -123,12 +129,6 @@ class SassFunctionTest < Test::Unit::TestCase
123
129
  assert_equal("50%", evaluate("percentage($number: 0.5)"))
124
130
  end
125
131
 
126
- def test_percentage_deprecated_arg_name
127
- assert_warning(<<WARNING) {assert_equal("50%", evaluate("percentage($value: 0.5)"))}
128
- DEPRECATION WARNING: The `$value' argument for `percentage()' has been renamed to `$number'.
129
- WARNING
130
- end
131
-
132
132
  def test_percentage_checks_types
133
133
  assert_error_message("$number: 25px is not a unitless number for `percentage'", "percentage(25px)")
134
134
  assert_error_message("$number: #cccccc is not a unitless number for `percentage'", "percentage(#ccc)")
@@ -142,12 +142,6 @@ WARNING
142
142
  assert_equal("5px", evaluate("round($number: 5.49px)"))
143
143
  end
144
144
 
145
- def test_round_deprecated_arg_name
146
- assert_warning(<<WARNING) {assert_equal("5px", evaluate("round($value: 5.49px)"))}
147
- DEPRECATION WARNING: The `$value' argument for `round()' has been renamed to `$number'.
148
- WARNING
149
- end
150
-
151
145
  def test_round_checks_types
152
146
  assert_error_message("$value: #cccccc is not a number for `round'", "round(#ccc)")
153
147
  end
@@ -158,12 +152,6 @@ WARNING
158
152
  assert_equal("4px", evaluate("floor($number: 4.8px)"))
159
153
  end
160
154
 
161
- def test_floor_deprecated_arg_name
162
- assert_warning(<<WARNING) {assert_equal("4px", evaluate("floor($value: 4.8px)"))}
163
- DEPRECATION WARNING: The `$value' argument for `floor()' has been renamed to `$number'.
164
- WARNING
165
- end
166
-
167
155
  def test_floor_checks_types
168
156
  assert_error_message("$value: \"foo\" is not a number for `floor'", "floor(\"foo\")")
169
157
  end
@@ -174,12 +162,6 @@ WARNING
174
162
  assert_equal("5px", evaluate("ceil($number: 4.8px)"))
175
163
  end
176
164
 
177
- def test_ceil_deprecated_arg_name
178
- assert_warning(<<WARNING) {assert_equal("5px", evaluate("ceil($value: 4.8px)"))}
179
- DEPRECATION WARNING: The `$value' argument for `ceil()' has been renamed to `$number'.
180
- WARNING
181
- end
182
-
183
165
  def test_ceil_checks_types
184
166
  assert_error_message("$value: \"a\" is not a number for `ceil'", "ceil(\"a\")")
185
167
  end
@@ -192,12 +174,6 @@ WARNING
192
174
  assert_equal("5px", evaluate("abs($number: 5px)"))
193
175
  end
194
176
 
195
- def test_abs_deprecated_arg_name
196
- assert_warning(<<WARNING) {assert_equal("5px", evaluate("abs($value: 5px)"))}
197
- DEPRECATION WARNING: The `$value' argument for `abs()' has been renamed to `$number'.
198
- WARNING
199
- end
200
-
201
177
  def test_abs_checks_types
202
178
  assert_error_message("$value: #aaaaaa is not a number for `abs'", "abs(#aaa)")
203
179
  end
@@ -236,26 +212,18 @@ WARNING
236
212
  assert_equal("springgreen", evaluate("rgb(0%, 100%, 50%)"))
237
213
  end
238
214
 
239
- def test_rgb_tests_bounds
240
- assert_error_message("$red: Color value 256 must be between 0 and 255 for `rgb'",
241
- "rgb(256, 1, 1)")
242
- assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgb'",
243
- "rgb(1, 256, 1)")
244
- assert_error_message("$blue: Color value 256 must be between 0 and 255 for `rgb'",
245
- "rgb(1, 1, 256)")
246
- assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgb'",
247
- "rgb(1, 256, 257)")
248
- assert_error_message("$red: Color value -1 must be between 0 and 255 for `rgb'",
249
- "rgb(-1, 1, 1)")
215
+ def test_rgb_clamps_bounds
216
+ assert_equal("#ff0101", evaluate("rgb(256, 1, 1)"))
217
+ assert_equal("#01ff01", evaluate("rgb(1, 256, 1)"))
218
+ assert_equal("#0101ff", evaluate("rgb(1, 1, 256)"))
219
+ assert_equal("#01ffff", evaluate("rgb(1, 256, 257)"))
220
+ assert_equal("#000101", evaluate("rgb(-1, 1, 1)"))
250
221
  end
251
222
 
252
- def test_rgb_test_percent_bounds
253
- assert_error_message("$red: Color value 100.1% must be between 0% and 100% for `rgb'",
254
- "rgb(100.1%, 0, 0)")
255
- assert_error_message("$green: Color value -0.1% must be between 0% and 100% for `rgb'",
256
- "rgb(0, -0.1%, 0)")
257
- assert_error_message("$blue: Color value 101% must be between 0% and 100% for `rgb'",
258
- "rgb(0, 0, 101%)")
223
+ def test_rgb_clamps_percent_bounds
224
+ assert_equal("red", evaluate("rgb(100.1%, 0, 0)"))
225
+ assert_equal("black", evaluate("rgb(0, -0.1%, 0)"))
226
+ assert_equal("blue", evaluate("rgb(0, 0, 101%)"))
259
227
  end
260
228
 
261
229
  def test_rgb_tests_types
@@ -271,21 +239,14 @@ WARNING
271
239
  assert_equal("rgba(0, 255, 127, 0)", evaluate("rgba($red: 0, $green: 255, $blue: 127, $alpha: 0)"))
272
240
  end
273
241
 
274
- def test_rgba_tests_bounds
275
- assert_error_message("$red: Color value 256 must be between 0 and 255 for `rgba'",
276
- "rgba(256, 1, 1, 0.3)")
277
- assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgba'",
278
- "rgba(1, 256, 1, 0.3)")
279
- assert_error_message("$blue: Color value 256 must be between 0 and 255 for `rgba'",
280
- "rgba(1, 1, 256, 0.3)")
281
- assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgba'",
282
- "rgba(1, 256, 257, 0.3)")
283
- assert_error_message("$red: Color value -1 must be between 0 and 255 for `rgba'",
284
- "rgba(-1, 1, 1, 0.3)")
285
- assert_error_message("Alpha channel -0.2 must be between 0 and 1 for `rgba'",
286
- "rgba(1, 1, 1, -0.2)")
287
- assert_error_message("Alpha channel 1.2 must be between 0 and 1 for `rgba'",
288
- "rgba(1, 1, 1, 1.2)")
242
+ def test_rgba_clamps_bounds
243
+ assert_equal("rgba(255, 1, 1, 0.3)", evaluate("rgba(256, 1, 1, 0.3)"))
244
+ assert_equal("rgba(1, 255, 1, 0.3)", evaluate("rgba(1, 256, 1, 0.3)"))
245
+ assert_equal("rgba(1, 1, 255, 0.3)", evaluate("rgba(1, 1, 256, 0.3)"))
246
+ assert_equal("rgba(1, 255, 255, 0.3)", evaluate("rgba(1, 256, 257, 0.3)"))
247
+ assert_equal("rgba(0, 1, 1, 0.3)", evaluate("rgba(-1, 1, 1, 0.3)"))
248
+ assert_equal("rgba(1, 1, 1, 0)", evaluate("rgba(1, 1, 1, -0.2)"))
249
+ assert_equal("#010101", evaluate("rgba(1, 1, 1, 1.2)"))
289
250
  end
290
251
 
291
252
  def test_rgba_tests_types
@@ -840,32 +801,6 @@ WARNING
840
801
  assert_equal("rgba(255, 0, 0, 0)", evaluate("mix($color1: transparentize(#f00, 1), $color2: #00f, $weight: 100%)"))
841
802
  end
842
803
 
843
- def test_mix_deprecated_arg_name
844
- assert_warning <<WARNING do
845
- DEPRECATION WARNING: The `$color-1' argument for `mix()' has been renamed to `$color1'.
846
- DEPRECATION WARNING: The `$color-2' argument for `mix()' has been renamed to `$color2'.
847
- WARNING
848
- assert_equal("rgba(255, 0, 0, 0)",
849
- evaluate("mix($color-1: transparentize(#f00, 1), $color-2: #00f, $weight: 100%)"))
850
- end
851
-
852
- assert_warning <<WARNING do
853
- DEPRECATION WARNING: The `$color-1' argument for `mix()' has been renamed to `$color1'.
854
- DEPRECATION WARNING: The `$color-2' argument for `mix()' has been renamed to `$color2'.
855
- WARNING
856
- assert_equal("rgba(0, 0, 255, 0.5)",
857
- evaluate("mix($color-1: transparentize(#f00, 1), $color-2: #00f)"))
858
- end
859
-
860
- assert_warning <<WARNING do
861
- DEPRECATION WARNING: The `$color_1' argument for `mix()' has been renamed to `$color1'.
862
- DEPRECATION WARNING: The `$color_2' argument for `mix()' has been renamed to `$color2'.
863
- WARNING
864
- assert_equal("rgba(0, 0, 255, 0.5)",
865
- evaluate("mix($color_1: transparentize(#f00, 1), $color_2: #00f)"))
866
- end
867
- end
868
-
869
804
  def test_mix_tests_types
870
805
  assert_error_message("$color1: \"foo\" is not a color for `mix'", "mix(\"foo\", #f00, 10%)")
871
806
  assert_error_message("$color2: \"foo\" is not a color for `mix'", "mix(#f00, \"foo\", 10%)")
@@ -995,6 +930,7 @@ WARNING
995
930
  assert_equal('ab', evaluate('str-slice(abcd,1,2)')) # for completeness
996
931
  assert_equal('abcd', evaluate('str-slice(abcd,1,4)')) # at the end points
997
932
  assert_equal('abcd', evaluate('str-slice(abcd,0,4)')) # when start is before the start of the string
933
+ assert_equal('', evaluate('str-slice(abcd,1,0)')) # when end is before the start of the string
998
934
  assert_equal('abcd', evaluate('str-slice(abcd,1,100)')) # when end is past the end of the string
999
935
  assert_equal('', evaluate('str-slice(abcd,2,1)')) # when end is before start
1000
936
  assert_equal('"bc"', evaluate('str-slice("abcd",2,3)')) # when used with a quoted string
@@ -1084,22 +1020,6 @@ MSG
1084
1020
  assert_equal(%Q{false}, evaluate("comparable($number1: 100px, $number2: 3em)"))
1085
1021
  end
1086
1022
 
1087
- def test_comparable_deprecated_arg_name
1088
- assert_warning <<WARNING do
1089
- DEPRECATION WARNING: The `$number-1' argument for `comparable()' has been renamed to `$number1'.
1090
- DEPRECATION WARNING: The `$number-2' argument for `comparable()' has been renamed to `$number2'.
1091
- WARNING
1092
- assert_equal("false", evaluate("comparable($number-1: 100px, $number-2: 3em)"))
1093
- end
1094
-
1095
- assert_warning <<WARNING do
1096
- DEPRECATION WARNING: The `$number_1' argument for `comparable()' has been renamed to `$number1'.
1097
- DEPRECATION WARNING: The `$number_2' argument for `comparable()' has been renamed to `$number2'.
1098
- WARNING
1099
- assert_equal("false", evaluate("comparable($number_1: 100px, $number_2: 3em)"))
1100
- end
1101
- end
1102
-
1103
1023
  def test_comparable_checks_types
1104
1024
  assert_error_message("$number1: #ff0000 is not a number for `comparable'", "comparable(#f00, 1px)")
1105
1025
  assert_error_message("$number2: #ff0000 is not a number for `comparable'", "comparable(1px, #f00)")
@@ -1257,76 +1177,17 @@ WARNING
1257
1177
  end
1258
1178
 
1259
1179
  def test_index
1180
+ null = Sass::Script::Value::Null.new
1260
1181
  assert_equal("1", evaluate("index(1px solid blue, 1px)"))
1261
1182
  assert_equal("2", evaluate("index(1px solid blue, solid)"))
1262
1183
  assert_equal("3", evaluate("index(1px solid blue, #00f)"))
1263
1184
  assert_equal("1", evaluate("index(1px, 1px)"))
1264
- assert_equal("false", evaluate("index(1px solid blue, 1em)"))
1265
- assert_equal("false", evaluate("index(1px solid blue, notfound)"))
1266
- assert_equal("false", evaluate("index(1px, #00f)"))
1185
+ assert_equal(null, perform("index(1px solid blue, 1em)"))
1186
+ assert_equal(null, perform("index(1px solid blue, notfound)"))
1187
+ assert_equal(null, perform("index(1px, #00f)"))
1267
1188
 
1268
1189
  assert_equal("1", evaluate("index((foo: bar, bar: baz), (foo bar))"))
1269
- assert_equal("false", evaluate("index((foo: bar, bar: baz), (foo: bar))"))
1270
- end
1271
-
1272
- def test_index_deprecation_warning
1273
- assert_warning(<<WARNING) do
1274
- DEPRECATION WARNING: The return value of index() will change from "false" to
1275
- "null" in future versions of Sass. For compatibility, avoid using "== false" on
1276
- the return value. For example, instead of "@if index(...) == false", just write
1277
- "@if index(...)".
1278
- WARNING
1279
- assert_equal("true", evaluate("index(1, 2 3 4) == false"))
1280
- end
1281
-
1282
- assert_warning(<<WARNING) do
1283
- DEPRECATION WARNING: The return value of index() will change from "false" to
1284
- "null" in future versions of Sass. For compatibility, avoid using "!= null" on
1285
- the return value.
1286
- WARNING
1287
- assert_equal("true", evaluate("index(1, 2 3 4) != null"))
1288
- end
1289
-
1290
- assert_warning(<<WARNING) do
1291
- DEPRECATION WARNING: The return value of index() will change from "false" to
1292
- "null" in future versions of Sass. For compatibility, avoid using "== false" on
1293
- the return value. For example, instead of "@if index(...) == false", just write
1294
- "@if index(...)".
1295
- WARNING
1296
- assert_equal("true", evaluate("false == index(1, 2 3 4)"))
1297
- end
1298
-
1299
- assert_warning(<<WARNING) do
1300
- DEPRECATION WARNING: The return value of index() will change from "false" to
1301
- "null" in future versions of Sass. For compatibility, avoid using "!= null" on
1302
- the return value.
1303
- WARNING
1304
- assert_equal("true", evaluate("null != index(1, 2 3 4)"))
1305
- end
1306
- end
1307
-
1308
- def test_index_deprecation_warning_is_only_emitted_once_per_call
1309
- assert_warning(<<WARNING) do
1310
- DEPRECATION WARNING: The return value of index() will change from "false" to
1311
- "null" in future versions of Sass. For compatibility, avoid using "== false" on
1312
- the return value. For example, instead of "@if index(...) == false", just write
1313
- "@if index(...)".
1314
- on line 3 of test_index_deprecation_warning_is_only_emitted_once_per_call_inline.scss
1315
- DEPRECATION WARNING: The return value of index() will change from "false" to
1316
- "null" in future versions of Sass. For compatibility, avoid using "== false" on
1317
- the return value. For example, instead of "@if index(...) == false", just write
1318
- "@if index(...)".
1319
- on line 6 of test_index_deprecation_warning_is_only_emitted_once_per_call_inline.scss
1320
- WARNING
1321
- render(<<SCSS)
1322
- @for $i from 1 to 10 {
1323
- $var1: index(1, 2 3 4);
1324
- $var2: $var1 == false;
1325
- $var3: $var1 != null;
1326
- }
1327
- $var4: index(1, 2 3 4) == false;
1328
- SCSS
1329
- end
1190
+ assert_equal(null, perform("index((foo: bar, bar: baz), (foo: bar))"))
1330
1191
  end
1331
1192
 
1332
1193
  def test_list_separator
@@ -1446,7 +1307,7 @@ SCSS
1446
1307
  50.times do
1447
1308
  last_id, current_id = current_id, evaluate("unique-id()")
1448
1309
  assert_match(/u[a-z0-9]{8}/, current_id)
1449
- assert_not_equal last_id, current_id
1310
+ refute_equal last_id, current_id
1450
1311
  end
1451
1312
  end
1452
1313
 
@@ -1457,16 +1318,6 @@ SCSS
1457
1318
  assert_equal "null", perform("map-get((), foo)").to_sass
1458
1319
  end
1459
1320
 
1460
- def test_map_get_deprecation_warning
1461
- assert_warning(<<WARNING) do
1462
- DEPRECATION WARNING: Passing lists of pairs to map-get is deprecated and will
1463
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1464
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1465
- WARNING
1466
- assert_equal "1", evaluate("map-get((foo 1) (bar 2), foo)")
1467
- end
1468
- end
1469
-
1470
1321
  def test_map_get_checks_type
1471
1322
  assert_error_message("$map: 12 is not a map for `map-get'", "map-get(12, bar)")
1472
1323
  end
@@ -1480,26 +1331,6 @@ WARNING
1480
1331
  perform("map-merge((foo: 1, bar: 2), ())").to_sass)
1481
1332
  end
1482
1333
 
1483
- def test_map_merge_deprecation_warning
1484
- assert_warning(<<WARNING) do
1485
- DEPRECATION WARNING: Passing lists of pairs to map-merge is deprecated and will
1486
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1487
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1488
- WARNING
1489
- assert_equal("(foo: 1, bar: 2, baz: 3)",
1490
- perform("map-merge((foo 1, bar 2), (baz: 3))").to_sass)
1491
- end
1492
-
1493
- assert_warning(<<WARNING) do
1494
- DEPRECATION WARNING: Passing lists of pairs to map-merge is deprecated and will
1495
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1496
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1497
- WARNING
1498
- assert_equal("(baz: 3, foo: 1, bar: 2)",
1499
- perform("map-merge((baz: 3), (foo 1, bar 2))").to_sass)
1500
- end
1501
- end
1502
-
1503
1334
  def test_map_merge_checks_type
1504
1335
  assert_error_message("$map1: 12 is not a map for `map-merge'", "map-merge(12, (foo: 1))")
1505
1336
  assert_error_message("$map2: 12 is not a map for `map-merge'", "map-merge((foo: 1), 12)")
@@ -1508,18 +1339,12 @@ WARNING
1508
1339
  def test_map_remove
1509
1340
  assert_equal("(foo: 1, baz: 3)",
1510
1341
  perform("map-remove((foo: 1, bar: 2, baz: 3), bar)").to_sass)
1342
+ assert_equal("(foo: 1, baz: 3)",
1343
+ perform("map-remove($map: (foo: 1, bar: 2, baz: 3), $key: bar)").to_sass)
1344
+ assert_equal("()",
1345
+ perform("map-remove((foo: 1, bar: 2, baz: 3), foo, bar, baz)").to_sass)
1511
1346
  assert_equal("()", perform("map-remove((), foo)").to_sass)
1512
- end
1513
-
1514
- def test_map_remove_deprecation_warning
1515
- assert_warning(<<WARNING) do
1516
- DEPRECATION WARNING: Passing lists of pairs to map-remove is deprecated and will
1517
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1518
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1519
- WARNING
1520
- assert_equal("(foo: 1, baz: 3)",
1521
- perform("map-remove((foo 1, bar 2, baz 3), bar)").to_sass)
1522
- end
1347
+ assert_equal("()", perform("map-remove((), foo, bar)").to_sass)
1523
1348
  end
1524
1349
 
1525
1350
  def test_map_remove_checks_type
@@ -1532,17 +1357,6 @@ WARNING
1532
1357
  assert_equal("()", perform("map-keys(())").to_sass)
1533
1358
  end
1534
1359
 
1535
- def test_map_keys_deprecation_warning
1536
- assert_warning(<<WARNING) do
1537
- DEPRECATION WARNING: Passing lists of pairs to map-keys is deprecated and will
1538
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1539
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1540
- WARNING
1541
- assert_equal("foo, bar",
1542
- perform("map-keys((foo 1, bar 2))").to_sass)
1543
- end
1544
- end
1545
-
1546
1360
  def test_map_keys_checks_type
1547
1361
  assert_error_message("$map: 12 is not a map for `map-keys'", "map-keys(12)")
1548
1362
  end
@@ -1554,16 +1368,6 @@ WARNING
1554
1368
  assert_equal("()", perform("map-values(())").to_sass)
1555
1369
  end
1556
1370
 
1557
- def test_map_values_deprecation_warning
1558
- assert_warning(<<WARNING) do
1559
- DEPRECATION WARNING: Passing lists of pairs to map-values is deprecated and will
1560
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1561
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1562
- WARNING
1563
- assert_equal("1, 2", perform("map-values((foo 1, bar 2))").to_sass)
1564
- end
1565
- end
1566
-
1567
1371
  def test_map_values_checks_type
1568
1372
  assert_error_message("$map: 12 is not a map for `map-values'", "map-values(12)")
1569
1373
  end
@@ -1574,16 +1378,6 @@ WARNING
1574
1378
  assert_equal "false", evaluate("map-has-key((), foo)")
1575
1379
  end
1576
1380
 
1577
- def test_map_has_key_deprecation_warning
1578
- assert_warning(<<WARNING) do
1579
- DEPRECATION WARNING: Passing lists of pairs to map-has-key is deprecated and will
1580
- be removed in future versions of Sass. Use Sass maps instead. For details, see
1581
- http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1582
- WARNING
1583
- assert_equal("true", evaluate("map-has-key((foo 1, bar 1), foo)"))
1584
- end
1585
- end
1586
-
1587
1381
  def test_map_has_key_checks_type
1588
1382
  assert_error_message("$map: 12 is not a map for `map-has-key'", "map-has-key(12, foo)")
1589
1383
  end
@@ -1838,7 +1632,255 @@ SCSS
1838
1632
  if Sass::Script::Functions.instance_variable_defined?("@random_number_generator")
1839
1633
  Sass::Script::Functions.send(:remove_instance_variable, "@random_number_generator")
1840
1634
  end
1841
- assert_not_equal evaluate("random()"), evaluate("random()")
1635
+ refute_equal evaluate("random()"), evaluate("random()")
1636
+ end
1637
+
1638
+ def test_deprecated_arg_names
1639
+ assert_warning <<WARNING do
1640
+ DEPRECATION WARNING: The `$arg-1' argument for `deprecated-arg-fn()' has been renamed to `$arg1'.
1641
+ DEPRECATION WARNING: The `$arg-2' argument for `deprecated-arg-fn()' has been renamed to `$arg2'.
1642
+ WARNING
1643
+ assert_equal("1 2 3",
1644
+ evaluate("deprecated-arg-fn($arg-1: 1, $arg-2: 2, $arg3: 3)"))
1645
+ end
1646
+
1647
+ assert_warning <<WARNING do
1648
+ DEPRECATION WARNING: The `$arg-1' argument for `deprecated-arg-fn()' has been renamed to `$arg1'.
1649
+ DEPRECATION WARNING: The `$arg-2' argument for `deprecated-arg-fn()' has been renamed to `$arg2'.
1650
+ WARNING
1651
+ assert_equal("1 2",
1652
+ evaluate("deprecated-arg-fn($arg-1: 1, $arg-2: 2)"))
1653
+ end
1654
+
1655
+ assert_warning <<WARNING do
1656
+ DEPRECATION WARNING: The `$arg_1' argument for `deprecated-arg-fn()' has been renamed to `$arg1'.
1657
+ DEPRECATION WARNING: The `$arg_2' argument for `deprecated-arg-fn()' has been renamed to `$arg2'.
1658
+ WARNING
1659
+ assert_equal("1 2",
1660
+ evaluate("deprecated-arg-fn($arg_1: 1, $arg_2: 2)"))
1661
+ end
1662
+ end
1663
+
1664
+ def test_non_deprecated_arg_names
1665
+ assert_equal("1 2 3", evaluate("deprecated-arg-fn($arg1: 1, $arg2: 2, $arg3: 3)"))
1666
+ assert_equal("1 2", evaluate("deprecated-arg-fn($arg1: 1, $arg2: 2)"))
1667
+ end
1668
+
1669
+ ## Selector Functions
1670
+
1671
+ def test_selector_argument_parsing
1672
+ assert_equal("true", evaluate("selector-parse('.foo') == (join(('.foo',), (), space),)"))
1673
+ assert_equal("true", evaluate("selector-parse('.foo .bar') == ('.foo' '.bar',)"))
1674
+ assert_equal("true",
1675
+ evaluate("selector-parse('.foo .bar, .baz .bang') == ('.foo' '.bar', '.baz' '.bang')"))
1676
+
1677
+ assert_equal(".foo %bar", evaluate("selector-parse('.foo %bar')"))
1678
+
1679
+ assert_equal("true",
1680
+ evaluate("selector-parse(('.foo', '.bar')) == selector-parse('.foo, .bar')"))
1681
+ assert_equal("true",
1682
+ evaluate("selector-parse('.foo' '.bar') == selector-parse('.foo .bar')"))
1683
+
1684
+ assert_equal("true", evaluate("selector-parse(('.foo' '.bar', '.baz' '.bang')) == " +
1685
+ "selector-parse('.foo .bar, .baz .bang')"))
1686
+ assert_equal("true", evaluate("selector-parse(('.foo .bar', '.baz .bang')) == " +
1687
+ "selector-parse('.foo .bar, .baz .bang')"))
1688
+
1689
+ # This may throw an error in the future.
1690
+ assert_equal("true", evaluate("selector-parse(('.foo, .bar' '.baz, .bang')) == " +
1691
+ "selector-parse('.foo, .bar .baz, .bang')"))
1692
+ end
1693
+
1694
+ def test_selector_argument_validation
1695
+ assert_error_message("$selector: 12 is not a valid selector: it must be a string,\n" +
1696
+ "a list of strings, or a list of lists of strings for `selector-parse'", "selector-parse(12)")
1697
+ assert_error_message("$selector: (((\".foo\" \".bar\"), \".baz\") (\".bang\", \".qux\")) is not a valid selector: it must be a string,\n" +
1698
+ "a list of strings, or a list of lists of strings for `selector-parse'",
1699
+ "selector-parse(('.foo' '.bar', '.baz') ('.bang', '.qux'))")
1700
+ assert_error_message("$selector: \".#\" is not a valid selector: Invalid CSS after \".\": " +
1701
+ "expected class name, was \"#\" for `selector-parse'", "selector-parse('.#')")
1702
+ assert_error_message("$selector: \"&.foo\" is not a valid selector: Invalid CSS after \"\": " +
1703
+ "expected selector, was \"&.foo\" for `selector-parse'", "selector-parse('&.foo')")
1704
+ end
1705
+
1706
+ def test_selector_nest
1707
+ assert_equal(".foo", evaluate("selector-nest('.foo')"))
1708
+ assert_equal(".foo .bar", evaluate("selector-nest('.foo', '.bar')"))
1709
+ assert_equal(".foo .bar .baz", evaluate("selector-nest('.foo', '.bar', '.baz')"))
1710
+ assert_equal(".a .foo .b .bar", evaluate("selector-nest('.a .foo', '.b .bar')"))
1711
+ assert_equal(".foo.bar", evaluate("selector-nest('.foo', '&.bar')"))
1712
+ assert_equal(".baz .foo.bar", evaluate("selector-nest('.foo', '&.bar', '.baz &')"))
1713
+ end
1714
+
1715
+ def test_selector_nest_checks_types
1716
+ assert_error_message("$selectors: 12 is not a valid selector: it must be a string,\n" +
1717
+ "a list of strings, or a list of lists of strings for `selector-nest'",
1718
+ "selector-nest(12)")
1719
+ assert_error_message("$selectors: 12 is not a valid selector: it must be a string,\n" +
1720
+ "a list of strings, or a list of lists of strings for `selector-nest'",
1721
+ "selector-nest('.foo', 12)")
1722
+ end
1723
+
1724
+ def test_selector_nest_argument_validation
1725
+ assert_error_message("$selectors: At least one selector must be passed for `selector-nest'",
1726
+ "selector-nest()")
1727
+ end
1728
+
1729
+ def test_selector_append
1730
+ assert_equal(".foo.bar", evaluate("selector-append('.foo', '.bar')"))
1731
+ assert_equal(".a .foo.b .bar", evaluate("selector-append('.a .foo', '.b .bar')"))
1732
+ assert_equal(".foo-suffix", evaluate("selector-append('.foo', '-suffix')"))
1733
+ assert_equal(".foo.bar, .foo-suffix", evaluate("selector-append('.foo', '.bar, -suffix')"))
1734
+ assert_equal(".foo--suffix", evaluate("selector-append('.foo', '--suffix')"))
1735
+ assert_equal(".foo.bar, .foo--suffix", evaluate("selector-append('.foo', '.bar, --suffix')"))
1736
+ end
1737
+
1738
+ def test_selector_append_checks_types
1739
+ assert_error_message("$selectors: 12 is not a valid selector: it must be a string,\n" +
1740
+ "a list of strings, or a list of lists of strings for `selector-append'",
1741
+ "selector-append(12)")
1742
+ assert_error_message("$selectors: 12 is not a valid selector: it must be a string,\n" +
1743
+ "a list of strings, or a list of lists of strings for `selector-append'",
1744
+ "selector-append('.foo', 12)")
1745
+ end
1746
+
1747
+ def test_selector_append_errors
1748
+ assert_error_message("$selectors: At least one selector must be passed for `selector-append'",
1749
+ "selector-append()")
1750
+ assert_error_message("Can't append \"> .bar\" to \".foo\" for `selector-append'",
1751
+ "selector-append('.foo', '> .bar')")
1752
+ assert_error_message("Can't append \"*.bar\" to \".foo\" for `selector-append'",
1753
+ "selector-append('.foo', '*.bar')")
1754
+ assert_error_message("Can't append \"ns|suffix\" to \".foo\" for `selector-append'",
1755
+ "selector-append('.foo', 'ns|suffix')")
1756
+ end
1757
+
1758
+ def test_selector_extend
1759
+ assert_equal(".foo .x, .foo .a .bar, .a .foo .bar",
1760
+ evaluate("selector-extend('.foo .x', '.x', '.a .bar')"))
1761
+ assert_equal(".foo .x, .foo .bang, .x.bar, .bar.bang",
1762
+ evaluate("selector-extend('.foo .x, .x.bar', '.x', '.bang')"))
1763
+ assert_equal(".y .x, .foo .x, .y .foo, .foo .foo",
1764
+ evaluate("selector-extend('.y .x', '.x, .y', '.foo')"))
1765
+ assert_equal(".foo .x, .foo .bar, .foo .bang",
1766
+ evaluate("selector-extend('.foo .x', '.x', '.bar, .bang')"))
1767
+ assert_equal(".foo.x, .foo",
1768
+ evaluate("selector-extend('.foo.x', '.x', '.foo')"))
1769
+ end
1770
+
1771
+ def test_selector_extend_checks_types
1772
+ assert_error_message("$selector: 12 is not a valid selector: it must be a string,\n" +
1773
+ "a list of strings, or a list of lists of strings for `selector-extend'",
1774
+ "selector-extend(12, '.foo', '.bar')")
1775
+ assert_error_message("$extendee: 12 is not a valid selector: it must be a string,\n" +
1776
+ "a list of strings, or a list of lists of strings for `selector-extend'",
1777
+ "selector-extend('.foo', 12, '.bar')")
1778
+ assert_error_message("$extender: 12 is not a valid selector: it must be a string,\n" +
1779
+ "a list of strings, or a list of lists of strings for `selector-extend'",
1780
+ "selector-extend('.foo', '.bar', 12)")
1781
+ end
1782
+
1783
+ def test_selector_extend_errors
1784
+ assert_error_message("Can't extend .bar .baz: can't extend nested selectors for " +
1785
+ "`selector-extend'", "selector-extend('.foo', '.bar .baz', '.bang')")
1786
+ assert_error_message("Can't extend >: invalid selector for `selector-extend'",
1787
+ "selector-extend('.foo', '>', '.bang')")
1788
+ assert_error_message(".bang > can't extend: invalid selector for `selector-extend'",
1789
+ "selector-extend('.foo', '.bar', '.bang >')")
1790
+ end
1791
+
1792
+ def test_selector_replace
1793
+ assert_equal(".bar", evaluate("selector-replace('.foo', '.foo', '.bar')"))
1794
+ assert_equal(".foo.baz", evaluate("selector-replace('.foo.bar', '.bar', '.baz')"))
1795
+ assert_equal(".a .foo.baz", evaluate("selector-replace('.foo.bar', '.bar', '.a .baz')"))
1796
+ assert_equal(".foo.bar", evaluate("selector-replace('.foo.bar', '.baz.bar', '.qux')"))
1797
+ assert_equal(".bar.qux", evaluate("selector-replace('.foo.bar.baz', '.foo.baz', '.qux')"))
1798
+
1799
+ assert_equal(":not(.bar)", evaluate("selector-replace(':not(.foo)', '.foo', '.bar')"))
1800
+ assert_equal(".bar", evaluate("selector-replace(':not(.foo)', ':not(.foo)', '.bar')"))
1801
+ end
1802
+
1803
+ def test_selector_replace_checks_types
1804
+ assert_error_message("$selector: 12 is not a valid selector: it must be a string,\n" +
1805
+ "a list of strings, or a list of lists of strings for `selector-replace'",
1806
+ "selector-replace(12, '.foo', '.bar')")
1807
+ assert_error_message("$original: 12 is not a valid selector: it must be a string,\n" +
1808
+ "a list of strings, or a list of lists of strings for `selector-replace'",
1809
+ "selector-replace('.foo', 12, '.bar')")
1810
+ assert_error_message("$replacement: 12 is not a valid selector: it must be a string,\n" +
1811
+ "a list of strings, or a list of lists of strings for `selector-replace'",
1812
+ "selector-replace('.foo', '.bar', 12)")
1813
+ end
1814
+
1815
+ def test_selector_replace_errors
1816
+ assert_error_message("Can't extend .bar .baz: can't extend nested selectors for " +
1817
+ "`selector-replace'", "selector-replace('.foo', '.bar .baz', '.bang')")
1818
+ assert_error_message("Can't extend >: invalid selector for `selector-replace'",
1819
+ "selector-replace('.foo', '>', '.bang')")
1820
+ assert_error_message(".bang > can't extend: invalid selector for `selector-replace'",
1821
+ "selector-replace('.foo', '.bar', '.bang >')")
1822
+ end
1823
+
1824
+ def test_selector_unify
1825
+ assert_equal(".foo", evaluate("selector-unify('.foo', '.foo')"))
1826
+ assert_equal(".foo.bar", evaluate("selector-unify('.foo', '.bar')"))
1827
+ assert_equal(".foo.bar.baz", evaluate("selector-unify('.foo.bar', '.bar.baz')"))
1828
+ assert_equal(".a .b .foo.bar, .b .a .foo.bar", evaluate("selector-unify('.a .foo', '.b .bar')"))
1829
+ assert_equal(".a .foo.bar", evaluate("selector-unify('.a .foo', '.a .bar')"))
1830
+ assert_equal("", evaluate("selector-unify('p', 'a')"))
1831
+ assert_equal("", evaluate("selector-unify('.foo >', '.bar')"))
1832
+ assert_equal("", evaluate("selector-unify('.foo', '.bar >')"))
1833
+ assert_equal(".foo.baz, .foo.bang, .bar.baz, .bar.bang",
1834
+ evaluate("selector-unify('.foo, .bar', '.baz, .bang')"))
1835
+ end
1836
+
1837
+ def test_selector_unify_checks_types
1838
+ assert_error_message("$selector1: 12 is not a valid selector: it must be a string,\n" +
1839
+ "a list of strings, or a list of lists of strings for `selector-unify'",
1840
+ "selector-unify(12, '.foo')")
1841
+ assert_error_message("$selector2: 12 is not a valid selector: it must be a string,\n" +
1842
+ "a list of strings, or a list of lists of strings for `selector-unify'",
1843
+ "selector-unify('.foo', 12)")
1844
+ end
1845
+
1846
+ def test_simple_selectors
1847
+ assert_equal('(.foo,)', evaluate("inspect(simple-selectors('.foo'))"))
1848
+ assert_equal('.foo, .bar', evaluate("inspect(simple-selectors('.foo.bar'))"))
1849
+ assert_equal('.foo, .bar, :pseudo("flip, flap")',
1850
+ evaluate("inspect(simple-selectors('.foo.bar:pseudo(\"flip, flap\")'))"))
1851
+ end
1852
+
1853
+ def test_simple_selectors_checks_types
1854
+ assert_error_message("$selector: 12 is not a string for `simple-selectors'",
1855
+ "simple-selectors(12)")
1856
+ end
1857
+
1858
+ def test_simple_selectors_errors
1859
+ assert_error_message("$selector: \".foo .bar\" is not a compound selector for `simple-selectors'",
1860
+ "simple-selectors('.foo .bar')")
1861
+ assert_error_message("$selector: \".foo,.bar\" is not a compound selector for `simple-selectors'",
1862
+ "simple-selectors('.foo,.bar')")
1863
+ assert_error_message("$selector: \".#\" is not a valid selector: Invalid CSS after \".\": " +
1864
+ "expected class name, was \"#\" for `simple-selectors'", "simple-selectors('.#')")
1865
+ end
1866
+
1867
+ def test_is_superselector
1868
+ assert_equal("true", evaluate("is-superselector('.foo', '.foo.bar')"))
1869
+ assert_equal("false", evaluate("is-superselector('.foo.bar', '.foo')"))
1870
+ assert_equal("true", evaluate("is-superselector('.foo', '.foo')"))
1871
+ assert_equal("true", evaluate("is-superselector('.bar', '.foo .bar')"))
1872
+ assert_equal("false", evaluate("is-superselector('.foo .bar', '.bar')"))
1873
+ assert_equal("true", evaluate("is-superselector('.foo .bar', '.foo > .bar')"))
1874
+ assert_equal("false", evaluate("is-superselector('.foo > .bar', '.foo .bar')"))
1875
+ end
1876
+
1877
+ def test_is_superselector_checks_types
1878
+ assert_error_message("$super: 12 is not a valid selector: it must be a string,\n" +
1879
+ "a list of strings, or a list of lists of strings for `is-superselector'",
1880
+ "is-superselector(12, '.foo')")
1881
+ assert_error_message("$sub: 12 is not a valid selector: it must be a string,\n" +
1882
+ "a list of strings, or a list of lists of strings for `is-superselector'",
1883
+ "is-superselector('.foo', 12)")
1842
1884
  end
1843
1885
 
1844
1886
  ## Regression Tests