Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'origin/master'

Conflicts:
	lib/sass/script/functions.rb
  • Loading branch information...
commit ebf9e326dafba548aef36fe36945d97a9dd590d9 2 parents a2a17ed + e18890b
@nex3 nex3 authored
View
18 doc-src/SASS_CHANGELOG.md
@@ -62,33 +62,33 @@ that use keywords to encompass a large amount of functionality in one function.
* The {Sass::Script::Functions#adjust adjust} function works like the old
`lighten`, `saturate`, and `adjust-hue` methods.
It increases and/or decreases the values of a color's properties by fixed amounts.
- For example, `adjust($color, $lightness: 10%)` is the same as `lighten($color, 10%)`:
+ For example, `adjust-color($color, $lightness: 10%)` is the same as `lighten($color, 10%)`:
it returns `$color` with its lightness increased by 10%.
-* The {Sass::Script::Functions#scale scale} function
+* The {Sass::Script::Functions#scale_color scale_color} function
is similar to {Sass::Script::Functions#adjust adjust},
but instead of increasing and/or decreasing a color's properties by fixed amounts,
it scales them fluidly by percentages.
The closer the percentage is to 100% (or -100%),
the closer the new property value will be to its maximum (or minimum).
- For example, `scale(hsl(120, 70, 80), $lightness: 50%)`
+ For example, `scale-color(hsl(120, 70, 80), $lightness: 50%)`
will change the lightness from 80% to 90%,
because 90% is halfway between 80% and 100%.
- Similarly, `scale(hsl(120, 70, 50), $lightness: 50%)`
+ Similarly, `scale-color(hsl(120, 70, 50), $lightness: 50%)`
will change the lightness from 50% to 75%.
-* The {Sass::Script::Functions#set set} function simply sets a color's properties
+* The {Sass::Script::Functions#change_color change-color} function simply changes a color's properties
regardless of their old values.
- For example `set($color, $lightness: 10%)` returns `$color` with 10% lightness,
- and `set($color, $alpha: 0.7)` returns color with opacity 0.7.
+ For example `change-color($color, $lightness: 10%)` returns `$color` with 10% lightness,
+ and `change-color($color, $alpha: 0.7)` returns color with opacity 0.7.
Each keyword function accepts `$hue`, `$saturation`, `$value`,
`$red`, `$green`, `$blue`, and `$alpha` keywords,
-with the exception of `scale()` which doesn't accept `$hue`.
+with the exception of `scale-color()` which doesn't accept `$hue`.
These keywords modify the respective properties of the given color.
Each keyword function can modify multiple properties at once.
-For example, `adjust($color, $lightness: 15%, $saturation: -10%)`
+For example, `adjust-color($color, $lightness: 15%, $saturation: -10%)`
both lightens and desaturates `$color`.
HSL properties cannot be modified at the same time as RGB properties, though.
View
2  doc-src/SASS_REFERENCE.md
@@ -1098,7 +1098,7 @@ For example, if `example.scss` contains
then
#main {
- @import .example;
+ @import "example";
}
would compile to
View
9 lib/sass/script/funcall.rb
@@ -84,7 +84,7 @@ def _perform(environment)
args = construct_ruby_args(ruby_name, args, keywords)
unless Sass::Util.has?(:public_instance_method, Functions, ruby_name) && ruby_name !~ /^__/
- opts(Script::String.new("#{name}(#{args.join(', ')})"))
+ opts(to_literal(args))
else
opts(Functions::EvaluationContext.new(environment.options).send(ruby_name, *args))
end
@@ -93,6 +93,13 @@ def _perform(environment)
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
end
+ # This method is factored out from `_perform` so that compass can override
+ # it with a cross-browser implementation for functions that require vendor prefixes
+ # in the generated css.
+ def to_literal(args)
+ Script::String.new("#{name}(#{args.join(', ')})")
+ end
+
private
def construct_ruby_args(name, args, keywords)
View
57 lib/sass/script/functions.rb
@@ -90,14 +90,14 @@ module Sass::Script
#
# ## Other Color Functions
#
- # \{#adjust adjust($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
+ # \{#adjust adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
# : Increase or decrease any of the components of a color.
#
- # \{#scale scale($color, \[$red\], \[$green\], \[$blue\], \[$saturation\], \[$lightness\], \[$alpha\]}
- # : Fluidly scale any of the components of a color.
+ # \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
+ # : Fluidly scale one or more components of a color.
#
- # \{#set set($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
- # : Set any of the components of a color.
+ # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
+ # : Changes one or more properties of a color.
#
# ## String Functions
#
@@ -735,9 +735,9 @@ def adjust_hue(color, degrees)
# and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
#
# @example
- # adjust(#102030, $blue: 5) => #102035
- # adjust(#102030, $red: -5, $blue: 5) => #0b2035
- # adjust(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
+ # adjust-color(#102030, $blue: 5) => #102035
+ # adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
+ # adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
# @param color [Color]
# @param red [Number]
# @param green [Number]
@@ -752,7 +752,7 @@ def adjust_hue(color, degrees)
# if any keyword argument is not in the legal range,
# if an unexpected keyword argument is given,
# or if both HSL and RGB properties are given.
- def adjust(color, kwargs)
+ def adjust_color(color, kwargs)
assert_type color, :Color
with = Sass::Util.map_hash({
"red" => [-255..255, ""],
@@ -781,7 +781,7 @@ def adjust(color, kwargs)
color.with(with)
end
- declare :adjust, [:color], :var_kwargs => true
+ declare :adjust_color, [:color], :var_kwargs => true
# Scales one or more properties of a color by a percentage value.
# Unlike \{#adjust}, which changes a color's properties by fixed amounts,
@@ -789,13 +789,13 @@ def adjust(color, kwargs)
# That means that lightening an already-light color with \{#scale}
# won't change the lightness much,
# but lightening a dark color by the same amount will change it more dramatically.
- # This has the benefit of making `scale($color, ...)` have a similar effect
+ # This has the benefit of making `scale-color($color, ...)` have a similar effect
# regardless of what `$color` is.
#
# For example, the lightness of a color can be anywhere between 0 and 100.
- # If `scale($color, $lightness: 40%)` is called, the resulting color's lightness
+ # If `scale-color($color, $lightness: 40%)` is called, the resulting color's lightness
# will be 40% of the way between its original lightness and 100.
- # If `scale($color, $lightness: -40%)` is called instead,
+ # If `scale-color($color, $lightness: -40%)` is called instead,
# the lightness will be 40% of the way between the original and 0.
#
# This can change the red, green, blue, saturation, value, and alpha properties.
@@ -807,9 +807,9 @@ def adjust(color, kwargs)
# and HSL properties (`$saturation`, `$value`) at the same time.
#
# @example
- # scale(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
- # scale(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
- # scale(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
+ # scale-color(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
+ # scale-color(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
+ # scale-color(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
# @param color [Color]
# @param red [Number]
# @param green [Number]
@@ -822,7 +822,7 @@ def adjust(color, kwargs)
# if any keyword argument is not a percentage between 0% and 100%,
# if an unexpected keyword argument is given,
# or if both HSL and RGB properties are given.
- def scale(color, kwargs)
+ def scale_color(color, kwargs)
assert_type color, :Color
with = Sass::Util.map_hash({
"red" => 255,
@@ -854,10 +854,10 @@ def scale(color, kwargs)
color.with(with)
end
- declare :scale, [:color], :var_kwargs => true
+ declare :scale_color, [:color], :var_kwargs => true
- # Sets on or more properties of a color.
- # This can set the red, green, blue, hue, saturation, value, and alpha properties.
+ # Changes one or more properties of a color.
+ # This can change the red, green, blue, hue, saturation, value, and alpha properties.
# The properties are specified as keyword arguments,
# and replace the color's current value for that property.
#
@@ -870,9 +870,9 @@ def scale(color, kwargs)
# and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
#
# @example
- # set(#102030, $blue: 5) => #102005
- # set(#102030, $red: 120, $blue: 5) => #782005
- # set(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
+ # change-color(#102030, $blue: 5) => #102005
+ # change-color(#102030, $red: 120, $blue: 5) => #782005
+ # change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
# @param color [Color]
# @param red [Number]
# @param green [Number]
@@ -887,7 +887,7 @@ def scale(color, kwargs)
# if any keyword argument is not in the legal range,
# if an unexpected keyword argument is given,
# or if both HSL and RGB properties are given.
- def set(color, kwargs)
+ def change_color(color, kwargs)
assert_type color, :Color
with = Sass::Util.map_hash(%w[red green blue hue saturation lightness alpha]) do |name, max|
next unless val = kwargs.delete(name)
@@ -902,7 +902,7 @@ def set(color, kwargs)
color.with(with)
end
- declare :set, [:color], :var_kwargs => true
+ declare :change_color, [:color], :var_kwargs => true
# Mixes together two colors.
# Specifically, takes the average of each of the RGB components,
@@ -1019,8 +1019,11 @@ def invert(color)
# unquote("foo") => foo
# unquote(foo) => foo
def unquote(string)
- assert_type string, :String
- Sass::Script::String.new(string.value, :identifier)
+ if string.is_a?(Sass::Script::String)
+ Sass::Script::String.new(string.value, :identifier)
+ else
+ string
+ end
end
declare :unquote, [:string]
View
318 test/sass/functions_test.rb
@@ -461,274 +461,274 @@ def test_adjust_hue_tests_types
assert_error_message("\"foo\" is not a number for `adjust-hue'", "adjust-hue(#fff, \"foo\")")
end
- def test_adjust
+ def test_adjust_color
# HSL
assert_equal(evaluate("hsl(180, 30, 90)"),
- evaluate("adjust(hsl(120, 30, 90), $hue: 60deg)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg)"))
assert_equal(evaluate("hsl(120, 50, 90)"),
- evaluate("adjust(hsl(120, 30, 90), $saturation: 20%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: 20%)"))
assert_equal(evaluate("hsl(120, 30, 60)"),
- evaluate("adjust(hsl(120, 30, 90), $lightness: -30%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $lightness: -30%)"))
# RGB
assert_equal(evaluate("rgb(15, 20, 30)"),
- evaluate("adjust(rgb(10, 20, 30), $red: 5)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5)"))
assert_equal(evaluate("rgb(10, 15, 30)"),
- evaluate("adjust(rgb(10, 20, 30), $green: -5)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $green: -5)"))
assert_equal(evaluate("rgb(10, 20, 40)"),
- evaluate("adjust(rgb(10, 20, 30), $blue: 10)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $blue: 10)"))
# Alpha
assert_equal(evaluate("hsla(120, 30, 90, 0.65)"),
- evaluate("adjust(hsl(120, 30, 90), $alpha: -0.35)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $alpha: -0.35)"))
assert_equal(evaluate("rgba(10, 20, 30, 0.9)"),
- evaluate("adjust(rgba(10, 20, 30, 0.4), $alpha: 0.5)"))
+ evaluate("adjust-color(rgba(10, 20, 30, 0.4), $alpha: 0.5)"))
# HSL composability
assert_equal(evaluate("hsl(180, 20, 90)"),
- evaluate("adjust(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%)"))
assert_equal(evaluate("hsl(180, 20, 95)"),
- evaluate("adjust(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%, $lightness: 5%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%, $lightness: 5%)"))
assert_equal(evaluate("hsla(120, 20, 95, 0.3)"),
- evaluate("adjust(hsl(120, 30, 90), $saturation: -10%, $lightness: 5%, $alpha: -0.7)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: -10%, $lightness: 5%, $alpha: -0.7)"))
# RGB composability
assert_equal(evaluate("rgb(15, 20, 29)"),
- evaluate("adjust(rgb(10, 20, 30), $red: 5, $blue: -1)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $blue: -1)"))
assert_equal(evaluate("rgb(15, 45, 29)"),
- evaluate("adjust(rgb(10, 20, 30), $red: 5, $green: 25, $blue: -1)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $green: 25, $blue: -1)"))
assert_equal(evaluate("rgba(10, 25, 29, 0.7)"),
- evaluate("adjust(rgb(10, 20, 30), $green: 5, $blue: -1, $alpha: -0.3)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $green: 5, $blue: -1, $alpha: -0.3)"))
# HSL range restriction
assert_equal(evaluate("hsl(120, 30, 90)"),
- evaluate("adjust(hsl(120, 30, 90), $hue: 720deg)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 720deg)"))
assert_equal(evaluate("hsl(120, 0, 90)"),
- evaluate("adjust(hsl(120, 30, 90), $saturation: -90%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: -90%)"))
assert_equal(evaluate("hsl(120, 30, 100)"),
- evaluate("adjust(hsl(120, 30, 90), $lightness: 30%)"))
+ evaluate("adjust-color(hsl(120, 30, 90), $lightness: 30%)"))
# RGB range restriction
assert_equal(evaluate("rgb(255, 20, 30)"),
- evaluate("adjust(rgb(10, 20, 30), $red: 250)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 250)"))
assert_equal(evaluate("rgb(10, 0, 30)"),
- evaluate("adjust(rgb(10, 20, 30), $green: -30)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $green: -30)"))
assert_equal(evaluate("rgb(10, 20, 0)"),
- evaluate("adjust(rgb(10, 20, 30), $blue: -40)"))
+ evaluate("adjust-color(rgb(10, 20, 30), $blue: -40)"))
end
- def test_adjust_tests_types
- assert_error_message("\"foo\" is not a color for `adjust'", "adjust(foo, $hue: 10)")
+ def test_adjust_color_tests_types
+ assert_error_message("\"foo\" is not a color for `adjust-color'", "adjust-color(foo, $hue: 10)")
# HSL
- assert_error_message("$hue: \"foo\" is not a number for `adjust'",
- "adjust(blue, $hue: foo)")
- assert_error_message("$saturation: \"foo\" is not a number for `adjust'",
- "adjust(blue, $saturation: foo)")
- assert_error_message("$lightness: \"foo\" is not a number for `adjust'",
- "adjust(blue, $lightness: foo)")
+ assert_error_message("$hue: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $hue: foo)")
+ assert_error_message("$saturation: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $saturation: foo)")
+ assert_error_message("$lightness: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $lightness: foo)")
# RGB
- assert_error_message("$red: \"foo\" is not a number for `adjust'",
- "adjust(blue, $red: foo)")
- assert_error_message("$green: \"foo\" is not a number for `adjust'",
- "adjust(blue, $green: foo)")
- assert_error_message("$blue: \"foo\" is not a number for `adjust'",
- "adjust(blue, $blue: foo)")
+ assert_error_message("$red: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $red: foo)")
+ assert_error_message("$green: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $green: foo)")
+ assert_error_message("$blue: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $blue: foo)")
# Alpha
- assert_error_message("$alpha: \"foo\" is not a number for `adjust'",
- "adjust(blue, $alpha: foo)")
+ assert_error_message("$alpha: \"foo\" is not a number for `adjust-color'",
+ "adjust-color(blue, $alpha: foo)")
end
- def test_adjust_tests_arg_range
+ def test_adjust_color_tests_arg_range
# HSL
- assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `adjust'",
- "adjust(blue, $saturation: 101%)")
- assert_error_message("$saturation: Amount -101% must be between -100% and 100% for `adjust'",
- "adjust(blue, $saturation: -101%)")
- assert_error_message("$lightness: Amount 101% must be between -100% and 100% for `adjust'",
- "adjust(blue, $lightness: 101%)")
- assert_error_message("$lightness: Amount -101% must be between -100% and 100% for `adjust'",
- "adjust(blue, $lightness: -101%)")
+ assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `adjust-color'",
+ "adjust-color(blue, $saturation: 101%)")
+ assert_error_message("$saturation: Amount -101% must be between -100% and 100% for `adjust-color'",
+ "adjust-color(blue, $saturation: -101%)")
+ assert_error_message("$lightness: Amount 101% must be between -100% and 100% for `adjust-color'",
+ "adjust-color(blue, $lightness: 101%)")
+ assert_error_message("$lightness: Amount -101% must be between -100% and 100% for `adjust-color'",
+ "adjust-color(blue, $lightness: -101%)")
# RGB
- assert_error_message("$red: Amount 256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $red: 256)")
- assert_error_message("$red: Amount -256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $red: -256)")
- assert_error_message("$green: Amount 256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $green: 256)")
- assert_error_message("$green: Amount -256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $green: -256)")
- assert_error_message("$blue: Amount 256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $blue: 256)")
- assert_error_message("$blue: Amount -256 must be between -255 and 255 for `adjust'",
- "adjust(blue, $blue: -256)")
+ assert_error_message("$red: Amount 256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $red: 256)")
+ assert_error_message("$red: Amount -256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $red: -256)")
+ assert_error_message("$green: Amount 256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $green: 256)")
+ assert_error_message("$green: Amount -256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $green: -256)")
+ assert_error_message("$blue: Amount 256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $blue: 256)")
+ assert_error_message("$blue: Amount -256 must be between -255 and 255 for `adjust-color'",
+ "adjust-color(blue, $blue: -256)")
# Alpha
- assert_error_message("$alpha: Amount 1.1 must be between -1 and 1 for `adjust'",
- "adjust(blue, $alpha: 1.1)")
- assert_error_message("$alpha: Amount -1.1 must be between -1 and 1 for `adjust'",
- "adjust(blue, $alpha: -1.1)")
- end
-
- def test_adjust_argument_errors
- assert_error_message("Unknown argument $hoo (260deg) for `adjust'",
- "adjust(blue, $hoo: 260deg)")
- assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `adjust'",
- "adjust(blue, $hue: 120deg, $red: 10)");
- assert_error_message("10px is not a keyword argument for `adjust'",
- "adjust(blue, 10px)")
- assert_error_message("10px is not a keyword argument for `adjust'",
- "adjust(blue, 10px, 20px)")
- assert_error_message("10px is not a keyword argument for `adjust'",
- "adjust(blue, 10px, $hue: 180deg)")
- end
-
- def test_scale
+ assert_error_message("$alpha: Amount 1.1 must be between -1 and 1 for `adjust-color'",
+ "adjust-color(blue, $alpha: 1.1)")
+ assert_error_message("$alpha: Amount -1.1 must be between -1 and 1 for `adjust-color'",
+ "adjust-color(blue, $alpha: -1.1)")
+ end
+
+ def test_adjust_color_argument_errors
+ assert_error_message("Unknown argument $hoo (260deg) for `adjust-color'",
+ "adjust-color(blue, $hoo: 260deg)")
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `adjust-color'",
+ "adjust-color(blue, $hue: 120deg, $red: 10)");
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
+ "adjust-color(blue, 10px)")
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
+ "adjust-color(blue, 10px, 20px)")
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
+ "adjust-color(blue, 10px, $hue: 180deg)")
+ end
+
+ def test_scale_color
# HSL
assert_equal(evaluate("hsl(120, 51, 90)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: 30%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%)"))
assert_equal(evaluate("hsl(120, 30, 76.5)"),
- evaluate("scale(hsl(120, 30, 90), $lightness: -15%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $lightness: -15%)"))
# RGB
assert_equal(evaluate("rgb(157, 20, 30)"),
- evaluate("scale(rgb(10, 20, 30), $red: 60%)"))
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%)"))
assert_equal(evaluate("rgb(10, 38.8, 30)"),
- evaluate("scale(rgb(10, 20, 30), $green: 8%)"))
+ evaluate("scale-color(rgb(10, 20, 30), $green: 8%)"))
assert_equal(evaluate("rgb(10, 20, 20)"),
- evaluate("scale(rgb(10, 20, 30), $blue: -(1/3)*100%)"))
+ evaluate("scale-color(rgb(10, 20, 30), $blue: -(1/3)*100%)"))
# Alpha
assert_equal(evaluate("hsla(120, 30, 90, 0.86)"),
- evaluate("scale(hsl(120, 30, 90), $alpha: -14%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $alpha: -14%)"))
assert_equal(evaluate("rgba(10, 20, 30, 0.82)"),
- evaluate("scale(rgba(10, 20, 30, 0.8), $alpha: 10%)"))
+ evaluate("scale-color(rgba(10, 20, 30, 0.8), $alpha: 10%)"))
# HSL composability
assert_equal(evaluate("hsl(120, 51, 76.5)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: 30%, $lightness: -15%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $lightness: -15%)"))
assert_equal(evaluate("hsla(120, 51, 90, 0.2)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: 30%, $alpha: -80%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $alpha: -80%)"))
# RGB composability
assert_equal(evaluate("rgb(157, 38.8, 30)"),
- evaluate("scale(rgb(10, 20, 30), $red: 60%, $green: 8%)"))
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%)"))
assert_equal(evaluate("rgb(157, 38.8, 20)"),
- evaluate("scale(rgb(10, 20, 30), $red: 60%, $green: 8%, $blue: -(1/3)*100%)"))
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%, $blue: -(1/3)*100%)"))
assert_equal(evaluate("rgba(10, 38.8, 20, 0.55)"),
- evaluate("scale(rgba(10, 20, 30, 0.5), $green: 8%, $blue: -(1/3)*100%, $alpha: 10%)"))
+ evaluate("scale-color(rgba(10, 20, 30, 0.5), $green: 8%, $blue: -(1/3)*100%, $alpha: 10%)"))
# Extremes
assert_equal(evaluate("hsl(120, 100, 90)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: 100%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 100%)"))
assert_equal(evaluate("hsl(120, 30, 90)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: 0%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 0%)"))
assert_equal(evaluate("hsl(120, 0, 90)"),
- evaluate("scale(hsl(120, 30, 90), $saturation: -100%)"))
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: -100%)"))
end
- def test_scale_tests_types
- assert_error_message("\"foo\" is not a color for `scale'", "scale(foo, $red: 10%)")
+ def test_scale_color_tests_types
+ assert_error_message("\"foo\" is not a color for `scale-color'", "scale-color(foo, $red: 10%)")
# HSL
- assert_error_message("$saturation: \"foo\" is not a number for `scale'",
- "scale(blue, $saturation: foo)")
- assert_error_message("$lightness: \"foo\" is not a number for `scale'",
- "scale(blue, $lightness: foo)")
+ assert_error_message("$saturation: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $saturation: foo)")
+ assert_error_message("$lightness: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $lightness: foo)")
# RGB
- assert_error_message("$red: \"foo\" is not a number for `scale'",
- "scale(blue, $red: foo)")
- assert_error_message("$green: \"foo\" is not a number for `scale'",
- "scale(blue, $green: foo)")
- assert_error_message("$blue: \"foo\" is not a number for `scale'",
- "scale(blue, $blue: foo)")
+ assert_error_message("$red: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $red: foo)")
+ assert_error_message("$green: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $green: foo)")
+ assert_error_message("$blue: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $blue: foo)")
# Alpha
- assert_error_message("$alpha: \"foo\" is not a number for `scale'",
- "scale(blue, $alpha: foo)")
+ assert_error_message("$alpha: \"foo\" is not a number for `scale-color'",
+ "scale-color(blue, $alpha: foo)")
end
- def test_scale_argument_errors
+ def test_scale_color_argument_errors
# Range
- assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `scale'",
- "scale(blue, $saturation: 101%)")
- assert_error_message("$red: Amount -101% must be between -100% and 100% for `scale'",
- "scale(blue, $red: -101%)")
- assert_error_message("$alpha: Amount -101% must be between -100% and 100% for `scale'",
- "scale(blue, $alpha: -101%)")
+ assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `scale-color'",
+ "scale-color(blue, $saturation: 101%)")
+ assert_error_message("$red: Amount -101% must be between -100% and 100% for `scale-color'",
+ "scale-color(blue, $red: -101%)")
+ assert_error_message("$alpha: Amount -101% must be between -100% and 100% for `scale-color'",
+ "scale-color(blue, $alpha: -101%)")
# Unit
- assert_error_message("$saturation: Amount 80 must be a % (e.g. 80%) for `scale'",
- "scale(blue, $saturation: 80)")
- assert_error_message("$alpha: Amount 0.5 must be a % (e.g. 0.5%) for `scale'",
- "scale(blue, $alpha: 0.5)")
+ assert_error_message("$saturation: Amount 80 must be a % (e.g. 80%) for `scale-color'",
+ "scale-color(blue, $saturation: 80)")
+ assert_error_message("$alpha: Amount 0.5 must be a % (e.g. 0.5%) for `scale-color'",
+ "scale-color(blue, $alpha: 0.5)")
# Unknown argument
- assert_error_message("Unknown argument $hue (80%) for `scale'", "scale(blue, $hue: 80%)")
+ assert_error_message("Unknown argument $hue (80%) for `scale-color'", "scale-color(blue, $hue: 80%)")
# Non-keyword arg
- assert_error_message("10px is not a keyword argument for `scale'", "scale(blue, 10px)")
+ assert_error_message("10px is not a keyword argument for `scale_color'", "scale-color(blue, 10px)")
# HSL/RGB
- assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `scale'",
- "scale(blue, $lightness: 10%, $red: 20%)");
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `scale-color'",
+ "scale-color(blue, $lightness: 10%, $red: 20%)");
end
- def test_set
+ def test_change_color
# HSL
assert_equal(evaluate("hsl(195, 30, 90)"),
- evaluate("set(hsl(120, 30, 90), $hue: 195deg)"))
+ evaluate("change-color(hsl(120, 30, 90), $hue: 195deg)"))
assert_equal(evaluate("hsl(120, 50, 90)"),
- evaluate("set(hsl(120, 30, 90), $saturation: 50%)"))
+ evaluate("change-color(hsl(120, 30, 90), $saturation: 50%)"))
assert_equal(evaluate("hsl(120, 30, 40)"),
- evaluate("set(hsl(120, 30, 90), $lightness: 40%)"))
+ evaluate("change-color(hsl(120, 30, 90), $lightness: 40%)"))
# RGB
assert_equal(evaluate("rgb(123, 20, 30)"),
- evaluate("set(rgb(10, 20, 30), $red: 123)"))
+ evaluate("change-color(rgb(10, 20, 30), $red: 123)"))
assert_equal(evaluate("rgb(10, 234, 30)"),
- evaluate("set(rgb(10, 20, 30), $green: 234)"))
+ evaluate("change-color(rgb(10, 20, 30), $green: 234)"))
assert_equal(evaluate("rgb(10, 20, 198)"),
- evaluate("set(rgb(10, 20, 30), $blue: 198)"))
+ evaluate("change-color(rgb(10, 20, 30), $blue: 198)"))
# Alpha
assert_equal(evaluate("rgba(10, 20, 30, 0.76)"),
- evaluate("set(rgb(10, 20, 30), $alpha: 0.76)"))
+ evaluate("change-color(rgb(10, 20, 30), $alpha: 0.76)"))
# HSL composability
assert_equal(evaluate("hsl(56, 30, 47)"),
- evaluate("set(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%)"))
+ evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%)"))
assert_equal(evaluate("hsla(56, 30, 47, 0.9)"),
- evaluate("set(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%, $alpha: 0.9)"))
+ evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%, $alpha: 0.9)"))
end
- def test_set_tests_types
- assert_error_message("\"foo\" is not a color for `set'", "set(foo, $red: 10%)")
+ def test_change_color_tests_types
+ assert_error_message("\"foo\" is not a color for `change-color'", "change-color(foo, $red: 10%)")
# HSL
- assert_error_message("$saturation: \"foo\" is not a number for `set'",
- "set(blue, $saturation: foo)")
- assert_error_message("$lightness: \"foo\" is not a number for `set'",
- "set(blue, $lightness: foo)")
+ assert_error_message("$saturation: \"foo\" is not a number for `change-color'",
+ "change-color(blue, $saturation: foo)")
+ assert_error_message("$lightness: \"foo\" is not a number for `change-color'",
+ "change-color(blue, $lightness: foo)")
# RGB
- assert_error_message("$red: \"foo\" is not a number for `set'", "set(blue, $red: foo)")
- assert_error_message("$green: \"foo\" is not a number for `set'", "set(blue, $green: foo)")
- assert_error_message("$blue: \"foo\" is not a number for `set'", "set(blue, $blue: foo)")
+ assert_error_message("$red: \"foo\" is not a number for `change-color'", "change-color(blue, $red: foo)")
+ assert_error_message("$green: \"foo\" is not a number for `change-color'", "change-color(blue, $green: foo)")
+ assert_error_message("$blue: \"foo\" is not a number for `change-color'", "change-color(blue, $blue: foo)")
# Alpha
- assert_error_message("$alpha: \"foo\" is not a number for `set'", "set(blue, $alpha: foo)")
+ assert_error_message("$alpha: \"foo\" is not a number for `change-color'", "change-color(blue, $alpha: foo)")
end
- def test_set_argument_errors
+ def test_change_color_argument_errors
# Range
- assert_error_message("Saturation must be between 0 and 100 for `set'",
- "set(blue, $saturation: 101%)")
- assert_error_message("Lightness must be between 0 and 100 for `set'",
- "set(blue, $lightness: 101%)")
- assert_error_message("Red value must be between 0 and 255 for `set'",
- "set(blue, $red: -1)")
- assert_error_message("Green value must be between 0 and 255 for `set'",
- "set(blue, $green: 256)")
- assert_error_message("Blue value must be between 0 and 255 for `set'",
- "set(blue, $blue: 500)")
+ assert_error_message("Saturation must be between 0 and 100 for `change-color'",
+ "change-color(blue, $saturation: 101%)")
+ assert_error_message("Lightness must be between 0 and 100 for `change-color'",
+ "change-color(blue, $lightness: 101%)")
+ assert_error_message("Red value must be between 0 and 255 for `change-color'",
+ "change-color(blue, $red: -1)")
+ assert_error_message("Green value must be between 0 and 255 for `change-color'",
+ "change-color(blue, $green: 256)")
+ assert_error_message("Blue value must be between 0 and 255 for `change-color'",
+ "change-color(blue, $blue: 500)")
# Unknown argument
- assert_error_message("Unknown argument $hoo (80%) for `set'", "set(blue, $hoo: 80%)")
+ assert_error_message("Unknown argument $hoo (80%) for `change-color'", "change-color(blue, $hoo: 80%)")
# Non-keyword arg
- assert_error_message("10px is not a keyword argument for `set'", "set(blue, 10px)")
+ assert_error_message("10px is not a keyword argument for `change_color'", "change-color(blue, 10px)")
# HSL/RGB
- assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `set'",
- "set(blue, $lightness: 10%, $red: 120)");
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `change-color'",
+ "change-color(blue, $lightness: 10%, $red: 120)");
end
def test_mix
@@ -802,10 +802,6 @@ def test_unquote
assert_equal('foo', evaluate('unquote($string: foo)'))
end
- def test_unquote_tests_type
- assert_error_message("#ff0000 is not a string for `unquote'", "unquote(#f00)")
- end
-
def test_quote
assert_equal('"foo"', evaluate('quote(foo)'))
assert_equal('"foo"', evaluate('quote("foo")'))
Please sign in to comment.
Something went wrong with that request. Please try again.