sass 3.1.0.alpha.210 → 3.1.0.alpha.212
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/VERSION +1 -1
- data/lib/sass/cache_stores.rb +1 -0
- data/lib/sass/cache_stores/base.rb +2 -2
- data/lib/sass/cache_stores/chain.rb +33 -0
- data/lib/sass/cache_stores/memory.rb +8 -12
- data/lib/sass/engine.rb +11 -2
- data/lib/sass/script/functions.rb +27 -21
- data/lib/sass/tree/if_node.rb +14 -15
- data/lib/sass/tree/node.rb +8 -23
- data/lib/sass/util.rb +0 -50
- data/test/sass/functions_test.rb +157 -157
- data/test/sass/importer_test.rb +0 -22
- data/test/sass/util_test.rb +0 -21
- metadata +3 -2
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ebf9e326dafba548aef36fe36945d97a9dd590d9
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.212
|
data/lib/sass/cache_stores.rb
CHANGED
@@ -48,7 +48,7 @@ module Sass
|
|
48
48
|
# @param sha [String] The checksum for the contents that are being stored.
|
49
49
|
# @param obj [Object] The object to cache.
|
50
50
|
def store(key, sha, root)
|
51
|
-
_store(key, Sass::VERSION, sha,
|
51
|
+
_store(key, Sass::VERSION, sha, Marshal.dump(root))
|
52
52
|
end
|
53
53
|
|
54
54
|
# Retrieve a {Sass::Tree::RootNode}.
|
@@ -58,7 +58,7 @@ module Sass
|
|
58
58
|
# @return [Object] The cached object.
|
59
59
|
def retrieve(key, sha)
|
60
60
|
contents = _retrieve(key, Sass::VERSION, sha)
|
61
|
-
|
61
|
+
Marshal.load(contents) if contents
|
62
62
|
rescue EOFError, TypeError, ArgumentError => e
|
63
63
|
Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
|
64
64
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Sass
|
2
|
+
module CacheStores
|
3
|
+
# A meta-cache that chains multiple caches together.
|
4
|
+
# Specifically:
|
5
|
+
#
|
6
|
+
# * All `#store`s are passed to all caches.
|
7
|
+
# * `#retrieve`s are passed to each cache until one has a hit.
|
8
|
+
# * When one cache has a hit, the value is `#store`d in all earlier caches.
|
9
|
+
class Chain < Base
|
10
|
+
# Create a new cache chaining the given caches.
|
11
|
+
#
|
12
|
+
# @param caches [Array<Sass::CacheStores::Base>] The caches to chain.
|
13
|
+
def initialize(*caches)
|
14
|
+
@caches = caches
|
15
|
+
end
|
16
|
+
|
17
|
+
# @see Base#store
|
18
|
+
def store(key, sha, obj)
|
19
|
+
@caches.each {|c| c.store(key, sha, obj)}
|
20
|
+
end
|
21
|
+
|
22
|
+
# @see Base#retrieve
|
23
|
+
def retrieve(key, sha)
|
24
|
+
@caches.each_with_index do |c, i|
|
25
|
+
next unless obj = c.retrieve(key, sha)
|
26
|
+
@caches[0...i].each {|c| c.store(key, sha, obj)}
|
27
|
+
return obj
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -24,22 +24,18 @@ module Sass
|
|
24
24
|
@contents = {}
|
25
25
|
end
|
26
26
|
|
27
|
-
# @see Base#
|
28
|
-
def
|
27
|
+
# @see Base#retrieve
|
28
|
+
def retrieve(key, sha)
|
29
29
|
if @contents.has_key?(key)
|
30
|
-
return unless @contents[key][:version] == version
|
31
30
|
return unless @contents[key][:sha] == sha
|
32
|
-
|
31
|
+
obj = @contents[key][:obj]
|
32
|
+
obj.respond_to?(:deep_copy) ? obj.deep_copy : obj.dup
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
36
|
-
# @see Base#
|
37
|
-
def
|
38
|
-
@contents[key] = {
|
39
|
-
:version => version,
|
40
|
-
:sha => sha,
|
41
|
-
:contents => contents
|
42
|
-
}
|
35
|
+
|
36
|
+
# @see Base#store
|
37
|
+
def store(key, sha, obj)
|
38
|
+
@contents[key] = {:sha => sha, :obj => obj}
|
43
39
|
end
|
44
40
|
|
45
41
|
# Destructively clear the cache.
|
data/lib/sass/engine.rb
CHANGED
@@ -164,7 +164,8 @@ module Sass
|
|
164
164
|
# Tracks the original filename of the top-level Sass file
|
165
165
|
options[:original_filename] = options[:original_filename] || options[:filename]
|
166
166
|
|
167
|
-
options[:cache_store] ||= Sass::CacheStores::
|
167
|
+
options[:cache_store] ||= Sass::CacheStores::Chain.new(
|
168
|
+
Sass::CacheStores::Memory.new, Sass::CacheStores::Filesystem.new(options[:cache_location]))
|
168
169
|
# Support both, because the docs said one and the other actually worked
|
169
170
|
# for quite a long time.
|
170
171
|
options[:line_comments] ||= options[:line_numbers]
|
@@ -333,7 +334,15 @@ module Sass
|
|
333
334
|
end
|
334
335
|
|
335
336
|
root.options = @options
|
336
|
-
|
337
|
+
if @options[:cache] && key && sha
|
338
|
+
begin
|
339
|
+
old_options = root.options
|
340
|
+
root.options = {:importer => root.options[:importer]}
|
341
|
+
@options[:cache_store].store(key, sha, root)
|
342
|
+
ensure
|
343
|
+
root.options = old_options
|
344
|
+
end
|
345
|
+
end
|
337
346
|
root
|
338
347
|
rescue SyntaxError => e
|
339
348
|
e.modify_backtrace(:filename => @options[:filename], :line => @line)
|
@@ -90,9 +90,15 @@ module Sass::Script
|
|
90
90
|
#
|
91
91
|
# ## Other Color Functions
|
92
92
|
#
|
93
|
-
# \{#adjust adjust($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
|
93
|
+
# \{#adjust adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
|
94
94
|
# : Increase or decrease any of the components of a color.
|
95
95
|
#
|
96
|
+
# \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
|
97
|
+
# : Fluidly scale one or more components of a color.
|
98
|
+
#
|
99
|
+
# \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
|
100
|
+
# : Changes one or more properties of a color.
|
101
|
+
#
|
96
102
|
# ## String Functions
|
97
103
|
#
|
98
104
|
# \{#unquote unquote($string)}
|
@@ -729,9 +735,9 @@ module Sass::Script
|
|
729
735
|
# and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
|
730
736
|
#
|
731
737
|
# @example
|
732
|
-
# adjust(#102030, $blue: 5) => #102035
|
733
|
-
# adjust(#102030, $red: -5, $blue: 5) => #0b2035
|
734
|
-
# adjust(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
|
738
|
+
# adjust-color(#102030, $blue: 5) => #102035
|
739
|
+
# adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
|
740
|
+
# adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
|
735
741
|
# @param color [Color]
|
736
742
|
# @param red [Number]
|
737
743
|
# @param green [Number]
|
@@ -746,7 +752,7 @@ module Sass::Script
|
|
746
752
|
# if any keyword argument is not in the legal range,
|
747
753
|
# if an unexpected keyword argument is given,
|
748
754
|
# or if both HSL and RGB properties are given.
|
749
|
-
def
|
755
|
+
def adjust_color(color, kwargs)
|
750
756
|
assert_type color, :Color
|
751
757
|
with = Sass::Util.map_hash({
|
752
758
|
"red" => [-255..255, ""],
|
@@ -775,7 +781,7 @@ module Sass::Script
|
|
775
781
|
|
776
782
|
color.with(with)
|
777
783
|
end
|
778
|
-
declare :
|
784
|
+
declare :adjust_color, [:color], :var_kwargs => true
|
779
785
|
|
780
786
|
# Scales one or more properties of a color by a percentage value.
|
781
787
|
# Unlike \{#adjust}, which changes a color's properties by fixed amounts,
|
@@ -783,13 +789,13 @@ module Sass::Script
|
|
783
789
|
# That means that lightening an already-light color with \{#scale}
|
784
790
|
# won't change the lightness much,
|
785
791
|
# but lightening a dark color by the same amount will change it more dramatically.
|
786
|
-
# This has the benefit of making `scale($color, ...)` have a similar effect
|
792
|
+
# This has the benefit of making `scale-color($color, ...)` have a similar effect
|
787
793
|
# regardless of what `$color` is.
|
788
794
|
#
|
789
795
|
# For example, the lightness of a color can be anywhere between 0 and 100.
|
790
|
-
# If `scale($color, $lightness: 40%)` is called, the resulting color's lightness
|
796
|
+
# If `scale-color($color, $lightness: 40%)` is called, the resulting color's lightness
|
791
797
|
# will be 40% of the way between its original lightness and 100.
|
792
|
-
# If `scale($color, $lightness: -40%)` is called instead,
|
798
|
+
# If `scale-color($color, $lightness: -40%)` is called instead,
|
793
799
|
# the lightness will be 40% of the way between the original and 0.
|
794
800
|
#
|
795
801
|
# This can change the red, green, blue, saturation, value, and alpha properties.
|
@@ -801,9 +807,9 @@ module Sass::Script
|
|
801
807
|
# and HSL properties (`$saturation`, `$value`) at the same time.
|
802
808
|
#
|
803
809
|
# @example
|
804
|
-
# scale(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
|
805
|
-
# scale(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
|
806
|
-
# scale(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
|
810
|
+
# scale-color(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
|
811
|
+
# scale-color(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
|
812
|
+
# scale-color(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
|
807
813
|
# @param color [Color]
|
808
814
|
# @param red [Number]
|
809
815
|
# @param green [Number]
|
@@ -816,7 +822,7 @@ module Sass::Script
|
|
816
822
|
# if any keyword argument is not a percentage between 0% and 100%,
|
817
823
|
# if an unexpected keyword argument is given,
|
818
824
|
# or if both HSL and RGB properties are given.
|
819
|
-
def
|
825
|
+
def scale_color(color, kwargs)
|
820
826
|
assert_type color, :Color
|
821
827
|
with = Sass::Util.map_hash({
|
822
828
|
"red" => 255,
|
@@ -848,10 +854,10 @@ module Sass::Script
|
|
848
854
|
|
849
855
|
color.with(with)
|
850
856
|
end
|
851
|
-
declare :
|
857
|
+
declare :scale_color, [:color], :var_kwargs => true
|
852
858
|
|
853
|
-
#
|
854
|
-
# This can
|
859
|
+
# Changes one or more properties of a color.
|
860
|
+
# This can change the red, green, blue, hue, saturation, value, and alpha properties.
|
855
861
|
# The properties are specified as keyword arguments,
|
856
862
|
# and replace the color's current value for that property.
|
857
863
|
#
|
@@ -864,9 +870,9 @@ module Sass::Script
|
|
864
870
|
# and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
|
865
871
|
#
|
866
872
|
# @example
|
867
|
-
#
|
868
|
-
#
|
869
|
-
#
|
873
|
+
# change-color(#102030, $blue: 5) => #102005
|
874
|
+
# change-color(#102030, $red: 120, $blue: 5) => #782005
|
875
|
+
# change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
|
870
876
|
# @param color [Color]
|
871
877
|
# @param red [Number]
|
872
878
|
# @param green [Number]
|
@@ -881,7 +887,7 @@ module Sass::Script
|
|
881
887
|
# if any keyword argument is not in the legal range,
|
882
888
|
# if an unexpected keyword argument is given,
|
883
889
|
# or if both HSL and RGB properties are given.
|
884
|
-
def
|
890
|
+
def change_color(color, kwargs)
|
885
891
|
assert_type color, :Color
|
886
892
|
with = Sass::Util.map_hash(%w[red green blue hue saturation lightness alpha]) do |name, max|
|
887
893
|
next unless val = kwargs.delete(name)
|
@@ -896,7 +902,7 @@ module Sass::Script
|
|
896
902
|
|
897
903
|
color.with(with)
|
898
904
|
end
|
899
|
-
declare :
|
905
|
+
declare :change_color, [:color], :var_kwargs => true
|
900
906
|
|
901
907
|
# Mixes together two colors.
|
902
908
|
# Specifically, takes the average of each of the RGB components,
|
data/lib/sass/tree/if_node.rb
CHANGED
@@ -41,23 +41,22 @@ module Sass::Tree
|
|
41
41
|
self.else.options = options if self.else
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
old_else = @else
|
47
|
-
old_last_else = @last_else
|
48
|
-
@else = Sass::Util.dump(@else)
|
49
|
-
@last_else = (self == @last_else ? nil : Sass::Util.dump(@last_else))
|
50
|
-
super
|
51
|
-
ensure
|
52
|
-
@else = old_else
|
53
|
-
@last_else = old_last_else
|
44
|
+
def _dump(f)
|
45
|
+
Marshal.dump([self.expr, self.else])
|
54
46
|
end
|
55
47
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
48
|
+
def self._load(data)
|
49
|
+
expr, else_ = Marshal.load(data)
|
50
|
+
node = IfNode.new(expr)
|
51
|
+
node.else = else_
|
52
|
+
node
|
53
|
+
end
|
54
|
+
|
55
|
+
# @see Node#deep_copy
|
56
|
+
def deep_copy
|
57
|
+
node = super
|
58
|
+
node.else = self.else.deep_copy if self.else
|
59
|
+
node
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/sass/tree/node.rb
CHANGED
@@ -180,29 +180,14 @@ module Sass
|
|
180
180
|
Sass::Tree::Visitors::Convert.visit(self, options, :scss)
|
181
181
|
end
|
182
182
|
|
183
|
-
#
|
184
|
-
|
185
|
-
|
186
|
-
#
|
187
|
-
def
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
SAVED_OPTIONS.each do |opt|
|
192
|
-
@options[opt] = old_options[opt]
|
193
|
-
end
|
194
|
-
@options = Sass::Util.dump(@options)
|
195
|
-
@children = Sass::Util.dump(@children)
|
196
|
-
yield
|
197
|
-
ensure
|
198
|
-
@options = old_options
|
199
|
-
@children = old_children
|
200
|
-
end
|
201
|
-
|
202
|
-
# Ensures that only {SAVED_OPTIONS} get saved.
|
203
|
-
def _after_load
|
204
|
-
@options = Sass::Util.load(@options)
|
205
|
-
@children = Sass::Util.load(@children)
|
183
|
+
# Return a deep clone of this node.
|
184
|
+
# The child nodes are cloned, but options are not.
|
185
|
+
#
|
186
|
+
# @return [Node]
|
187
|
+
def deep_copy
|
188
|
+
node = dup
|
189
|
+
node.children = children.map {|c| c.deep_copy}
|
190
|
+
node
|
206
191
|
end
|
207
192
|
|
208
193
|
protected
|
data/lib/sass/util.rb
CHANGED
@@ -270,47 +270,6 @@ module Sass
|
|
270
270
|
version_gt(v1, v2) || !version_gt(v2, v1)
|
271
271
|
end
|
272
272
|
|
273
|
-
# A wrapper for `Marshal.dump` that calls `#_before_dump` on the object
|
274
|
-
# before dumping it, `#_after_dump` afterwards.
|
275
|
-
# It also calls `#_around_dump` and passes it a block in which the object is dumped.
|
276
|
-
#
|
277
|
-
# If any of these methods are undefined, they are not called.
|
278
|
-
#
|
279
|
-
# This will recursively call itself on members of arrays and hashes,
|
280
|
-
# but not of user-defined objects.
|
281
|
-
# This means that user-defined objects that need their members' `#_before_dump` etc. methods called
|
282
|
-
# must call `Haml::Util.dump` and `Haml::Util.load` manually on those members.
|
283
|
-
#
|
284
|
-
# @param obj [Object] The object to dump.
|
285
|
-
# @return [String] The dumped data.
|
286
|
-
def dump(obj)
|
287
|
-
obj._before_dump if obj.respond_to?(:_before_dump)
|
288
|
-
return convert_and_dump(obj) unless obj.respond_to?(:_around_dump)
|
289
|
-
res = nil
|
290
|
-
obj._around_dump {res = convert_and_dump(obj)}
|
291
|
-
res
|
292
|
-
ensure
|
293
|
-
obj._after_dump if obj.respond_to?(:_after_dump)
|
294
|
-
end
|
295
|
-
|
296
|
-
# A wrapper for `Marshal.load` that calls `#_after_load` on the object
|
297
|
-
# after loading it, if it's defined.
|
298
|
-
#
|
299
|
-
# @param data [String] The data to load.
|
300
|
-
# @return [Object] The loaded object.
|
301
|
-
def load(data)
|
302
|
-
obj = Marshal.load(data)
|
303
|
-
|
304
|
-
if obj.is_a?(Array)
|
305
|
-
obj = obj.map {|e| Sass::Util.load(e)}
|
306
|
-
elsif obj.is_a?(Hash)
|
307
|
-
obj = map_hash(obj) {|k, v| [Sass::Util.load(k), Sass::Util.load(v)]}
|
308
|
-
end
|
309
|
-
|
310
|
-
obj._after_load if obj.respond_to?(:_after_load)
|
311
|
-
obj
|
312
|
-
end
|
313
|
-
|
314
273
|
# Throws a NotImplementedError for an abstract method.
|
315
274
|
#
|
316
275
|
# @param obj [Object] `self`
|
@@ -706,14 +665,5 @@ MSG
|
|
706
665
|
return lcs_backtrace(c, x, y, i, j-1, &block) if c[i][j-1] > c[i-1][j]
|
707
666
|
return lcs_backtrace(c, x, y, i-1, j, &block)
|
708
667
|
end
|
709
|
-
|
710
|
-
def convert_and_dump(obj)
|
711
|
-
if obj.is_a?(Array)
|
712
|
-
obj = obj.map {|e| dump(e)}
|
713
|
-
elsif obj.is_a?(Hash)
|
714
|
-
obj = map_hash(obj) {|k, v| [dump(k), dump(v)]}
|
715
|
-
end
|
716
|
-
Marshal.dump(obj)
|
717
|
-
end
|
718
668
|
end
|
719
669
|
end
|
data/test/sass/functions_test.rb
CHANGED
@@ -461,274 +461,274 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
461
461
|
assert_error_message("\"foo\" is not a number for `adjust-hue'", "adjust-hue(#fff, \"foo\")")
|
462
462
|
end
|
463
463
|
|
464
|
-
def
|
464
|
+
def test_adjust_color
|
465
465
|
# HSL
|
466
466
|
assert_equal(evaluate("hsl(180, 30, 90)"),
|
467
|
-
evaluate("adjust(hsl(120, 30, 90), $hue: 60deg)"))
|
467
|
+
evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg)"))
|
468
468
|
assert_equal(evaluate("hsl(120, 50, 90)"),
|
469
|
-
evaluate("adjust(hsl(120, 30, 90), $saturation: 20%)"))
|
469
|
+
evaluate("adjust-color(hsl(120, 30, 90), $saturation: 20%)"))
|
470
470
|
assert_equal(evaluate("hsl(120, 30, 60)"),
|
471
|
-
evaluate("adjust(hsl(120, 30, 90), $lightness: -30%)"))
|
471
|
+
evaluate("adjust-color(hsl(120, 30, 90), $lightness: -30%)"))
|
472
472
|
# RGB
|
473
473
|
assert_equal(evaluate("rgb(15, 20, 30)"),
|
474
|
-
evaluate("adjust(rgb(10, 20, 30), $red: 5)"))
|
474
|
+
evaluate("adjust-color(rgb(10, 20, 30), $red: 5)"))
|
475
475
|
assert_equal(evaluate("rgb(10, 15, 30)"),
|
476
|
-
evaluate("adjust(rgb(10, 20, 30), $green: -5)"))
|
476
|
+
evaluate("adjust-color(rgb(10, 20, 30), $green: -5)"))
|
477
477
|
assert_equal(evaluate("rgb(10, 20, 40)"),
|
478
|
-
evaluate("adjust(rgb(10, 20, 30), $blue: 10)"))
|
478
|
+
evaluate("adjust-color(rgb(10, 20, 30), $blue: 10)"))
|
479
479
|
# Alpha
|
480
480
|
assert_equal(evaluate("hsla(120, 30, 90, 0.65)"),
|
481
|
-
evaluate("adjust(hsl(120, 30, 90), $alpha: -0.35)"))
|
481
|
+
evaluate("adjust-color(hsl(120, 30, 90), $alpha: -0.35)"))
|
482
482
|
assert_equal(evaluate("rgba(10, 20, 30, 0.9)"),
|
483
|
-
evaluate("adjust(rgba(10, 20, 30, 0.4), $alpha: 0.5)"))
|
483
|
+
evaluate("adjust-color(rgba(10, 20, 30, 0.4), $alpha: 0.5)"))
|
484
484
|
|
485
485
|
# HSL composability
|
486
486
|
assert_equal(evaluate("hsl(180, 20, 90)"),
|
487
|
-
evaluate("adjust(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%)"))
|
487
|
+
evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%)"))
|
488
488
|
assert_equal(evaluate("hsl(180, 20, 95)"),
|
489
|
-
evaluate("adjust(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%, $lightness: 5%)"))
|
489
|
+
evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%, $lightness: 5%)"))
|
490
490
|
assert_equal(evaluate("hsla(120, 20, 95, 0.3)"),
|
491
|
-
evaluate("adjust(hsl(120, 30, 90), $saturation: -10%, $lightness: 5%, $alpha: -0.7)"))
|
491
|
+
evaluate("adjust-color(hsl(120, 30, 90), $saturation: -10%, $lightness: 5%, $alpha: -0.7)"))
|
492
492
|
|
493
493
|
# RGB composability
|
494
494
|
assert_equal(evaluate("rgb(15, 20, 29)"),
|
495
|
-
evaluate("adjust(rgb(10, 20, 30), $red: 5, $blue: -1)"))
|
495
|
+
evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $blue: -1)"))
|
496
496
|
assert_equal(evaluate("rgb(15, 45, 29)"),
|
497
|
-
evaluate("adjust(rgb(10, 20, 30), $red: 5, $green: 25, $blue: -1)"))
|
497
|
+
evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $green: 25, $blue: -1)"))
|
498
498
|
assert_equal(evaluate("rgba(10, 25, 29, 0.7)"),
|
499
|
-
evaluate("adjust(rgb(10, 20, 30), $green: 5, $blue: -1, $alpha: -0.3)"))
|
499
|
+
evaluate("adjust-color(rgb(10, 20, 30), $green: 5, $blue: -1, $alpha: -0.3)"))
|
500
500
|
|
501
501
|
# HSL range restriction
|
502
502
|
assert_equal(evaluate("hsl(120, 30, 90)"),
|
503
|
-
evaluate("adjust(hsl(120, 30, 90), $hue: 720deg)"))
|
503
|
+
evaluate("adjust-color(hsl(120, 30, 90), $hue: 720deg)"))
|
504
504
|
assert_equal(evaluate("hsl(120, 0, 90)"),
|
505
|
-
evaluate("adjust(hsl(120, 30, 90), $saturation: -90%)"))
|
505
|
+
evaluate("adjust-color(hsl(120, 30, 90), $saturation: -90%)"))
|
506
506
|
assert_equal(evaluate("hsl(120, 30, 100)"),
|
507
|
-
evaluate("adjust(hsl(120, 30, 90), $lightness: 30%)"))
|
507
|
+
evaluate("adjust-color(hsl(120, 30, 90), $lightness: 30%)"))
|
508
508
|
|
509
509
|
# RGB range restriction
|
510
510
|
assert_equal(evaluate("rgb(255, 20, 30)"),
|
511
|
-
evaluate("adjust(rgb(10, 20, 30), $red: 250)"))
|
511
|
+
evaluate("adjust-color(rgb(10, 20, 30), $red: 250)"))
|
512
512
|
assert_equal(evaluate("rgb(10, 0, 30)"),
|
513
|
-
evaluate("adjust(rgb(10, 20, 30), $green: -30)"))
|
513
|
+
evaluate("adjust-color(rgb(10, 20, 30), $green: -30)"))
|
514
514
|
assert_equal(evaluate("rgb(10, 20, 0)"),
|
515
|
-
evaluate("adjust(rgb(10, 20, 30), $blue: -40)"))
|
515
|
+
evaluate("adjust-color(rgb(10, 20, 30), $blue: -40)"))
|
516
516
|
end
|
517
517
|
|
518
|
-
def
|
519
|
-
assert_error_message("\"foo\" is not a color for `adjust'", "adjust(foo, $hue: 10)")
|
518
|
+
def test_adjust_color_tests_types
|
519
|
+
assert_error_message("\"foo\" is not a color for `adjust-color'", "adjust-color(foo, $hue: 10)")
|
520
520
|
# HSL
|
521
|
-
assert_error_message("$hue: \"foo\" is not a number for `adjust'",
|
522
|
-
"adjust(blue, $hue: foo)")
|
523
|
-
assert_error_message("$saturation: \"foo\" is not a number for `adjust'",
|
524
|
-
"adjust(blue, $saturation: foo)")
|
525
|
-
assert_error_message("$lightness: \"foo\" is not a number for `adjust'",
|
526
|
-
"adjust(blue, $lightness: foo)")
|
521
|
+
assert_error_message("$hue: \"foo\" is not a number for `adjust-color'",
|
522
|
+
"adjust-color(blue, $hue: foo)")
|
523
|
+
assert_error_message("$saturation: \"foo\" is not a number for `adjust-color'",
|
524
|
+
"adjust-color(blue, $saturation: foo)")
|
525
|
+
assert_error_message("$lightness: \"foo\" is not a number for `adjust-color'",
|
526
|
+
"adjust-color(blue, $lightness: foo)")
|
527
527
|
# RGB
|
528
|
-
assert_error_message("$red: \"foo\" is not a number for `adjust'",
|
529
|
-
"adjust(blue, $red: foo)")
|
530
|
-
assert_error_message("$green: \"foo\" is not a number for `adjust'",
|
531
|
-
"adjust(blue, $green: foo)")
|
532
|
-
assert_error_message("$blue: \"foo\" is not a number for `adjust'",
|
533
|
-
"adjust(blue, $blue: foo)")
|
528
|
+
assert_error_message("$red: \"foo\" is not a number for `adjust-color'",
|
529
|
+
"adjust-color(blue, $red: foo)")
|
530
|
+
assert_error_message("$green: \"foo\" is not a number for `adjust-color'",
|
531
|
+
"adjust-color(blue, $green: foo)")
|
532
|
+
assert_error_message("$blue: \"foo\" is not a number for `adjust-color'",
|
533
|
+
"adjust-color(blue, $blue: foo)")
|
534
534
|
# Alpha
|
535
|
-
assert_error_message("$alpha: \"foo\" is not a number for `adjust'",
|
536
|
-
"adjust(blue, $alpha: foo)")
|
535
|
+
assert_error_message("$alpha: \"foo\" is not a number for `adjust-color'",
|
536
|
+
"adjust-color(blue, $alpha: foo)")
|
537
537
|
end
|
538
538
|
|
539
|
-
def
|
539
|
+
def test_adjust_color_tests_arg_range
|
540
540
|
# HSL
|
541
|
-
assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `adjust'",
|
542
|
-
"adjust(blue, $saturation: 101%)")
|
543
|
-
assert_error_message("$saturation: Amount -101% must be between -100% and 100% for `adjust'",
|
544
|
-
"adjust(blue, $saturation: -101%)")
|
545
|
-
assert_error_message("$lightness: Amount 101% must be between -100% and 100% for `adjust'",
|
546
|
-
"adjust(blue, $lightness: 101%)")
|
547
|
-
assert_error_message("$lightness: Amount -101% must be between -100% and 100% for `adjust'",
|
548
|
-
"adjust(blue, $lightness: -101%)")
|
541
|
+
assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `adjust-color'",
|
542
|
+
"adjust-color(blue, $saturation: 101%)")
|
543
|
+
assert_error_message("$saturation: Amount -101% must be between -100% and 100% for `adjust-color'",
|
544
|
+
"adjust-color(blue, $saturation: -101%)")
|
545
|
+
assert_error_message("$lightness: Amount 101% must be between -100% and 100% for `adjust-color'",
|
546
|
+
"adjust-color(blue, $lightness: 101%)")
|
547
|
+
assert_error_message("$lightness: Amount -101% must be between -100% and 100% for `adjust-color'",
|
548
|
+
"adjust-color(blue, $lightness: -101%)")
|
549
549
|
# RGB
|
550
|
-
assert_error_message("$red: Amount 256 must be between -255 and 255 for `adjust'",
|
551
|
-
"adjust(blue, $red: 256)")
|
552
|
-
assert_error_message("$red: Amount -256 must be between -255 and 255 for `adjust'",
|
553
|
-
"adjust(blue, $red: -256)")
|
554
|
-
assert_error_message("$green: Amount 256 must be between -255 and 255 for `adjust'",
|
555
|
-
"adjust(blue, $green: 256)")
|
556
|
-
assert_error_message("$green: Amount -256 must be between -255 and 255 for `adjust'",
|
557
|
-
"adjust(blue, $green: -256)")
|
558
|
-
assert_error_message("$blue: Amount 256 must be between -255 and 255 for `adjust'",
|
559
|
-
"adjust(blue, $blue: 256)")
|
560
|
-
assert_error_message("$blue: Amount -256 must be between -255 and 255 for `adjust'",
|
561
|
-
"adjust(blue, $blue: -256)")
|
550
|
+
assert_error_message("$red: Amount 256 must be between -255 and 255 for `adjust-color'",
|
551
|
+
"adjust-color(blue, $red: 256)")
|
552
|
+
assert_error_message("$red: Amount -256 must be between -255 and 255 for `adjust-color'",
|
553
|
+
"adjust-color(blue, $red: -256)")
|
554
|
+
assert_error_message("$green: Amount 256 must be between -255 and 255 for `adjust-color'",
|
555
|
+
"adjust-color(blue, $green: 256)")
|
556
|
+
assert_error_message("$green: Amount -256 must be between -255 and 255 for `adjust-color'",
|
557
|
+
"adjust-color(blue, $green: -256)")
|
558
|
+
assert_error_message("$blue: Amount 256 must be between -255 and 255 for `adjust-color'",
|
559
|
+
"adjust-color(blue, $blue: 256)")
|
560
|
+
assert_error_message("$blue: Amount -256 must be between -255 and 255 for `adjust-color'",
|
561
|
+
"adjust-color(blue, $blue: -256)")
|
562
562
|
# Alpha
|
563
|
-
assert_error_message("$alpha: Amount 1.1 must be between -1 and 1 for `adjust'",
|
564
|
-
"adjust(blue, $alpha: 1.1)")
|
565
|
-
assert_error_message("$alpha: Amount -1.1 must be between -1 and 1 for `adjust'",
|
566
|
-
"adjust(blue, $alpha: -1.1)")
|
567
|
-
end
|
568
|
-
|
569
|
-
def
|
570
|
-
assert_error_message("Unknown argument $hoo (260deg) for `adjust'",
|
571
|
-
"adjust(blue, $hoo: 260deg)")
|
572
|
-
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `adjust'",
|
573
|
-
"adjust(blue, $hue: 120deg, $red: 10)");
|
574
|
-
assert_error_message("10px is not a keyword argument for `
|
575
|
-
"adjust(blue, 10px)")
|
576
|
-
assert_error_message("10px is not a keyword argument for `
|
577
|
-
"adjust(blue, 10px, 20px)")
|
578
|
-
assert_error_message("10px is not a keyword argument for `
|
579
|
-
"adjust(blue, 10px, $hue: 180deg)")
|
580
|
-
end
|
581
|
-
|
582
|
-
def
|
563
|
+
assert_error_message("$alpha: Amount 1.1 must be between -1 and 1 for `adjust-color'",
|
564
|
+
"adjust-color(blue, $alpha: 1.1)")
|
565
|
+
assert_error_message("$alpha: Amount -1.1 must be between -1 and 1 for `adjust-color'",
|
566
|
+
"adjust-color(blue, $alpha: -1.1)")
|
567
|
+
end
|
568
|
+
|
569
|
+
def test_adjust_color_argument_errors
|
570
|
+
assert_error_message("Unknown argument $hoo (260deg) for `adjust-color'",
|
571
|
+
"adjust-color(blue, $hoo: 260deg)")
|
572
|
+
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `adjust-color'",
|
573
|
+
"adjust-color(blue, $hue: 120deg, $red: 10)");
|
574
|
+
assert_error_message("10px is not a keyword argument for `adjust_color'",
|
575
|
+
"adjust-color(blue, 10px)")
|
576
|
+
assert_error_message("10px is not a keyword argument for `adjust_color'",
|
577
|
+
"adjust-color(blue, 10px, 20px)")
|
578
|
+
assert_error_message("10px is not a keyword argument for `adjust_color'",
|
579
|
+
"adjust-color(blue, 10px, $hue: 180deg)")
|
580
|
+
end
|
581
|
+
|
582
|
+
def test_scale_color
|
583
583
|
# HSL
|
584
584
|
assert_equal(evaluate("hsl(120, 51, 90)"),
|
585
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: 30%)"))
|
585
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%)"))
|
586
586
|
assert_equal(evaluate("hsl(120, 30, 76.5)"),
|
587
|
-
evaluate("scale(hsl(120, 30, 90), $lightness: -15%)"))
|
587
|
+
evaluate("scale-color(hsl(120, 30, 90), $lightness: -15%)"))
|
588
588
|
# RGB
|
589
589
|
assert_equal(evaluate("rgb(157, 20, 30)"),
|
590
|
-
evaluate("scale(rgb(10, 20, 30), $red: 60%)"))
|
590
|
+
evaluate("scale-color(rgb(10, 20, 30), $red: 60%)"))
|
591
591
|
assert_equal(evaluate("rgb(10, 38.8, 30)"),
|
592
|
-
evaluate("scale(rgb(10, 20, 30), $green: 8%)"))
|
592
|
+
evaluate("scale-color(rgb(10, 20, 30), $green: 8%)"))
|
593
593
|
assert_equal(evaluate("rgb(10, 20, 20)"),
|
594
|
-
evaluate("scale(rgb(10, 20, 30), $blue: -(1/3)*100%)"))
|
594
|
+
evaluate("scale-color(rgb(10, 20, 30), $blue: -(1/3)*100%)"))
|
595
595
|
# Alpha
|
596
596
|
assert_equal(evaluate("hsla(120, 30, 90, 0.86)"),
|
597
|
-
evaluate("scale(hsl(120, 30, 90), $alpha: -14%)"))
|
597
|
+
evaluate("scale-color(hsl(120, 30, 90), $alpha: -14%)"))
|
598
598
|
assert_equal(evaluate("rgba(10, 20, 30, 0.82)"),
|
599
|
-
evaluate("scale(rgba(10, 20, 30, 0.8), $alpha: 10%)"))
|
599
|
+
evaluate("scale-color(rgba(10, 20, 30, 0.8), $alpha: 10%)"))
|
600
600
|
|
601
601
|
# HSL composability
|
602
602
|
assert_equal(evaluate("hsl(120, 51, 76.5)"),
|
603
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: 30%, $lightness: -15%)"))
|
603
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $lightness: -15%)"))
|
604
604
|
assert_equal(evaluate("hsla(120, 51, 90, 0.2)"),
|
605
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: 30%, $alpha: -80%)"))
|
605
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $alpha: -80%)"))
|
606
606
|
|
607
607
|
# RGB composability
|
608
608
|
assert_equal(evaluate("rgb(157, 38.8, 30)"),
|
609
|
-
evaluate("scale(rgb(10, 20, 30), $red: 60%, $green: 8%)"))
|
609
|
+
evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%)"))
|
610
610
|
assert_equal(evaluate("rgb(157, 38.8, 20)"),
|
611
|
-
evaluate("scale(rgb(10, 20, 30), $red: 60%, $green: 8%, $blue: -(1/3)*100%)"))
|
611
|
+
evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%, $blue: -(1/3)*100%)"))
|
612
612
|
assert_equal(evaluate("rgba(10, 38.8, 20, 0.55)"),
|
613
|
-
evaluate("scale(rgba(10, 20, 30, 0.5), $green: 8%, $blue: -(1/3)*100%, $alpha: 10%)"))
|
613
|
+
evaluate("scale-color(rgba(10, 20, 30, 0.5), $green: 8%, $blue: -(1/3)*100%, $alpha: 10%)"))
|
614
614
|
|
615
615
|
# Extremes
|
616
616
|
assert_equal(evaluate("hsl(120, 100, 90)"),
|
617
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: 100%)"))
|
617
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: 100%)"))
|
618
618
|
assert_equal(evaluate("hsl(120, 30, 90)"),
|
619
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: 0%)"))
|
619
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: 0%)"))
|
620
620
|
assert_equal(evaluate("hsl(120, 0, 90)"),
|
621
|
-
evaluate("scale(hsl(120, 30, 90), $saturation: -100%)"))
|
621
|
+
evaluate("scale-color(hsl(120, 30, 90), $saturation: -100%)"))
|
622
622
|
end
|
623
623
|
|
624
|
-
def
|
625
|
-
assert_error_message("\"foo\" is not a color for `scale'", "scale(foo, $red: 10%)")
|
624
|
+
def test_scale_color_tests_types
|
625
|
+
assert_error_message("\"foo\" is not a color for `scale-color'", "scale-color(foo, $red: 10%)")
|
626
626
|
# HSL
|
627
|
-
assert_error_message("$saturation: \"foo\" is not a number for `scale'",
|
628
|
-
"scale(blue, $saturation: foo)")
|
629
|
-
assert_error_message("$lightness: \"foo\" is not a number for `scale'",
|
630
|
-
"scale(blue, $lightness: foo)")
|
627
|
+
assert_error_message("$saturation: \"foo\" is not a number for `scale-color'",
|
628
|
+
"scale-color(blue, $saturation: foo)")
|
629
|
+
assert_error_message("$lightness: \"foo\" is not a number for `scale-color'",
|
630
|
+
"scale-color(blue, $lightness: foo)")
|
631
631
|
# RGB
|
632
|
-
assert_error_message("$red: \"foo\" is not a number for `scale'",
|
633
|
-
"scale(blue, $red: foo)")
|
634
|
-
assert_error_message("$green: \"foo\" is not a number for `scale'",
|
635
|
-
"scale(blue, $green: foo)")
|
636
|
-
assert_error_message("$blue: \"foo\" is not a number for `scale'",
|
637
|
-
"scale(blue, $blue: foo)")
|
632
|
+
assert_error_message("$red: \"foo\" is not a number for `scale-color'",
|
633
|
+
"scale-color(blue, $red: foo)")
|
634
|
+
assert_error_message("$green: \"foo\" is not a number for `scale-color'",
|
635
|
+
"scale-color(blue, $green: foo)")
|
636
|
+
assert_error_message("$blue: \"foo\" is not a number for `scale-color'",
|
637
|
+
"scale-color(blue, $blue: foo)")
|
638
638
|
# Alpha
|
639
|
-
assert_error_message("$alpha: \"foo\" is not a number for `scale'",
|
640
|
-
"scale(blue, $alpha: foo)")
|
639
|
+
assert_error_message("$alpha: \"foo\" is not a number for `scale-color'",
|
640
|
+
"scale-color(blue, $alpha: foo)")
|
641
641
|
end
|
642
642
|
|
643
|
-
def
|
643
|
+
def test_scale_color_argument_errors
|
644
644
|
# Range
|
645
|
-
assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `scale'",
|
646
|
-
"scale(blue, $saturation: 101%)")
|
647
|
-
assert_error_message("$red: Amount -101% must be between -100% and 100% for `scale'",
|
648
|
-
"scale(blue, $red: -101%)")
|
649
|
-
assert_error_message("$alpha: Amount -101% must be between -100% and 100% for `scale'",
|
650
|
-
"scale(blue, $alpha: -101%)")
|
645
|
+
assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `scale-color'",
|
646
|
+
"scale-color(blue, $saturation: 101%)")
|
647
|
+
assert_error_message("$red: Amount -101% must be between -100% and 100% for `scale-color'",
|
648
|
+
"scale-color(blue, $red: -101%)")
|
649
|
+
assert_error_message("$alpha: Amount -101% must be between -100% and 100% for `scale-color'",
|
650
|
+
"scale-color(blue, $alpha: -101%)")
|
651
651
|
|
652
652
|
# Unit
|
653
|
-
assert_error_message("$saturation: Amount 80 must be a % (e.g. 80%) for `scale'",
|
654
|
-
"scale(blue, $saturation: 80)")
|
655
|
-
assert_error_message("$alpha: Amount 0.5 must be a % (e.g. 0.5%) for `scale'",
|
656
|
-
"scale(blue, $alpha: 0.5)")
|
653
|
+
assert_error_message("$saturation: Amount 80 must be a % (e.g. 80%) for `scale-color'",
|
654
|
+
"scale-color(blue, $saturation: 80)")
|
655
|
+
assert_error_message("$alpha: Amount 0.5 must be a % (e.g. 0.5%) for `scale-color'",
|
656
|
+
"scale-color(blue, $alpha: 0.5)")
|
657
657
|
|
658
658
|
# Unknown argument
|
659
|
-
assert_error_message("Unknown argument $hue (80%) for `scale'", "scale(blue, $hue: 80%)")
|
659
|
+
assert_error_message("Unknown argument $hue (80%) for `scale-color'", "scale-color(blue, $hue: 80%)")
|
660
660
|
|
661
661
|
# Non-keyword arg
|
662
|
-
assert_error_message("10px is not a keyword argument for `
|
662
|
+
assert_error_message("10px is not a keyword argument for `scale_color'", "scale-color(blue, 10px)")
|
663
663
|
|
664
664
|
# HSL/RGB
|
665
|
-
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `scale'",
|
666
|
-
"scale(blue, $lightness: 10%, $red: 20%)");
|
665
|
+
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `scale-color'",
|
666
|
+
"scale-color(blue, $lightness: 10%, $red: 20%)");
|
667
667
|
end
|
668
668
|
|
669
|
-
def
|
669
|
+
def test_change_color
|
670
670
|
# HSL
|
671
671
|
assert_equal(evaluate("hsl(195, 30, 90)"),
|
672
|
-
evaluate("
|
672
|
+
evaluate("change-color(hsl(120, 30, 90), $hue: 195deg)"))
|
673
673
|
assert_equal(evaluate("hsl(120, 50, 90)"),
|
674
|
-
evaluate("
|
674
|
+
evaluate("change-color(hsl(120, 30, 90), $saturation: 50%)"))
|
675
675
|
assert_equal(evaluate("hsl(120, 30, 40)"),
|
676
|
-
evaluate("
|
676
|
+
evaluate("change-color(hsl(120, 30, 90), $lightness: 40%)"))
|
677
677
|
# RGB
|
678
678
|
assert_equal(evaluate("rgb(123, 20, 30)"),
|
679
|
-
evaluate("
|
679
|
+
evaluate("change-color(rgb(10, 20, 30), $red: 123)"))
|
680
680
|
assert_equal(evaluate("rgb(10, 234, 30)"),
|
681
|
-
evaluate("
|
681
|
+
evaluate("change-color(rgb(10, 20, 30), $green: 234)"))
|
682
682
|
assert_equal(evaluate("rgb(10, 20, 198)"),
|
683
|
-
evaluate("
|
683
|
+
evaluate("change-color(rgb(10, 20, 30), $blue: 198)"))
|
684
684
|
# Alpha
|
685
685
|
assert_equal(evaluate("rgba(10, 20, 30, 0.76)"),
|
686
|
-
evaluate("
|
686
|
+
evaluate("change-color(rgb(10, 20, 30), $alpha: 0.76)"))
|
687
687
|
|
688
688
|
# HSL composability
|
689
689
|
assert_equal(evaluate("hsl(56, 30, 47)"),
|
690
|
-
evaluate("
|
690
|
+
evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%)"))
|
691
691
|
assert_equal(evaluate("hsla(56, 30, 47, 0.9)"),
|
692
|
-
evaluate("
|
692
|
+
evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%, $alpha: 0.9)"))
|
693
693
|
end
|
694
694
|
|
695
|
-
def
|
696
|
-
assert_error_message("\"foo\" is not a color for `
|
695
|
+
def test_change_color_tests_types
|
696
|
+
assert_error_message("\"foo\" is not a color for `change-color'", "change-color(foo, $red: 10%)")
|
697
697
|
# HSL
|
698
|
-
assert_error_message("$saturation: \"foo\" is not a number for `
|
699
|
-
"
|
700
|
-
assert_error_message("$lightness: \"foo\" is not a number for `
|
701
|
-
"
|
698
|
+
assert_error_message("$saturation: \"foo\" is not a number for `change-color'",
|
699
|
+
"change-color(blue, $saturation: foo)")
|
700
|
+
assert_error_message("$lightness: \"foo\" is not a number for `change-color'",
|
701
|
+
"change-color(blue, $lightness: foo)")
|
702
702
|
# RGB
|
703
|
-
assert_error_message("$red: \"foo\" is not a number for `
|
704
|
-
assert_error_message("$green: \"foo\" is not a number for `
|
705
|
-
assert_error_message("$blue: \"foo\" is not a number for `
|
703
|
+
assert_error_message("$red: \"foo\" is not a number for `change-color'", "change-color(blue, $red: foo)")
|
704
|
+
assert_error_message("$green: \"foo\" is not a number for `change-color'", "change-color(blue, $green: foo)")
|
705
|
+
assert_error_message("$blue: \"foo\" is not a number for `change-color'", "change-color(blue, $blue: foo)")
|
706
706
|
# Alpha
|
707
|
-
assert_error_message("$alpha: \"foo\" is not a number for `
|
707
|
+
assert_error_message("$alpha: \"foo\" is not a number for `change-color'", "change-color(blue, $alpha: foo)")
|
708
708
|
end
|
709
709
|
|
710
|
-
def
|
710
|
+
def test_change_color_argument_errors
|
711
711
|
# Range
|
712
|
-
assert_error_message("Saturation must be between 0 and 100 for `
|
713
|
-
"
|
714
|
-
assert_error_message("Lightness must be between 0 and 100 for `
|
715
|
-
"
|
716
|
-
assert_error_message("Red value must be between 0 and 255 for `
|
717
|
-
"
|
718
|
-
assert_error_message("Green value must be between 0 and 255 for `
|
719
|
-
"
|
720
|
-
assert_error_message("Blue value must be between 0 and 255 for `
|
721
|
-
"
|
712
|
+
assert_error_message("Saturation must be between 0 and 100 for `change-color'",
|
713
|
+
"change-color(blue, $saturation: 101%)")
|
714
|
+
assert_error_message("Lightness must be between 0 and 100 for `change-color'",
|
715
|
+
"change-color(blue, $lightness: 101%)")
|
716
|
+
assert_error_message("Red value must be between 0 and 255 for `change-color'",
|
717
|
+
"change-color(blue, $red: -1)")
|
718
|
+
assert_error_message("Green value must be between 0 and 255 for `change-color'",
|
719
|
+
"change-color(blue, $green: 256)")
|
720
|
+
assert_error_message("Blue value must be between 0 and 255 for `change-color'",
|
721
|
+
"change-color(blue, $blue: 500)")
|
722
722
|
|
723
723
|
# Unknown argument
|
724
|
-
assert_error_message("Unknown argument $hoo (80%) for `
|
724
|
+
assert_error_message("Unknown argument $hoo (80%) for `change-color'", "change-color(blue, $hoo: 80%)")
|
725
725
|
|
726
726
|
# Non-keyword arg
|
727
|
-
assert_error_message("10px is not a keyword argument for `
|
727
|
+
assert_error_message("10px is not a keyword argument for `change_color'", "change-color(blue, 10px)")
|
728
728
|
|
729
729
|
# HSL/RGB
|
730
|
-
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `
|
731
|
-
"
|
730
|
+
assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `change-color'",
|
731
|
+
"change-color(blue, $lightness: 10%, $red: 120)");
|
732
732
|
end
|
733
733
|
|
734
734
|
def test_mix
|
data/test/sass/importer_test.rb
CHANGED
@@ -5,8 +5,6 @@ require File.dirname(__FILE__) + '/test_helper'
|
|
5
5
|
class ImporterTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
class FruitImporter < Sass::Importers::Base
|
8
|
-
attr_reader :cached
|
9
|
-
|
10
8
|
def find(name, context = nil)
|
11
9
|
if name =~ %r{fruits/(\w+)(\.s[ac]ss)?}
|
12
10
|
fruit = $1
|
@@ -31,13 +29,6 @@ class ImporterTest < Test::Unit::TestCase
|
|
31
29
|
def key(name, context)
|
32
30
|
[self.class.name, name]
|
33
31
|
end
|
34
|
-
|
35
|
-
def _around_dump
|
36
|
-
@cached = true
|
37
|
-
yield
|
38
|
-
ensure
|
39
|
-
@cached = false
|
40
|
-
end
|
41
32
|
end
|
42
33
|
|
43
34
|
# This class proves that you can override the extension scheme for importers
|
@@ -88,17 +79,4 @@ CSS
|
|
88
79
|
ensure
|
89
80
|
FileUtils.rm_rf(absolutize("tmp"))
|
90
81
|
end
|
91
|
-
|
92
|
-
def test_caching_importer
|
93
|
-
source = "p\n foo: bar"
|
94
|
-
importer = FruitImporter.new
|
95
|
-
filename = filename_for_test
|
96
|
-
engine = Sass::Engine.new(source, :filename => filename, :importer => importer)
|
97
|
-
engine.to_tree # Trigger caching
|
98
|
-
|
99
|
-
sha = Digest::SHA1.hexdigest(source)
|
100
|
-
cache = engine.options[:cache_store]
|
101
|
-
cached_tree = cache.retrieve(cache.key(*importer.key(filename, engine.options)), sha)
|
102
|
-
assert cached_tree.options[:importer].cached, "Importer's _around_dump method should have been called"
|
103
|
-
end
|
104
82
|
end
|
data/test/sass/util_test.rb
CHANGED
@@ -5,19 +5,6 @@ require 'pathname'
|
|
5
5
|
class UtilTest < Test::Unit::TestCase
|
6
6
|
include Sass::Util
|
7
7
|
|
8
|
-
class Dumpable
|
9
|
-
attr_reader :arr
|
10
|
-
def initialize; @arr = []; end
|
11
|
-
def _before_dump; @arr << :before; end
|
12
|
-
def _after_dump; @arr << :after; end
|
13
|
-
def _around_dump
|
14
|
-
@arr << :around_before
|
15
|
-
yield
|
16
|
-
@arr << :around_after
|
17
|
-
end
|
18
|
-
def _after_load; @arr << :loaded; end
|
19
|
-
end
|
20
|
-
|
21
8
|
def test_scope
|
22
9
|
assert(File.exist?(scope("Rakefile")))
|
23
10
|
end
|
@@ -253,14 +240,6 @@ class UtilTest < Test::Unit::TestCase
|
|
253
240
|
assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}")
|
254
241
|
end
|
255
242
|
|
256
|
-
def test_dump_and_load
|
257
|
-
obj = Dumpable.new
|
258
|
-
data = dump(obj)
|
259
|
-
assert_equal([:before, :around_before, :around_after, :after], obj.arr)
|
260
|
-
obj2 = load(data)
|
261
|
-
assert_equal([:before, :around_before, :loaded], obj2.arr)
|
262
|
-
end
|
263
|
-
|
264
243
|
class FooBar
|
265
244
|
def foo
|
266
245
|
Sass::Util.abstract(self)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.alpha.
|
4
|
+
version: 3.1.0.alpha.212
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2011-01-13 00:00:00 -05:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/sass/cache_stores/filesystem.rb
|
64
64
|
- lib/sass/cache_stores/memory.rb
|
65
65
|
- lib/sass/cache_stores/null.rb
|
66
|
+
- lib/sass/cache_stores/chain.rb
|
66
67
|
- lib/sass/plugin/configuration.rb
|
67
68
|
- lib/sass/plugin/merb.rb
|
68
69
|
- lib/sass/plugin/generic.rb
|