sass 3.2.9 → 3.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -120,7 +120,6 @@ module Sass
120
120
  value = [text.sub(/^\s*\/\//, '/*').gsub(/^\s*\/\//, ' *') + ' */']
121
121
  else
122
122
  value = Sass::Engine.parse_interp(text, line, @scanner.pos - text.size, :filename => @filename)
123
- value[0].slice!(2) if loud # get rid of the "!"
124
123
  value.unshift(@scanner.
125
124
  string[0...@scanner.pos].
126
125
  reverse[/.*?\*\/(.*?)($|\Z)/, 1].
@@ -437,15 +437,21 @@ module Sass
437
437
  # @param seqses [Array<Array<Array<SimpleSequence or String>>>]
438
438
  # @return [Array<Array<Array<SimpleSequence or String>>>]
439
439
  def trim(seqses)
440
- # Avoid truly horrific quadratic behavior. TOOD: I think there
440
+ # Avoid truly horrific quadratic behavior. TODO: I think there
441
441
  # may be a way to get perfect trimming without going quadratic.
442
442
  return seqses if seqses.size > 100
443
+
444
+ # Keep the results in a separate array so we can be sure we aren't
445
+ # comparing against an already-trimmed selector. This ensures that two
446
+ # identical selectors don't mutually trim one another.
447
+ result = seqses.dup
448
+
443
449
  # This is n^2 on the sequences, but only comparing between
444
450
  # separate sequences should limit the quadratic behavior.
445
- seqses.map do |seqs1|
446
- seqs1.reject do |seq1|
451
+ seqses.each_with_index do |seqs1, i|
452
+ result[i] = seqs1.reject do |seq1|
447
453
  min_spec = _sources(seq1).map {|seq| seq.specificity}.min || 0
448
- seqses.any? do |seqs2|
454
+ result.any? do |seqs2|
449
455
  next if seqs1.equal?(seqs2)
450
456
  # Second Law of Extend: the specificity of a generated selector
451
457
  # should never be less than the specificity of the extending
@@ -456,6 +462,7 @@ module Sass
456
462
  end
457
463
  end
458
464
  end
465
+ result
459
466
  end
460
467
 
461
468
  def _hash
@@ -89,7 +89,6 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
89
89
  end.gsub(/^/, spaces) + "\n"
90
90
  content
91
91
  end
92
- content.sub!(%r{^\s*(/\*)}, '/*!') if node.type == :loud #'
93
92
  content
94
93
  end
95
94
 
@@ -144,9 +144,9 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
144
144
  res = node.expr.perform(@environment)
145
145
  res = res.value if res.is_a?(Sass::Script::String)
146
146
  if node.filename
147
- $stderr.puts "#{node.filename}:#{node.line} DEBUG: #{res}"
147
+ Sass::Util.sass_warn "#{node.filename}:#{node.line} DEBUG: #{res}"
148
148
  else
149
- $stderr.puts "Line #{node.line} DEBUG: #{res}"
149
+ Sass::Util.sass_warn "Line #{node.line} DEBUG: #{res}"
150
150
  end
151
151
  []
152
152
  end
@@ -0,0 +1,10 @@
1
+ module Sass
2
+ module Util
3
+ module Test
4
+ def skip(msg = nil, bt = caller)
5
+ super if defined?(super)
6
+ return
7
+ end
8
+ end
9
+ end
10
+ end
@@ -557,7 +557,7 @@ ERR
557
557
  importer.add_import("bar", "@import 'foo'")
558
558
 
559
559
  engine = Sass::Engine.new('@import "foo"', :filename => filename_for_test,
560
- :load_paths => [importer])
560
+ :load_paths => [importer], :importer => importer)
561
561
 
562
562
  assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) {engine.render}
563
563
  An @import loop has been found:
@@ -574,7 +574,7 @@ ERR
574
574
  importer.add_import("baz", "@import 'foo'")
575
575
 
576
576
  engine = Sass::Engine.new('@import "foo"', :filename => filename_for_test,
577
- :load_paths => [importer])
577
+ :load_paths => [importer], :importer => importer)
578
578
 
579
579
  assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) {engine.render}
580
580
  An @import loop has been found:
@@ -730,7 +730,7 @@ SASS
730
730
  importer.add_import("imported", "div{color:red}")
731
731
  Sass.load_paths << importer
732
732
 
733
- assert_equal "div {\n color: red; }\n", Sass::Engine.new('@import "imported"').render
733
+ assert_equal "div {\n color: red; }\n", Sass::Engine.new('@import "imported"', :importer => importer).render
734
734
  ensure
735
735
  Sass.load_paths.clear
736
736
  end
@@ -1804,7 +1804,7 @@ SASS
1804
1804
 
1805
1805
  def test_loud_comment_in_compressed_mode
1806
1806
  assert_equal <<CSS, render(<<SASS, :style => :compressed)
1807
- foo{color:blue;/* foo
1807
+ foo{color:blue;/*! foo
1808
1808
  * bar
1809
1809
  */}
1810
1810
  CSS
@@ -1818,7 +1818,8 @@ SASS
1818
1818
 
1819
1819
  def test_loud_comment_is_evaluated
1820
1820
  assert_equal <<CSS, render(<<SASS)
1821
- /* Hue: 327.21649deg */
1821
+ /*!
1822
+ * Hue: 327.21649deg */
1822
1823
  CSS
1823
1824
  /*!
1824
1825
  Hue: \#{hue(#f836a0)}
@@ -2486,15 +2487,15 @@ SASS
2486
2487
 
2487
2488
  def test_interpolated_comment_in_mixin
2488
2489
  assert_equal <<CSS, render(<<SASS)
2489
- /* color: red */
2490
+ /*! color: red */
2490
2491
  .foo {
2491
2492
  color: red; }
2492
2493
 
2493
- /* color: blue */
2494
+ /*! color: blue */
2494
2495
  .foo {
2495
2496
  color: blue; }
2496
2497
 
2497
- /* color: green */
2498
+ /*! color: green */
2498
2499
  .foo {
2499
2500
  color: green; }
2500
2501
  CSS
@@ -2789,7 +2790,7 @@ CSS
2789
2790
  /* \\\#{foo}
2790
2791
  SASS
2791
2792
  assert_equal <<CSS, render(<<SASS)
2792
- /* \#{foo} */
2793
+ /*! \#{foo} */
2793
2794
  CSS
2794
2795
  /*! \\\#{foo}
2795
2796
  SASS
@@ -2972,7 +2973,7 @@ SCSS
2972
2973
 
2973
2974
  original_filename = filename_for_test
2974
2975
  engine = Sass::Engine.new('@import "imported"; div{color:blue}',
2975
- :filename => original_filename, :load_paths => [importer], :syntax => :scss)
2976
+ :filename => original_filename, :load_paths => [importer], :syntax => :scss, :importer => importer)
2976
2977
  engine.render
2977
2978
 
2978
2979
  assert_equal original_filename, engine.options[:original_filename]
@@ -3207,6 +3208,7 @@ SASS
3207
3208
 
3208
3209
  def render(sass, options = {})
3209
3210
  munge_filename options
3211
+ options[:importer] ||= MockImporter.new
3210
3212
  Sass::Engine.new(sass, options).render
3211
3213
  end
3212
3214
 
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'sass/util/test'
4
+ require 'tmpdir'
5
+
6
+ class ExecTest < Test::Unit::TestCase
7
+ include Sass::Util::Test
8
+
9
+ def setup
10
+ @dir = Dir.mktmpdir
11
+ end
12
+
13
+ def teardown
14
+ FileUtils.rm_rf(@dir)
15
+ clean_up_sassc
16
+ end
17
+
18
+ def test_scss_t_expanded
19
+ src = get_path("src.scss")
20
+ dest = get_path("dest.css")
21
+ write(src, ".ruleset { margin: 0 }")
22
+ assert(exec(*%w[scss -t expanded --unix-newlines].push(src, dest)))
23
+ assert_equal(".ruleset {\n margin: 0;\n}\n", read(dest))
24
+ end
25
+
26
+ def test_sass_convert_T_sass
27
+ src = get_path("src.scss")
28
+ dest = get_path("dest.css")
29
+ write(src, ".ruleset { margin: 0 }")
30
+ assert(exec(*%w[sass-convert -T sass --unix-newlines].push(src, dest)))
31
+ assert_equal(".ruleset\n margin: 0\n", read(dest))
32
+ end
33
+
34
+ def test_sass_convert_T_sass_in_place
35
+ src = get_path("src.scss")
36
+ write(src, ".ruleset { margin: 0 }")
37
+ assert(exec(*%w[sass-convert -T sass --in-place --unix-newlines].push(src)))
38
+ assert_equal(".ruleset\n margin: 0\n", read(src))
39
+ end
40
+
41
+ def test_scss_t_expanded_no_unix_newlines
42
+ return skip "Can be run on Windows only" unless Sass::Util.windows?
43
+ src = get_path("src.scss")
44
+ dest = get_path("dest.css")
45
+ write(src, ".ruleset { margin: 0 }")
46
+ assert(exec(*%w[scss -t expanded].push(src, dest)))
47
+ assert_equal(".ruleset {\r\n margin: 0;\r\n}\r\n", read(dest))
48
+ end
49
+
50
+ def test_sass_convert_T_sass_no_unix_newlines
51
+ return skip "Can be run on Windows only" unless Sass::Util.windows?
52
+ src = get_path("src.scss")
53
+ dest = get_path("dest.sass")
54
+ write(src, ".ruleset { margin: 0 }")
55
+ assert(exec(*%w[sass-convert -T sass].push(src, dest)))
56
+ assert_equal(".ruleset\r\n margin: 0\r\n", read(dest))
57
+ end
58
+
59
+ def test_sass_convert_T_sass_in_place_no_unix_newlines
60
+ return skip "Can be run on Windows only" unless Sass::Util.windows?
61
+ src = get_path("src.scss")
62
+ write(src, ".ruleset { margin: 0 }")
63
+ assert(exec(*%w[sass-convert -T sass --in-place].push(src)))
64
+ assert_equal(".ruleset\r\n margin: 0\r\n", read(src))
65
+ end
66
+
67
+ private
68
+
69
+ def get_path(name)
70
+ File.join(@dir, name)
71
+ end
72
+
73
+ def read(file)
74
+ open(file, 'rb') {|f| f.read}
75
+ end
76
+
77
+ def write(file, content)
78
+ open(file, 'wb') {|f| f.write(content)}
79
+ end
80
+
81
+ def exec(script, *args)
82
+ script = File.dirname(__FILE__) + '/../../bin/' + script
83
+ ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'])
84
+ system(ruby, script, *args)
85
+ end
86
+ end
@@ -489,7 +489,7 @@ CSS
489
489
  SCSS
490
490
  end
491
491
 
492
- def test_nested_extender_with_early_child_selectors_doesnt_subseq_them
492
+ def test_another_nested_extender_with_early_child_selectors_doesnt_subseq_them
493
493
  assert_equal <<CSS, render(<<SCSS)
494
494
  .foo .bar, .foo .bip > .baz {
495
495
  a: b; }
@@ -1145,20 +1145,6 @@ SCSS
1145
1145
  a.bar {
1146
1146
  a: b; }
1147
1147
 
1148
- .bar, b.foo {
1149
- c: d; }
1150
- CSS
1151
- a.bar {a: b}
1152
- .bar {c: d}
1153
- b.foo {@extend .bar}
1154
- SCSS
1155
- end
1156
-
1157
- def test_extend_does_not_warn_when_one_extension_fails_but_others_dont
1158
- assert_no_warning {assert_equal(<<CSS, render(<<SCSS))}
1159
- a.bar {
1160
- a: b; }
1161
-
1162
1148
  .bar, b.foo {
1163
1149
  c: d; }
1164
1150
  CSS
@@ -1186,6 +1172,43 @@ SCSS
1186
1172
 
1187
1173
  # Regression Tests
1188
1174
 
1175
+ def test_nested_sibling_extend
1176
+ assert_equal <<CSS, render(<<SCSS)
1177
+ .parent .bar, .parent .foo {
1178
+ width: 2000px; }
1179
+ CSS
1180
+ .foo {@extend .bar}
1181
+
1182
+ .parent {
1183
+ .bar {
1184
+ width: 2000px;
1185
+ }
1186
+ .foo {
1187
+ @extend .bar
1188
+ }
1189
+ }
1190
+ SCSS
1191
+ end
1192
+
1193
+ def test_parent_and_sibling_extend
1194
+ assert_equal <<CSS, render(<<SCSS)
1195
+ .parent1 .parent2 .child1.child2, .parent2 .parent1 .child1.child2 {
1196
+ c: d; }
1197
+ CSS
1198
+ %foo %bar%baz {c: d}
1199
+
1200
+ .parent1 {
1201
+ @extend %foo;
1202
+ .child1 {@extend %bar}
1203
+ }
1204
+
1205
+ .parent2 {
1206
+ @extend %foo;
1207
+ .child2 {@extend %baz}
1208
+ }
1209
+ SCSS
1210
+ end
1211
+
1189
1212
  def test_nested_extend_specificity
1190
1213
  assert_equal <<CSS, render(<<SCSS)
1191
1214
  a :b, a :b:c {
@@ -84,9 +84,9 @@ class SassFunctionTest < Test::Unit::TestCase
84
84
  end
85
85
 
86
86
  def test_hsl_checks_types
87
- assert_error_message("\"foo\" is not a number for `hsl'", "hsl(\"foo\", 10, 12)");
88
- assert_error_message("\"foo\" is not a number for `hsl'", "hsl(10, \"foo\", 12)");
89
- assert_error_message("\"foo\" is not a number for `hsl'", "hsl(10, 10, \"foo\")");
87
+ assert_error_message("$hue: \"foo\" is not a number for `hsl'", "hsl(\"foo\", 10, 12)");
88
+ assert_error_message("$saturation: \"foo\" is not a number for `hsl'", "hsl(10, \"foo\", 12)");
89
+ assert_error_message("$lightness: \"foo\" is not a number for `hsl'", "hsl(10, 10, \"foo\")");
90
90
  end
91
91
 
92
92
  def test_hsla
@@ -104,10 +104,10 @@ class SassFunctionTest < Test::Unit::TestCase
104
104
  end
105
105
 
106
106
  def test_hsla_checks_types
107
- assert_error_message("\"foo\" is not a number for `hsla'", "hsla(\"foo\", 10, 12, 0.3)");
108
- assert_error_message("\"foo\" is not a number for `hsla'", "hsla(10, \"foo\", 12, 0)");
109
- assert_error_message("\"foo\" is not a number for `hsla'", "hsla(10, 10, \"foo\", 1)");
110
- assert_error_message("\"foo\" is not a number for `hsla'", "hsla(10, 10, 10, \"foo\")");
107
+ assert_error_message("$hue: \"foo\" is not a number for `hsla'", "hsla(\"foo\", 10, 12, 0.3)");
108
+ assert_error_message("$saturation: \"foo\" is not a number for `hsla'", "hsla(10, \"foo\", 12, 0)");
109
+ assert_error_message("$lightness: \"foo\" is not a number for `hsla'", "hsla(10, 10, \"foo\", 1)");
110
+ assert_error_message("$alpha: \"foo\" is not a number for `hsla'", "hsla(10, 10, 10, \"foo\")");
111
111
  end
112
112
 
113
113
  def test_percentage
@@ -118,9 +118,9 @@ class SassFunctionTest < Test::Unit::TestCase
118
118
  end
119
119
 
120
120
  def test_percentage_checks_types
121
- assert_error_message("25px is not a unitless number for `percentage'", "percentage(25px)")
122
- assert_error_message("#cccccc is not a unitless number for `percentage'", "percentage(#ccc)")
123
- assert_error_message("\"string\" is not a unitless number for `percentage'", %Q{percentage("string")})
121
+ assert_error_message("$value: 25px is not a unitless number for `percentage'", "percentage(25px)")
122
+ assert_error_message("$value: #cccccc is not a unitless number for `percentage'", "percentage(#ccc)")
123
+ assert_error_message("$value: \"string\" is not a unitless number for `percentage'", %Q{percentage("string")})
124
124
  end
125
125
 
126
126
  def test_round
@@ -129,7 +129,7 @@ class SassFunctionTest < Test::Unit::TestCase
129
129
  assert_equal("5px", evaluate("round(5.49px)"))
130
130
  assert_equal("5px", evaluate("round($value: 5.49px)"))
131
131
 
132
- assert_error_message("#cccccc is not a number for `round'", "round(#ccc)")
132
+ assert_error_message("$value: #cccccc is not a number for `round'", "round(#ccc)")
133
133
  end
134
134
 
135
135
  def test_floor
@@ -137,7 +137,7 @@ class SassFunctionTest < Test::Unit::TestCase
137
137
  assert_equal("4px", evaluate("floor(4.8px)"))
138
138
  assert_equal("4px", evaluate("floor($value: 4.8px)"))
139
139
 
140
- assert_error_message("\"foo\" is not a number for `floor'", "floor(\"foo\")")
140
+ assert_error_message("$value: \"foo\" is not a number for `floor'", "floor(\"foo\")")
141
141
  end
142
142
 
143
143
  def test_ceil
@@ -145,7 +145,7 @@ class SassFunctionTest < Test::Unit::TestCase
145
145
  assert_equal("5px", evaluate("ceil(4.8px)"))
146
146
  assert_equal("5px", evaluate("ceil($value: 4.8px)"))
147
147
 
148
- assert_error_message("\"a\" is not a number for `ceil'", "ceil(\"a\")")
148
+ assert_error_message("$value: \"a\" is not a number for `ceil'", "ceil(\"a\")")
149
149
  end
150
150
 
151
151
  def test_abs
@@ -155,7 +155,7 @@ class SassFunctionTest < Test::Unit::TestCase
155
155
  assert_equal("5px", evaluate("abs(5px)"))
156
156
  assert_equal("5px", evaluate("abs($value: 5px)"))
157
157
 
158
- assert_error_message("#aaaaaa is not a number for `abs'", "abs(#aaa)")
158
+ assert_error_message("$value: #aaaaaa is not a number for `abs'", "abs(#aaa)")
159
159
  end
160
160
 
161
161
  def test_min
@@ -193,31 +193,31 @@ class SassFunctionTest < Test::Unit::TestCase
193
193
  end
194
194
 
195
195
  def test_rgb_tests_bounds
196
- assert_error_message("Color value 256 must be between 0 and 255 for `rgb'",
196
+ assert_error_message("$red: Color value 256 must be between 0 and 255 for `rgb'",
197
197
  "rgb(256, 1, 1)")
198
- assert_error_message("Color value 256 must be between 0 and 255 for `rgb'",
198
+ assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgb'",
199
199
  "rgb(1, 256, 1)")
200
- assert_error_message("Color value 256 must be between 0 and 255 for `rgb'",
200
+ assert_error_message("$blue: Color value 256 must be between 0 and 255 for `rgb'",
201
201
  "rgb(1, 1, 256)")
202
- assert_error_message("Color value 256 must be between 0 and 255 for `rgb'",
202
+ assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgb'",
203
203
  "rgb(1, 256, 257)")
204
- assert_error_message("Color value -1 must be between 0 and 255 for `rgb'",
204
+ assert_error_message("$red: Color value -1 must be between 0 and 255 for `rgb'",
205
205
  "rgb(-1, 1, 1)")
206
206
  end
207
207
 
208
208
  def test_rgb_test_percent_bounds
209
- assert_error_message("Color value 100.1% must be between 0% and 100% for `rgb'",
209
+ assert_error_message("$red: Color value 100.1% must be between 0% and 100% for `rgb'",
210
210
  "rgb(100.1%, 0, 0)")
211
- assert_error_message("Color value -0.1% must be between 0% and 100% for `rgb'",
211
+ assert_error_message("$green: Color value -0.1% must be between 0% and 100% for `rgb'",
212
212
  "rgb(0, -0.1%, 0)")
213
- assert_error_message("Color value 101% must be between 0% and 100% for `rgb'",
213
+ assert_error_message("$blue: Color value 101% must be between 0% and 100% for `rgb'",
214
214
  "rgb(0, 0, 101%)")
215
215
  end
216
216
 
217
217
  def test_rgb_tests_types
218
- assert_error_message("\"foo\" is not a number for `rgb'", "rgb(\"foo\", 10, 12)");
219
- assert_error_message("\"foo\" is not a number for `rgb'", "rgb(10, \"foo\", 12)");
220
- assert_error_message("\"foo\" is not a number for `rgb'", "rgb(10, 10, \"foo\")");
218
+ assert_error_message("$red: \"foo\" is not a number for `rgb'", "rgb(\"foo\", 10, 12)");
219
+ assert_error_message("$green: \"foo\" is not a number for `rgb'", "rgb(10, \"foo\", 12)");
220
+ assert_error_message("$blue: \"foo\" is not a number for `rgb'", "rgb(10, 10, \"foo\")");
221
221
  end
222
222
 
223
223
  def test_rgba
@@ -228,15 +228,15 @@ class SassFunctionTest < Test::Unit::TestCase
228
228
  end
229
229
 
230
230
  def test_rgba_tests_bounds
231
- assert_error_message("Color value 256 must be between 0 and 255 for `rgba'",
231
+ assert_error_message("$red: Color value 256 must be between 0 and 255 for `rgba'",
232
232
  "rgba(256, 1, 1, 0.3)")
233
- assert_error_message("Color value 256 must be between 0 and 255 for `rgba'",
233
+ assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgba'",
234
234
  "rgba(1, 256, 1, 0.3)")
235
- assert_error_message("Color value 256 must be between 0 and 255 for `rgba'",
235
+ assert_error_message("$blue: Color value 256 must be between 0 and 255 for `rgba'",
236
236
  "rgba(1, 1, 256, 0.3)")
237
- assert_error_message("Color value 256 must be between 0 and 255 for `rgba'",
237
+ assert_error_message("$green: Color value 256 must be between 0 and 255 for `rgba'",
238
238
  "rgba(1, 256, 257, 0.3)")
239
- assert_error_message("Color value -1 must be between 0 and 255 for `rgba'",
239
+ assert_error_message("$red: Color value -1 must be between 0 and 255 for `rgba'",
240
240
  "rgba(-1, 1, 1, 0.3)")
241
241
  assert_error_message("Alpha channel -0.2 must be between 0 and 1 for `rgba'",
242
242
  "rgba(1, 1, 1, -0.2)")
@@ -245,10 +245,10 @@ class SassFunctionTest < Test::Unit::TestCase
245
245
  end
246
246
 
247
247
  def test_rgba_tests_types
248
- assert_error_message("\"foo\" is not a number for `rgba'", "rgba(\"foo\", 10, 12, 0.2)");
249
- assert_error_message("\"foo\" is not a number for `rgba'", "rgba(10, \"foo\", 12, 0.1)");
250
- assert_error_message("\"foo\" is not a number for `rgba'", "rgba(10, 10, \"foo\", 0)");
251
- assert_error_message("\"foo\" is not a number for `rgba'", "rgba(10, 10, 10, \"foo\")");
248
+ assert_error_message("$red: \"foo\" is not a number for `rgba'", "rgba(\"foo\", 10, 12, 0.2)");
249
+ assert_error_message("$green: \"foo\" is not a number for `rgba'", "rgba(10, \"foo\", 12, 0.1)");
250
+ assert_error_message("$blue: \"foo\" is not a number for `rgba'", "rgba(10, 10, \"foo\", 0)");
251
+ assert_error_message("$alpha: \"foo\" is not a number for `rgba'", "rgba(10, 10, 10, \"foo\")");
252
252
  end
253
253
 
254
254
  def test_rgba_with_color
@@ -258,8 +258,8 @@ class SassFunctionTest < Test::Unit::TestCase
258
258
  end
259
259
 
260
260
  def test_rgba_with_color_tests_types
261
- assert_error_message("\"foo\" is not a color for `rgba'", "rgba(\"foo\", 0.2)");
262
- assert_error_message("\"foo\" is not a number for `rgba'", "rgba(blue, \"foo\")");
261
+ assert_error_message("$color: \"foo\" is not a color for `rgba'", "rgba(\"foo\", 0.2)");
262
+ assert_error_message("$alpha: \"foo\" is not a number for `rgba'", "rgba(blue, \"foo\")");
263
263
  end
264
264
 
265
265
  def test_rgba_tests_num_args
@@ -275,7 +275,7 @@ class SassFunctionTest < Test::Unit::TestCase
275
275
  end
276
276
 
277
277
  def test_red_exception
278
- assert_error_message("12 is not a color for `red'", "red(12)")
278
+ assert_error_message("$color: 12 is not a color for `red'", "red(12)")
279
279
  end
280
280
 
281
281
  def test_green
@@ -284,7 +284,7 @@ class SassFunctionTest < Test::Unit::TestCase
284
284
  end
285
285
 
286
286
  def test_green_exception
287
- assert_error_message("12 is not a color for `green'", "green(12)")
287
+ assert_error_message("$color: 12 is not a color for `green'", "green(12)")
288
288
  end
289
289
 
290
290
  def test_blue
@@ -293,7 +293,7 @@ class SassFunctionTest < Test::Unit::TestCase
293
293
  end
294
294
 
295
295
  def test_blue_exception
296
- assert_error_message("12 is not a color for `blue'", "blue(12)")
296
+ assert_error_message("$color: 12 is not a color for `blue'", "blue(12)")
297
297
  end
298
298
 
299
299
  def test_hue
@@ -302,7 +302,7 @@ class SassFunctionTest < Test::Unit::TestCase
302
302
  end
303
303
 
304
304
  def test_hue_exception
305
- assert_error_message("12 is not a color for `hue'", "hue(12)")
305
+ assert_error_message("$color: 12 is not a color for `hue'", "hue(12)")
306
306
  end
307
307
 
308
308
  def test_saturation
@@ -312,7 +312,7 @@ class SassFunctionTest < Test::Unit::TestCase
312
312
  end
313
313
 
314
314
  def test_saturation_exception
315
- assert_error_message("12 is not a color for `saturation'", "saturation(12)")
315
+ assert_error_message("$color: 12 is not a color for `saturation'", "saturation(12)")
316
316
  end
317
317
 
318
318
  def test_lightness
@@ -322,7 +322,7 @@ class SassFunctionTest < Test::Unit::TestCase
322
322
  end
323
323
 
324
324
  def test_lightness_exception
325
- assert_error_message("12 is not a color for `lightness'", "lightness(12)")
325
+ assert_error_message("$color: 12 is not a color for `lightness'", "lightness(12)")
326
326
  end
327
327
 
328
328
  def test_alpha
@@ -333,7 +333,7 @@ class SassFunctionTest < Test::Unit::TestCase
333
333
  end
334
334
 
335
335
  def test_alpha_exception
336
- assert_error_message("12 is not a color for `alpha'", "alpha(12)")
336
+ assert_error_message("$color: 12 is not a color for `alpha'", "alpha(12)")
337
337
  end
338
338
 
339
339
  def test_opacity
@@ -345,7 +345,7 @@ class SassFunctionTest < Test::Unit::TestCase
345
345
  end
346
346
 
347
347
  def test_opacity_exception
348
- assert_error_message("\"foo\" is not a color for `opacity'", "opacity(foo)")
348
+ assert_error_message("$color: \"foo\" is not a color for `opacity'", "opacity(foo)")
349
349
  end
350
350
 
351
351
  def test_opacify
@@ -367,8 +367,8 @@ class SassFunctionTest < Test::Unit::TestCase
367
367
  end
368
368
 
369
369
  def test_opacify_tests_types
370
- assert_error_message("\"foo\" is not a color for `opacify'", "opacify(\"foo\", 10%)")
371
- assert_error_message("\"foo\" is not a number for `opacify'", "opacify(#fff, \"foo\")")
370
+ assert_error_message("$color: \"foo\" is not a color for `opacify'", "opacify(\"foo\", 10%)")
371
+ assert_error_message("$amount: \"foo\" is not a number for `opacify'", "opacify(#fff, \"foo\")")
372
372
  end
373
373
 
374
374
  def test_transparentize
@@ -390,8 +390,8 @@ class SassFunctionTest < Test::Unit::TestCase
390
390
  end
391
391
 
392
392
  def test_transparentize_tests_types
393
- assert_error_message("\"foo\" is not a color for `transparentize'", "transparentize(\"foo\", 10%)")
394
- assert_error_message("\"foo\" is not a number for `transparentize'", "transparentize(#fff, \"foo\")")
393
+ assert_error_message("$color: \"foo\" is not a color for `transparentize'", "transparentize(\"foo\", 10%)")
394
+ assert_error_message("$amount: \"foo\" is not a number for `transparentize'", "transparentize(#fff, \"foo\")")
395
395
  end
396
396
 
397
397
  def test_lighten
@@ -412,8 +412,8 @@ class SassFunctionTest < Test::Unit::TestCase
412
412
  end
413
413
 
414
414
  def test_lighten_tests_types
415
- assert_error_message("\"foo\" is not a color for `lighten'", "lighten(\"foo\", 10%)")
416
- assert_error_message("\"foo\" is not a number for `lighten'", "lighten(#fff, \"foo\")")
415
+ assert_error_message("$color: \"foo\" is not a color for `lighten'", "lighten(\"foo\", 10%)")
416
+ assert_error_message("$amount: \"foo\" is not a number for `lighten'", "lighten(#fff, \"foo\")")
417
417
  end
418
418
 
419
419
  def test_darken
@@ -434,8 +434,8 @@ class SassFunctionTest < Test::Unit::TestCase
434
434
  end
435
435
 
436
436
  def test_darken_tests_types
437
- assert_error_message("\"foo\" is not a color for `darken'", "darken(\"foo\", 10%)")
438
- assert_error_message("\"foo\" is not a number for `darken'", "darken(#fff, \"foo\")")
437
+ assert_error_message("$color: \"foo\" is not a color for `darken'", "darken(\"foo\", 10%)")
438
+ assert_error_message("$amount: \"foo\" is not a number for `darken'", "darken(#fff, \"foo\")")
439
439
  end
440
440
 
441
441
  def test_saturate
@@ -458,8 +458,8 @@ class SassFunctionTest < Test::Unit::TestCase
458
458
  end
459
459
 
460
460
  def test_saturate_tests_types
461
- assert_error_message("\"foo\" is not a color for `saturate'", "saturate(\"foo\", 10%)")
462
- assert_error_message("\"foo\" is not a number for `saturate'", "saturate(#fff, \"foo\")")
461
+ assert_error_message("$color: \"foo\" is not a color for `saturate'", "saturate(\"foo\", 10%)")
462
+ assert_error_message("$amount: \"foo\" is not a number for `saturate'", "saturate(#fff, \"foo\")")
463
463
  end
464
464
 
465
465
  def test_desaturate
@@ -481,8 +481,8 @@ class SassFunctionTest < Test::Unit::TestCase
481
481
  end
482
482
 
483
483
  def test_desaturate_tests_types
484
- assert_error_message("\"foo\" is not a color for `desaturate'", "desaturate(\"foo\", 10%)")
485
- assert_error_message("\"foo\" is not a number for `desaturate'", "desaturate(#fff, \"foo\")")
484
+ assert_error_message("$color: \"foo\" is not a color for `desaturate'", "desaturate(\"foo\", 10%)")
485
+ assert_error_message("$amount: \"foo\" is not a number for `desaturate'", "desaturate(#fff, \"foo\")")
486
486
  end
487
487
 
488
488
  def test_adjust_hue
@@ -498,8 +498,8 @@ class SassFunctionTest < Test::Unit::TestCase
498
498
  end
499
499
 
500
500
  def test_adjust_hue_tests_types
501
- assert_error_message("\"foo\" is not a color for `adjust-hue'", "adjust-hue(\"foo\", 10%)")
502
- assert_error_message("\"foo\" is not a number for `adjust-hue'", "adjust-hue(#fff, \"foo\")")
501
+ assert_error_message("$color: \"foo\" is not a color for `adjust-hue'", "adjust-hue(\"foo\", 10%)")
502
+ assert_error_message("$degrees: \"foo\" is not a number for `adjust-hue'", "adjust-hue(#fff, \"foo\")")
503
503
  end
504
504
 
505
505
  def test_adjust_color
@@ -557,7 +557,7 @@ class SassFunctionTest < Test::Unit::TestCase
557
557
  end
558
558
 
559
559
  def test_adjust_color_tests_types
560
- assert_error_message("\"foo\" is not a color for `adjust-color'", "adjust-color(foo, $hue: 10)")
560
+ assert_error_message("$color: \"foo\" is not a color for `adjust-color'", "adjust-color(foo, $hue: 10)")
561
561
  # HSL
562
562
  assert_error_message("$hue: \"foo\" is not a number for `adjust-color'",
563
563
  "adjust-color(blue, $hue: foo)")
@@ -663,7 +663,7 @@ class SassFunctionTest < Test::Unit::TestCase
663
663
  end
664
664
 
665
665
  def test_scale_color_tests_types
666
- assert_error_message("\"foo\" is not a color for `scale-color'", "scale-color(foo, $red: 10%)")
666
+ assert_error_message("$color: \"foo\" is not a color for `scale-color'", "scale-color(foo, $red: 10%)")
667
667
  # HSL
668
668
  assert_error_message("$saturation: \"foo\" is not a number for `scale-color'",
669
669
  "scale-color(blue, $saturation: foo)")
@@ -734,7 +734,7 @@ class SassFunctionTest < Test::Unit::TestCase
734
734
  end
735
735
 
736
736
  def test_change_color_tests_types
737
- assert_error_message("\"foo\" is not a color for `change-color'", "change-color(foo, $red: 10%)")
737
+ assert_error_message("$color: \"foo\" is not a color for `change-color'", "change-color(foo, $red: 10%)")
738
738
  # HSL
739
739
  assert_error_message("$saturation: \"foo\" is not a number for `change-color'",
740
740
  "change-color(blue, $saturation: foo)")
@@ -797,9 +797,9 @@ class SassFunctionTest < Test::Unit::TestCase
797
797
  end
798
798
 
799
799
  def test_mix_tests_types
800
- assert_error_message("\"foo\" is not a color for `mix'", "mix(\"foo\", #f00, 10%)")
801
- assert_error_message("\"foo\" is not a color for `mix'", "mix(#f00, \"foo\", 10%)")
802
- assert_error_message("\"foo\" is not a number for `mix'", "mix(#f00, #baf, \"foo\")")
800
+ assert_error_message("$color-1: \"foo\" is not a color for `mix'", "mix(\"foo\", #f00, 10%)")
801
+ assert_error_message("$color-2: \"foo\" is not a color for `mix'", "mix(#f00, \"foo\", 10%)")
802
+ assert_error_message("$weight: \"foo\" is not a number for `mix'", "mix(#f00, #baf, \"foo\")")
803
803
  end
804
804
 
805
805
  def test_mix_tests_bounds
@@ -822,7 +822,7 @@ class SassFunctionTest < Test::Unit::TestCase
822
822
  end
823
823
 
824
824
  def tets_grayscale_tests_types
825
- assert_error_message("\"foo\" is not a color for `grayscale'", "grayscale(\"foo\")")
825
+ assert_error_message("$color: \"foo\" is not a color for `grayscale'", "grayscale(\"foo\")")
826
826
  end
827
827
 
828
828
  def test_complement
@@ -835,7 +835,7 @@ class SassFunctionTest < Test::Unit::TestCase
835
835
  end
836
836
 
837
837
  def tets_complement_tests_types
838
- assert_error_message("\"foo\" is not a color for `complement'", "complement(\"foo\")")
838
+ assert_error_message("$color: \"foo\" is not a color for `complement'", "complement(\"foo\")")
839
839
  end
840
840
 
841
841
  def test_invert
@@ -845,7 +845,7 @@ class SassFunctionTest < Test::Unit::TestCase
845
845
  end
846
846
 
847
847
  def test_invert_tests_types
848
- assert_error_message("\"foo\" is not a color for `invert'", "invert(\"foo\")")
848
+ assert_error_message("$color: \"foo\" is not a color for `invert'", "invert(\"foo\")")
849
849
  end
850
850
 
851
851
  def test_unquote
@@ -861,7 +861,7 @@ class SassFunctionTest < Test::Unit::TestCase
861
861
  end
862
862
 
863
863
  def test_quote_tests_type
864
- assert_error_message("#ff0000 is not a string for `quote'", "quote(#f00)")
864
+ assert_error_message("$string: #ff0000 is not a string for `quote'", "quote(#f00)")
865
865
  end
866
866
 
867
867
  def test_user_defined_function
@@ -900,14 +900,14 @@ MSG
900
900
  assert_equal(%Q{"em/rem"}, evaluate("unit(10px * 5em / 30cm / 1rem)"))
901
901
  assert_equal(%Q{"em*vh/cm*rem"}, evaluate("unit(10vh * 5em / 30cm / 1rem)"))
902
902
  assert_equal(%Q{"px"}, evaluate("unit($number: 100px)"))
903
- assert_error_message("#ff0000 is not a number for `unit'", "unit(#f00)")
903
+ assert_error_message("$number: #ff0000 is not a number for `unit'", "unit(#f00)")
904
904
  end
905
905
 
906
906
  def test_unitless
907
907
  assert_equal(%Q{true}, evaluate("unitless(100)"))
908
908
  assert_equal(%Q{false}, evaluate("unitless(100px)"))
909
909
  assert_equal(%Q{false}, evaluate("unitless($number: 100px)"))
910
- assert_error_message("#ff0000 is not a number for `unitless'", "unitless(#f00)")
910
+ assert_error_message("$number: #ff0000 is not a number for `unitless'", "unitless(#f00)")
911
911
  end
912
912
 
913
913
  def test_comparable
@@ -915,8 +915,8 @@ MSG
915
915
  assert_equal(%Q{true}, evaluate("comparable(10cm, 3mm)"))
916
916
  assert_equal(%Q{false}, evaluate("comparable(100px, 3em)"))
917
917
  assert_equal(%Q{false}, evaluate("comparable($number-1: 100px, $number-2: 3em)"))
918
- assert_error_message("#ff0000 is not a number for `comparable'", "comparable(#f00, 1px)")
919
- assert_error_message("#ff0000 is not a number for `comparable'", "comparable(1px, #f00)")
918
+ assert_error_message("$number-1: #ff0000 is not a number for `comparable'", "comparable(#f00, 1px)")
919
+ assert_error_message("$number-2: #ff0000 is not a number for `comparable'", "comparable(1px, #f00)")
920
920
  end
921
921
 
922
922
  def test_length
@@ -941,6 +941,7 @@ MSG
941
941
  assert_error_message("List index is 5 but list is only 4 items long for `nth'", "nth(1 2 3 4, 5)")
942
942
  assert_error_message("List index is 2 but list is only 1 item long for `nth'", "nth(foo, 2)")
943
943
  assert_error_message("List index is 1 but list has no items for `nth'", "nth((), 1)")
944
+ assert_error_message("$n: \"foo\" is not a number for `nth'", "nth(1 2 3, foo)")
944
945
  end
945
946
 
946
947
  def test_join
@@ -979,6 +980,7 @@ MSG
979
980
  assert_equal("false", evaluate("(1, 2, ()) == join((), (1, 2))"))
980
981
 
981
982
  assert_error_message("Separator name must be space, comma, or auto for `join'", "join(1, 2, baboon)")
983
+ assert_error_message("$separator: 12 is not a string for `join'", "join(1, 2, 12)")
982
984
  end
983
985
 
984
986
  def test_append
@@ -1013,6 +1015,7 @@ MSG
1013
1015
  assert_equal("true", evaluate("(1 2) == nth(append((), 1 2), 1)"))
1014
1016
 
1015
1017
  assert_error_message("Separator name must be space, comma, or auto for `append'", "append(1, 2, baboon)")
1018
+ assert_error_message("$separator: 12 is not a string for `append'", "append(1, 2, 12)")
1016
1019
  end
1017
1020
 
1018
1021
  def test_zip