diff --git a/src/spectest.rs b/src/spectest.rs index 40556b846..d18743e02 100644 --- a/src/spectest.rs +++ b/src/spectest.rs @@ -20,6 +20,7 @@ fn main() -> Result<(), Error> { "33_ambiguous_imports", // Need to handle separate files in tests ], )?; + handle_suite(&base, "core_functions", &[])?; handle_suite(&base, "colors", &[])?; handle_suite( &base, @@ -43,6 +44,7 @@ fn main() -> Result<(), Error> { ], )?; handle_suite(&base, "misc", &[])?; + handle_suite(&base, "mixin", &[])?; handle_suite(&base, "number-functions", &[])?; handle_suite(&base, "parser", &[])?; handle_suite( @@ -52,6 +54,7 @@ fn main() -> Result<(), Error> { "is_superselector", // multiple input files ], )?; + handle_suite(&base, "scope", &[])?; handle_suite( &base, "scss", @@ -61,6 +64,7 @@ fn main() -> Result<(), Error> { "huge", // stack overflow ], )?; + handle_suite(&base, "scss-tests", &[])?; handle_suite(&base, "values", &[])?; Ok(()) } diff --git a/tests/core_functions/color/hsl/basic/mod.rs b/tests/core_functions/color/hsl/basic/mod.rs new file mode 100644 index 000000000..15ae65944 --- /dev/null +++ b/tests/core_functions/color/hsl/basic/mod.rs @@ -0,0 +1,5 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/basic" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; diff --git a/tests/core_functions/color/hsl/error/four_args/mod.rs b/tests/core_functions/color/hsl/error/four_args/mod.rs new file mode 100644 index 000000000..026b8036d --- /dev/null +++ b/tests/core_functions/color/hsl/error/four_args/mod.rs @@ -0,0 +1,13 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/error/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "hue_type", tests with expected error not implemented yet. + +// Ignoring "lightness_type", tests with expected error not implemented yet. + +// Ignoring "saturation_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsl/error/mod.rs b/tests/core_functions/color/hsl/error/mod.rs new file mode 100644 index 000000000..54d7cfadb --- /dev/null +++ b/tests/core_functions/color/hsl/error/mod.rs @@ -0,0 +1,15 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "five_args", tests with expected error not implemented yet. + +mod four_args; + +mod one_arg; + +mod three_args; + +mod two_args; diff --git a/tests/core_functions/color/hsl/error/one_arg/mod.rs b/tests/core_functions/color/hsl/error/one_arg/mod.rs new file mode 100644 index 000000000..b40425bac --- /dev/null +++ b/tests/core_functions/color/hsl/error/one_arg/mod.rs @@ -0,0 +1,25 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/error/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "bracketed", tests with expected error not implemented yet. + +// Ignoring "comma_separated", tests with expected error not implemented yet. + +// Ignoring "empty", tests with expected error not implemented yet. + +// Ignoring "four_elements", tests with expected error not implemented yet. + +// Ignoring "hue_type", tests with expected error not implemented yet. + +// Ignoring "lightness_type", tests with expected error not implemented yet. + +// Ignoring "one_element", tests with expected error not implemented yet. + +// Ignoring "quoted_var_slash", tests with expected error not implemented yet. + +// Ignoring "saturation_type", tests with expected error not implemented yet. + +// Ignoring "two_elements", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsl/error/three_args/mod.rs b/tests/core_functions/color/hsl/error/three_args/mod.rs new file mode 100644 index 000000000..f5062965e --- /dev/null +++ b/tests/core_functions/color/hsl/error/three_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/error/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "hue_type", tests with expected error not implemented yet. + +// Ignoring "lightness_type", tests with expected error not implemented yet. + +// Ignoring "saturation_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsl/error/two_args/mod.rs b/tests/core_functions/color/hsl/error/two_args/mod.rs new file mode 100644 index 000000000..8aebc9b03 --- /dev/null +++ b/tests/core_functions/color/hsl/error/two_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/error/two_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_type", tests with expected error not implemented yet. + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "color_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsl/four_args/mod.rs b/tests/core_functions/color/hsl/four_args/mod.rs new file mode 100644 index 000000000..854e0b9dc --- /dev/null +++ b/tests/core_functions/color/hsl/four_args/mod.rs @@ -0,0 +1,57 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/hsl/four_args/alpha_percent" +#[test] +#[ignore] // failing +fn alpha_percent() { + assert_eq!( + rsass( + ".alpha-percent {\n negative: hsl(0, 0, 0, -10%);\n min: hsl(0, 0, 0, 0%);\n positive: hsl(0, 0, 0, 45.6%);\n max: hsl(0, 0, 0, 100%);\n above-max: hsl(0, 0, 0, 250%);\n}\n" + ) + .unwrap(), + ".alpha-percent {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/four_args/alpha_unitless" +#[test] +#[ignore] // failing +fn alpha_unitless() { + assert_eq!( + rsass( + ".alpha-unitless {\n negative: hsl(0, 0, 0, -10);\n min: hsl(0, 0, 0, 0);\n positive: hsl(0, 0, 0, 0.456);\n max: hsl(0, 0, 0, 1);\n above-max: hsl(0, 0, 0, 250);\n}\n" + ) + .unwrap(), + ".alpha-unitless {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/four_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "basic {\n transparent: hsl(180, 60%, 50%, 0);\n opaque: hsl(180, 60%, 50%, 1);\n partial: hsl(180, 60%, 50%, 0.5);\n named: hsl($hue: 180, $saturation: 60%, $lightness: 50%, $alpha: 0.4);\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n saturation: hsl(0, -0.1%, 50%, 0.5);\n blue: hsl(0, 100%, 9999%, 0.5);\n alpha-above: hsl(0, 100%, 50%, 1.1);\n alpha-below: rgba(0, 100%, 50%, -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(51, 204, 204, 0);\n opaque: #33cccc;\n partial: rgba(51, 204, 204, 0.5);\n named: rgba(51, 204, 204, 0.4);\n}\nclamped {\n saturation: rgba(128, 128, 128, 0.5);\n blue: rgba(255, 255, 255, 0.5);\n alpha-above: red;\n alpha-below: rgba(0, 255, 128, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/four_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: hsl(calc(1), 2%, 3%, 0.4);\n calc-2: hsl(1, calc(2%), 3%, 0.4);\n calc-3: hsl(1, 2%, calc(3%), 0.4);\n calc-4: hsl(1, 2%, 3%, calc(0.4));\n\n var-1: hsl(var(--foo), 2%, 3%, 0.4);\n var-2: hsl(1, var(--foo), 3%, 0.4);\n var-3: hsl(1, 2%, var(--foo), 0.4);\n var-4: hsl(1, 2%, 3%, var(--foo));\n\n env-1: hsl(env(--foo), 2%, 3%, 0.4);\n env-2: hsl(1, env(--foo), 3%, 0.4);\n env-3: hsl(1, 2%, env(--foo), 0.4);\n env-4: hsl(1, 2%, 3%, env(--foo));\n\n min-1: hsl(min(1), 2%, 3%, 0.4);\n min-2: hsl(1, min(2%), 3%, 0.4);\n min-3: hsl(1, 2%, min(3%), 0.4);\n min-4: hsl(1, 2%, 3%, min(0.4));\n\n max-1: hsl(max(1), 2%, 3%, 0.4);\n max-2: hsl(1, max(2%), 3%, 0.4);\n max-3: hsl(1, 2%, max(3%), 0.4);\n max-4: hsl(1, 2%, 3%, max(0.4));\n}\n" + ) + .unwrap(), + "a {\n calc-1: hsl(calc(1), 2%, 3%, 0.4);\n calc-2: hsl(1, calc(2%), 3%, 0.4);\n calc-3: hsl(1, 2%, calc(3%), 0.4);\n calc-4: hsl(1, 2%, 3%, calc(0.4));\n var-1: hsl(var(--foo), 2%, 3%, 0.4);\n var-2: hsl(1, var(--foo), 3%, 0.4);\n var-3: hsl(1, 2%, var(--foo), 0.4);\n var-4: hsl(1, 2%, 3%, var(--foo));\n env-1: hsl(env(--foo), 2%, 3%, 0.4);\n env-2: hsl(1, env(--foo), 3%, 0.4);\n env-3: hsl(1, 2%, env(--foo), 0.4);\n env-4: hsl(1, 2%, 3%, env(--foo));\n min-1: hsl(min(1), 2%, 3%, 0.4);\n min-2: hsl(1, min(2%), 3%, 0.4);\n min-3: hsl(1, 2%, min(3%), 0.4);\n min-4: hsl(1, 2%, 3%, min(0.4));\n max-1: hsl(max(1), 2%, 3%, 0.4);\n max-2: hsl(1, max(2%), 3%, 0.4);\n max-3: hsl(1, 2%, max(3%), 0.4);\n max-4: hsl(1, 2%, 3%, max(0.4));\n}\n" + ); +} diff --git a/tests/core_functions/color/hsl/mod.rs b/tests/core_functions/color/hsl/mod.rs new file mode 100644 index 000000000..d7a8e13dd --- /dev/null +++ b/tests/core_functions/color/hsl/mod.rs @@ -0,0 +1,29 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod basic; + +mod error; + +mod four_args; + +/// From "sass-spec/spec/core_functions/color/hsl/multi_argument_var" +#[test] +fn multi_argument_var() { + assert_eq!( + rsass( + "a {\n // var() is substituted before parsing, so it may contain multiple arguments.\n b: hsl(var(--foo), 3%, 0.4);\n b: hsl(1, var(--foo), 0.4);\n b: hsl(1, 2%, var(--foo));\n b: hsl(var(--foo), 0.4);\n b: hsl(1, var(--foo));\n b: hsl(var(--foo));\n}\n" + ) + .unwrap(), + "a {\n b: hsl(var(--foo), 3%, 0.4);\n b: hsl(1, var(--foo), 0.4);\n b: hsl(1, 2%, var(--foo));\n b: hsl(var(--foo), 0.4);\n b: hsl(1, var(--foo));\n b: hsl(var(--foo));\n}\n" + ); +} + +mod one_arg; + +mod three_args; + +// Ignoring "two_args", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsl/one_arg/mod.rs b/tests/core_functions/color/hsl/one_arg/mod.rs new file mode 100644 index 000000000..d462180c4 --- /dev/null +++ b/tests/core_functions/color/hsl/one_arg/mod.rs @@ -0,0 +1,44 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/hsl/one_arg/alpha" +#[test] +#[ignore] // failing +fn alpha() { + assert_eq!( + rsass( + "basic {\n transparent: hsl(180 60% 50% / 0);\n opaque: hsl(180 60% 50% / 1);\n partial: hsl(180 60% 50% / 0.5);\n named: hsl($channels: 180 60% 50% / 0.4);\n\n // Extra parens shouldn\'t cause the slash to be forced into division.\n parenthesized: (hsl(180 60% 50% / 0.4));\n}\n\nclamped {\n saturation: hsl(0 -0.1% 50% / 0.5);\n lightness: hsl(0 100% 9999% / 0.5);\n alpha-above: hsl(0 100% 50% / 1.1);\n alpha-below: hsl(0 100% 50% / -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(51, 204, 204, 0);\n opaque: #33cccc;\n partial: rgba(51, 204, 204, 0.5);\n named: rgba(51, 204, 204, 0.4);\n parenthesized: rgba(51, 204, 204, 0.4);\n}\nclamped {\n saturation: rgba(128, 128, 128, 0.5);\n lightness: rgba(255, 255, 255, 0.5);\n alpha-above: red;\n alpha-below: rgba(255, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/one_arg/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "basic {\n red: hsl(0 100% 50%);\n blue: hsl(240 100% 50%);\n grayish-yellow: hsl(60 60% 50%);\n}\n\nclamped {\n saturation-above: hsl(0 500% 50%);\n saturation-below: hsl(0 -100% 50%);\n lightness-above: hsl(0 100% 500%);\n lightness-below: hsl(0 100% -100%);\n}\n\nunits {\n hue-deg: hsl(0deg 100% 50%);\n saturation-unitless: hsl(0 50 50%);\n lightness-unitless: hsl(0 100% 50);\n}\n\nnamed {\n x: hsl($channels: 0 100% 50%);\n}\n" + ) + .unwrap(), + "basic {\n red: red;\n blue: blue;\n grayish-yellow: #cccc33;\n}\nclamped {\n saturation-above: red;\n saturation-below: gray;\n lightness-above: white;\n lightness-below: black;\n}\nunits {\n hue-deg: red;\n saturation-unitless: #bf4040;\n lightness-unitless: red;\n}\nnamed {\n x: red;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/one_arg/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "no-alpha {\n calc-1: hsl(calc(1) 2% 3%);\n calc-2: hsl(1 calc(2%) 3%);\n calc-3: hsl(1 2% calc(3%));\n\n var-1: hsl(var(--foo) 2% 3%);\n var-2: hsl(1 var(--foo) 3%);\n var-3: hsl(1 2% var(--foo));\n\n env-1: hsl(env(--foo) 2% 3%);\n env-2: hsl(1 env(--foo) 3%);\n env-3: hsl(1 2% env(--foo));\n\n min-1: hsl(min(1) 2% 3%);\n min-2: hsl(1 min(2%) 3%);\n min-3: hsl(1 2% min(3%));\n\n max-1: hsl(max(1) 2% 3%);\n max-2: hsl(1 max(2%) 3%);\n max-3: hsl(1 2% max(3%));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: hsl(var(--foo) 50%);\n multi-argument-var-2-of-2: hsl(0 var(--foo));\n multi-argument-var-1-of-1: hsl(var(--foo));\n}\n\nalpha {\n calc-1: hsl(calc(1) 2% 3% / 0.4);\n calc-2: hsl(1 calc(2%) 3% / 0.4);\n calc-3: hsl(1 2% calc(3%) / 0.4);\n calc-4: hsl(1 2% 3% / calc(0.4));\n\n var-1: hsl(var(--foo) 2% 3% / 0.4);\n var-2: hsl(1 var(--foo) 3% / 0.4);\n var-3: hsl(1 2% var(--foo) / 0.4);\n var-4: hsl(1 2% 3% / var(--foo));\n\n env-1: hsl(env(--foo) 2% 3% / 0.4);\n env-2: hsl(1 env(--foo) 3% / 0.4);\n env-3: hsl(1 2% env(--foo) / 0.4);\n env-4: hsl(1 2% 3% / env(--foo));\n\n min-1: hsl(min(1) 2% 3% / 0.4);\n min-2: hsl(1 min(2%) 3% / 0.4);\n min-3: hsl(1 2% min(3%) / 0.4);\n min-4: hsl(1 2% 3% / min(0.4));\n\n max-1: hsl(max(1) 2% 3% / 0.4);\n max-2: hsl(1 max(2%) 3% / 0.4);\n max-3: hsl(1 2% max(3%) / 0.4);\n max-4: hsl(1 2% 3% / max(0.4));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: hsl(var(--foo) 50% / 0.4);\n multi-argument-var-2-of-2: hsl(0 var(--foo) / 0.4);\n multi-argument-var-1-of-1: hsl(var(--foo) / 0.4);\n}\n" + ) + .unwrap(), + "no-alpha {\n calc-1: hsl(calc(1), 2%, 3%);\n calc-2: hsl(1, calc(2%), 3%);\n calc-3: hsl(1, 2%, calc(3%));\n var-1: hsl(var(--foo), 2%, 3%);\n var-2: hsl(1, var(--foo), 3%);\n var-3: hsl(1, 2%, var(--foo));\n env-1: hsl(env(--foo), 2%, 3%);\n env-2: hsl(1, env(--foo), 3%);\n env-3: hsl(1, 2%, env(--foo));\n min-1: hsl(min(1), 2%, 3%);\n min-2: hsl(1, min(2%), 3%);\n min-3: hsl(1, 2%, min(3%));\n max-1: hsl(max(1), 2%, 3%);\n max-2: hsl(1, max(2%), 3%);\n max-3: hsl(1, 2%, max(3%));\n multi-argument-var-1-of-2: hsl(var(--foo) 50%);\n multi-argument-var-2-of-2: hsl(0 var(--foo));\n multi-argument-var-1-of-1: hsl(var(--foo));\n}\nalpha {\n calc-1: hsl(calc(1), 2%, 3%, 0.4);\n calc-2: hsl(1, calc(2%), 3%, 0.4);\n calc-3: hsl(1 2% calc(3%)/0.4);\n calc-4: hsl(1 2% 3%/calc(0.4));\n var-1: hsl(var(--foo), 2%, 3%, 0.4);\n var-2: hsl(1, var(--foo), 3%, 0.4);\n var-3: hsl(1 2% var(--foo)/0.4);\n var-4: hsl(1 2% 3%/var(--foo));\n env-1: hsl(env(--foo), 2%, 3%, 0.4);\n env-2: hsl(1, env(--foo), 3%, 0.4);\n env-3: hsl(1 2% env(--foo)/0.4);\n env-4: hsl(1 2% 3%/env(--foo));\n min-1: hsl(min(1), 2%, 3%, 0.4);\n min-2: hsl(1, min(2%), 3%, 0.4);\n min-3: hsl(1 2% min(3%)/0.4);\n min-4: hsl(1 2% 3%/min(0.4));\n max-1: hsl(max(1), 2%, 3%, 0.4);\n max-2: hsl(1, max(2%), 3%, 0.4);\n max-3: hsl(1 2% max(3%)/0.4);\n max-4: hsl(1 2% 3%/max(0.4));\n multi-argument-var-1-of-2: hsl(var(--foo) 50%/0.4);\n multi-argument-var-2-of-2: hsl(0 var(--foo)/0.4);\n multi-argument-var-1-of-1: hsl(var(--foo)/0.4);\n}\n" + ); +} diff --git a/tests/core_functions/color/hsl/three_args/mod.rs b/tests/core_functions/color/hsl/three_args/mod.rs new file mode 100644 index 000000000..cb66a844d --- /dev/null +++ b/tests/core_functions/color/hsl/three_args/mod.rs @@ -0,0 +1,31 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/hsl/three_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "// These test cases come from two official W3C test suites:\n//\n// * https://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-h-rotating-b.htm\n// * https://www.w3.org/Style/CSS/Test/CSS3/Color/current/html4/t040204-hsl-values-b.htm\n\nhue {\n @mixin test-hues($name, $hues...) {\n #{$name} {\n @each $hue in $hues {\n hue-#{$hue}: hsl($hue, 100%, 50%);\n }\n }\n }\n\n @include test-hues(\"red\", 0, -360, 260, 6120);\n @include test-hues(\"yellow\", 60, -300, 420, -9660);\n @include test-hues(\"green\", 120, -240, 480, 99840);\n @include test-hues(\"cyan\", 180, -180, 540, -900);\n @include test-hues(\"blue\", 240, -120, 600, -104880);\n @include test-hues(\"purple\", 300, -60, 660, 2820);\n}\n\nred-to-green {\n step-1: hsl(0, 100%, 50%);\n step-2: hsl(12, 100%, 50%);\n step-3: hsl(24, 100%, 50%);\n step-4: hsl(36, 100%, 50%);\n step-5: hsl(48, 100%, 50%);\n step-6: hsl(60, 100%, 50%);\n step-7: hsl(72, 100%, 50%);\n step-8: hsl(84, 100%, 50%);\n step-9: hsl(96, 100%, 50%);\n step-10: hsl(108, 100%, 50%);\n step-11: hsl(120, 100%, 50%);\n}\n\ngreen-to-blue {\n step-1: hsl(120, 100%, 50%);\n step-2: hsl(132, 100%, 50%);\n step-3: hsl(144, 100%, 50%);\n step-4: hsl(156, 100%, 50%);\n step-5: hsl(168, 100%, 50%);\n step-6: hsl(180, 100%, 50%);\n step-7: hsl(192, 100%, 50%);\n step-8: hsl(204, 100%, 50%);\n step-9: hsl(216, 100%, 50%);\n step-10: hsl(228, 100%, 50%);\n step-11: hsl(240, 100%, 50%);\n}\n\nblue-to-red {\n step-1: hsl(240, 100%, 50%);\n step-2: hsl(252, 100%, 50%);\n step-3: hsl(264, 100%, 50%);\n step-4: hsl(276, 100%, 50%);\n step-5: hsl(288, 100%, 50%);\n step-6: hsl(300, 100%, 50%);\n step-7: hsl(312, 100%, 50%);\n step-8: hsl(324, 100%, 50%);\n step-9: hsl(336, 100%, 50%);\n step-10: hsl(348, 100%, 50%);\n step-11: hsl(360, 100%, 50%);\n}\n\ngray-to {\n red {\n step-1: hsl(0, 20%, 50%);\n step-2: hsl(0, 60%, 50%);\n step-3: hsl(0, 100%, 50%);\n }\n\n yellow {\n step-1: hsl(60, 20%, 50%);\n step-2: hsl(60, 60%, 50%);\n step-3: hsl(60, 100%, 50%);\n }\n\n green {\n step-1: hsl(120, 20%, 50%);\n step-2: hsl(120, 60%, 50%);\n step-3: hsl(120, 100%, 50%);\n }\n\n cyan {\n step-1: hsl(180, 20%, 50%);\n step-2: hsl(180, 60%, 50%);\n step-3: hsl(180, 100%, 50%);\n }\n\n blue {\n step-1: hsl(240, 20%, 50%);\n step-2: hsl(240, 60%, 50%);\n step-3: hsl(240, 100%, 50%);\n }\n\n purple {\n step-1: hsl(300, 20%, 50%);\n step-2: hsl(300, 60%, 50%);\n step-3: hsl(300, 100%, 50%);\n }\n}\n\nblack-to-white-through {\n red {\n step-1: hsl(0, 100%, 0%);\n step-2: hsl(0, 100%, 10%);\n step-3: hsl(0, 100%, 20%);\n step-4: hsl(0, 100%, 30%);\n step-5: hsl(0, 100%, 40%);\n step-6: hsl(0, 100%, 50%);\n step-7: hsl(0, 100%, 60%);\n step-8: hsl(0, 100%, 70%);\n step-9: hsl(0, 100%, 80%);\n step-10: hsl(0, 100%, 90%);\n step-11: hsl(0, 100%, 100%);\n }\n\n yellow {\n step-1: hsl(60, 100%, 0%);\n step-2: hsl(60, 100%, 10%);\n step-3: hsl(60, 100%, 20%);\n step-4: hsl(60, 100%, 30%);\n step-5: hsl(60, 100%, 40%);\n step-6: hsl(60, 100%, 50%);\n step-7: hsl(60, 100%, 60%);\n step-8: hsl(60, 100%, 70%);\n step-9: hsl(60, 100%, 80%);\n step-10: hsl(60, 100%, 90%);\n step-11: hsl(60, 100%, 100%);\n }\n\n green {\n step-1: hsl(120, 100%, 0%);\n step-2: hsl(120, 100%, 10%);\n step-3: hsl(120, 100%, 20%);\n step-4: hsl(120, 100%, 30%);\n step-5: hsl(120, 100%, 40%);\n step-6: hsl(120, 100%, 50%);\n step-7: hsl(120, 100%, 60%);\n step-8: hsl(120, 100%, 70%);\n step-9: hsl(120, 100%, 80%);\n step-10: hsl(120, 100%, 90%);\n step-11: hsl(120, 100%, 100%);\n }\n\n cyan {\n step-1: hsl(180, 100%, 0%);\n step-2: hsl(180, 100%, 10%);\n step-3: hsl(180, 100%, 20%);\n step-4: hsl(180, 100%, 30%);\n step-5: hsl(180, 100%, 40%);\n step-6: hsl(180, 100%, 50%);\n step-7: hsl(180, 100%, 60%);\n step-8: hsl(180, 100%, 70%);\n step-9: hsl(180, 100%, 80%);\n step-10: hsl(180, 100%, 90%);\n step-11: hsl(180, 100%, 100%);\n }\n\n blue {\n step-1: hsl(240, 100%, 0%);\n step-2: hsl(240, 100%, 10%);\n step-3: hsl(240, 100%, 20%);\n step-4: hsl(240, 100%, 30%);\n step-5: hsl(240, 100%, 40%);\n step-6: hsl(240, 100%, 50%);\n step-7: hsl(240, 100%, 60%);\n step-8: hsl(240, 100%, 70%);\n step-9: hsl(240, 100%, 80%);\n step-10: hsl(240, 100%, 90%);\n step-11: hsl(240, 100%, 100%);\n }\n\n purple {\n step-1: hsl(300, 100%, 0%);\n step-2: hsl(300, 100%, 10%);\n step-3: hsl(300, 100%, 20%);\n step-4: hsl(300, 100%, 30%);\n step-5: hsl(300, 100%, 40%);\n step-6: hsl(300, 100%, 50%);\n step-7: hsl(300, 100%, 60%);\n step-8: hsl(300, 100%, 70%);\n step-9: hsl(300, 100%, 80%);\n step-10: hsl(300, 100%, 90%);\n step-11: hsl(300, 100%, 100%);\n }\n}\n\n// The W3C tests cover clamped hue, but not clamped saturation or lightness.\nclamped {\n saturation-above: hsl(0, 500%, 50%);\n saturation-below: hsl(0, -100%, 50%);\n lightness-above: hsl(0, 100%, 500%);\n lightness-below: hsl(0, 100%, -100%);\n}\n\nunits {\n hue-deg: hsl(0deg, 100%, 50%);\n saturation-unitless: hsl(0, 50, 50%);\n lightness-unitless: hsl(0, 100%, 50);\n}\n\nnamed {\n x: hsl($hue: 0, $saturation: 100%, $lightness: 50%);\n}\n" + ) + .unwrap(), + "hue red {\n hue-0: red;\n hue--360: red;\n hue-260: #5500ff;\n hue-6120: red;\n}\nhue yellow {\n hue-60: yellow;\n hue--300: yellow;\n hue-420: yellow;\n hue--9660: yellow;\n}\nhue green {\n hue-120: lime;\n hue--240: lime;\n hue-480: lime;\n hue-99840: lime;\n}\nhue cyan {\n hue-180: aqua;\n hue--180: aqua;\n hue-540: aqua;\n hue--900: aqua;\n}\nhue blue {\n hue-240: blue;\n hue--120: blue;\n hue-600: blue;\n hue--104880: blue;\n}\nhue purple {\n hue-300: fuchsia;\n hue--60: fuchsia;\n hue-660: fuchsia;\n hue-2820: fuchsia;\n}\nred-to-green {\n step-1: red;\n step-2: #ff3300;\n step-3: #ff6600;\n step-4: #ff9900;\n step-5: #ffcc00;\n step-6: yellow;\n step-7: #ccff00;\n step-8: #99ff00;\n step-9: #66ff00;\n step-10: #33ff00;\n step-11: lime;\n}\ngreen-to-blue {\n step-1: lime;\n step-2: #00ff33;\n step-3: #00ff66;\n step-4: #00ff99;\n step-5: #00ffcc;\n step-6: aqua;\n step-7: #00ccff;\n step-8: #0099ff;\n step-9: #0066ff;\n step-10: #0033ff;\n step-11: blue;\n}\nblue-to-red {\n step-1: blue;\n step-2: #3300ff;\n step-3: #6600ff;\n step-4: #9900ff;\n step-5: #cc00ff;\n step-6: fuchsia;\n step-7: #ff00cc;\n step-8: #ff0099;\n step-9: #ff0066;\n step-10: #ff0033;\n step-11: red;\n}\ngray-to red {\n step-1: #996666;\n step-2: #cc3333;\n step-3: red;\n}\ngray-to yellow {\n step-1: #999966;\n step-2: #cccc33;\n step-3: yellow;\n}\ngray-to green {\n step-1: #669966;\n step-2: #33cc33;\n step-3: lime;\n}\ngray-to cyan {\n step-1: #669999;\n step-2: #33cccc;\n step-3: aqua;\n}\ngray-to blue {\n step-1: #666699;\n step-2: #3333cc;\n step-3: blue;\n}\ngray-to purple {\n step-1: #996699;\n step-2: #cc33cc;\n step-3: fuchsia;\n}\nblack-to-white-through red {\n step-1: black;\n step-2: #330000;\n step-3: #660000;\n step-4: #990000;\n step-5: #cc0000;\n step-6: red;\n step-7: #ff3333;\n step-8: #ff6666;\n step-9: #ff9999;\n step-10: #ffcccc;\n step-11: white;\n}\nblack-to-white-through yellow {\n step-1: black;\n step-2: #333300;\n step-3: #666600;\n step-4: #999900;\n step-5: #cccc00;\n step-6: yellow;\n step-7: #ffff33;\n step-8: #ffff66;\n step-9: #ffff99;\n step-10: #ffffcc;\n step-11: white;\n}\nblack-to-white-through green {\n step-1: black;\n step-2: #003300;\n step-3: #006600;\n step-4: #009900;\n step-5: #00cc00;\n step-6: lime;\n step-7: #33ff33;\n step-8: #66ff66;\n step-9: #99ff99;\n step-10: #ccffcc;\n step-11: white;\n}\nblack-to-white-through cyan {\n step-1: black;\n step-2: #003333;\n step-3: #006666;\n step-4: #009999;\n step-5: #00cccc;\n step-6: aqua;\n step-7: #33ffff;\n step-8: #66ffff;\n step-9: #99ffff;\n step-10: #ccffff;\n step-11: white;\n}\nblack-to-white-through blue {\n step-1: black;\n step-2: #000033;\n step-3: #000066;\n step-4: #000099;\n step-5: #0000cc;\n step-6: blue;\n step-7: #3333ff;\n step-8: #6666ff;\n step-9: #9999ff;\n step-10: #ccccff;\n step-11: white;\n}\nblack-to-white-through purple {\n step-1: black;\n step-2: #330033;\n step-3: #660066;\n step-4: #990099;\n step-5: #cc00cc;\n step-6: fuchsia;\n step-7: #ff33ff;\n step-8: #ff66ff;\n step-9: #ff99ff;\n step-10: #ffccff;\n step-11: white;\n}\nclamped {\n saturation-above: red;\n saturation-below: gray;\n lightness-above: white;\n lightness-below: black;\n}\nunits {\n hue-deg: red;\n saturation-unitless: #bf4040;\n lightness-unitless: red;\n}\nnamed {\n x: red;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsl/three_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: hsl(calc(1), 2%, 3%);\n calc-2: hsl(1, calc(2%), 3%);\n calc-3: hsl(1, 2%, calc(3%));\n\n var-1: hsl(var(--foo), 2%, 3%);\n var-2: hsl(1, var(--foo), 3%);\n var-3: hsl(1, 2%, var(--foo));\n\n env-1: hsl(env(--foo), 2%, 3%);\n env-2: hsl(1, env(--foo), 3%);\n env-3: hsl(1, 2%, env(--foo));\n\n min-1: hsl(min(1), 2%, 3%);\n min-2: hsl(1, min(2%), 3%);\n min-3: hsl(1, 2%, min(3%));\n\n max-1: hsl(max(1), 2%, 3%);\n max-2: hsl(1, max(2%), 3%);\n max-3: hsl(1, 2%, max(3%));\n}\n" + ) + .unwrap(), + "a {\n calc-1: hsl(calc(1), 2%, 3%);\n calc-2: hsl(1, calc(2%), 3%);\n calc-3: hsl(1, 2%, calc(3%));\n var-1: hsl(var(--foo), 2%, 3%);\n var-2: hsl(1, var(--foo), 3%);\n var-3: hsl(1, 2%, var(--foo));\n env-1: hsl(env(--foo), 2%, 3%);\n env-2: hsl(1, env(--foo), 3%);\n env-3: hsl(1, 2%, env(--foo));\n min-1: hsl(min(1), 2%, 3%);\n min-2: hsl(1, min(2%), 3%);\n min-3: hsl(1, 2%, min(3%));\n max-1: hsl(max(1), 2%, 3%);\n max-2: hsl(1, max(2%), 3%);\n max-3: hsl(1, 2%, max(3%));\n}\n" + ); +} diff --git a/tests/core_functions/color/hsla/error/four_args/mod.rs b/tests/core_functions/color/hsla/error/four_args/mod.rs new file mode 100644 index 000000000..99d1db8a2 --- /dev/null +++ b/tests/core_functions/color/hsla/error/four_args/mod.rs @@ -0,0 +1,13 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/error/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "hue_type", tests with expected error not implemented yet. + +// Ignoring "lightness_type", tests with expected error not implemented yet. + +// Ignoring "saturation_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsla/error/mod.rs b/tests/core_functions/color/hsla/error/mod.rs new file mode 100644 index 000000000..197badb4f --- /dev/null +++ b/tests/core_functions/color/hsla/error/mod.rs @@ -0,0 +1,15 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "five_args", tests with expected error not implemented yet. + +mod four_args; + +// Ignoring "one_arg", tests with expected error not implemented yet. + +mod three_args; + +// Ignoring "two_args", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsla/error/three_args/mod.rs b/tests/core_functions/color/hsla/error/three_args/mod.rs new file mode 100644 index 000000000..312b3cb9b --- /dev/null +++ b/tests/core_functions/color/hsla/error/three_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/error/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "hue_type", tests with expected error not implemented yet. + +// Ignoring "lightness_type", tests with expected error not implemented yet. + +// Ignoring "saturation_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsla/four_args/mod.rs b/tests/core_functions/color/hsla/four_args/mod.rs new file mode 100644 index 000000000..d6443c799 --- /dev/null +++ b/tests/core_functions/color/hsla/four_args/mod.rs @@ -0,0 +1,45 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_percent", start_version is 3.7. + +/// From "sass-spec/spec/core_functions/color/hsla/four_args/alpha_unitless" +#[test] +#[ignore] // failing +fn alpha_unitless() { + assert_eq!( + rsass( + ".alpha-unitless {\n negative: hsla(0, 0, 0, -10);\n min: hsla(0, 0, 0, 0);\n positive: hsla(0, 0, 0, 0.456);\n max: hsla(0, 0, 0, 1);\n above-max: hsla(0, 0, 0, 250);\n}\n" + ) + .unwrap(), + ".alpha-unitless {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsla/four_args/basic" +#[test] +fn basic() { + assert_eq!( + rsass( + "basic {\n transparent: hsla(180, 60%, 50%, 0);\n opaque: hsla(180, 60%, 50%, 1);\n partial: hsla(180, 60%, 50%, 0.5);\n named: hsla($hue: 180, $saturation: 60%, $lightness: 50%, $alpha: 0.4);\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n saturation: hsla(0, -0.1%, 50%, 0.5);\n blue: hsla(0, 100%, 9999%, 0.5);\n alpha-above: hsla(0, 100%, 50%, 1.1);\n alpha-below: rgba(0, 100%, 50%, -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(51, 204, 204, 0);\n opaque: #33cccc;\n partial: rgba(51, 204, 204, 0.5);\n named: rgba(51, 204, 204, 0.4);\n}\nclamped {\n saturation: rgba(128, 128, 128, 0.5);\n blue: rgba(255, 255, 255, 0.5);\n alpha-above: red;\n alpha-below: rgba(0, 255, 128, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsla/four_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: hsla(calc(1), 2%, 3%, 0.4);\n calc-2: hsla(1, calc(2%), 3%, 0.4);\n calc-3: hsla(1, 2%, calc(3%), 0.4);\n calc-4: hsla(1, 2%, 3%, calc(0.4));\n\n var-1: hsla(var(--foo), 2%, 3%, 0.4);\n var-2: hsla(1, var(--foo), 3%, 0.4);\n var-3: hsla(1, 2%, var(--foo), 0.4);\n var-4: hsla(1, 2%, 3%, var(--foo));\n\n env-1: hsla(env(--foo), 2%, 3%, 0.4);\n env-2: hsla(1, env(--foo), 3%, 0.4);\n env-3: hsla(1, 2%, env(--foo), 0.4);\n env-4: hsla(1, 2%, 3%, env(--foo));\n\n min-1: hsla(min(1), 2%, 3%, 0.4);\n min-2: hsla(1, min(2%), 3%, 0.4);\n min-3: hsla(1, 2%, min(3%), 0.4);\n min-4: hsla(1, 2%, 3%, min(0.4));\n\n max-1: hsla(max(1), 2%, 3%, 0.4);\n max-2: hsla(1, max(2%), 3%, 0.4);\n max-3: hsla(1, 2%, max(3%), 0.4);\n max-4: hsla(1, 2%, 3%, max(0.4));\n}\n" + ) + .unwrap(), + "a {\n calc-1: hsla(calc(1), 2%, 3%, 0.4);\n calc-2: hsla(1, calc(2%), 3%, 0.4);\n calc-3: hsla(1, 2%, calc(3%), 0.4);\n calc-4: hsla(1, 2%, 3%, calc(0.4));\n var-1: hsla(var(--foo), 2%, 3%, 0.4);\n var-2: hsla(1, var(--foo), 3%, 0.4);\n var-3: hsla(1, 2%, var(--foo), 0.4);\n var-4: hsla(1, 2%, 3%, var(--foo));\n env-1: hsla(env(--foo), 2%, 3%, 0.4);\n env-2: hsla(1, env(--foo), 3%, 0.4);\n env-3: hsla(1, 2%, env(--foo), 0.4);\n env-4: hsla(1, 2%, 3%, env(--foo));\n min-1: hsla(min(1), 2%, 3%, 0.4);\n min-2: hsla(1, min(2%), 3%, 0.4);\n min-3: hsla(1, 2%, min(3%), 0.4);\n min-4: hsla(1, 2%, 3%, min(0.4));\n max-1: hsla(max(1), 2%, 3%, 0.4);\n max-2: hsla(1, max(2%), 3%, 0.4);\n max-3: hsla(1, 2%, max(3%), 0.4);\n max-4: hsla(1, 2%, 3%, max(0.4));\n}\n" + ); +} diff --git a/tests/core_functions/color/hsla/mod.rs b/tests/core_functions/color/hsla/mod.rs new file mode 100644 index 000000000..98804b411 --- /dev/null +++ b/tests/core_functions/color/hsla/mod.rs @@ -0,0 +1,27 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod error; + +mod four_args; + +/// From "sass-spec/spec/core_functions/color/hsla/multi_argument_var" +#[test] +fn multi_argument_var() { + assert_eq!( + rsass( + "a {\n // var() is substituted before parsing, so it may contain multiple arguments.\n b: hsla(var(--foo), 3%, 0.4);\n b: hsla(1, var(--foo), 0.4);\n b: hsla(1, 2%, var(--foo));\n b: hsla(var(--foo), 0.4);\n b: hsla(1, var(--foo));\n b: hsla(var(--foo));\n}\n" + ) + .unwrap(), + "a {\n b: hsla(var(--foo), 3%, 0.4);\n b: hsla(1, var(--foo), 0.4);\n b: hsla(1, 2%, var(--foo));\n b: hsla(var(--foo), 0.4);\n b: hsla(1, var(--foo));\n b: hsla(var(--foo));\n}\n" + ); +} + +mod one_arg; + +mod three_args; + +// Ignoring "two_args", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/hsla/one_arg/mod.rs b/tests/core_functions/color/hsla/one_arg/mod.rs new file mode 100644 index 000000000..e2435ffba --- /dev/null +++ b/tests/core_functions/color/hsla/one_arg/mod.rs @@ -0,0 +1,44 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/hsla/one_arg/alpha" +#[test] +#[ignore] // failing +fn alpha() { + assert_eq!( + rsass( + "basic {\n transparent: hsla(180 60% 50% / 0);\n opaque: hsla(180 60% 50% / 1);\n partial: hsla(180 60% 50% / 0.5);\n named: hsla($channels: 180 60% 50% / 0.4);\n\n // Extra parens shouldn\'t cause the slash to be forced into division.\n parenthesized: (hsl(180 60% 50% / 0.4));\n}\n\nclamped {\n saturation: hsla(0 -0.1% 50% / 0.5);\n lightness: hsla(0 100% 9999% / 0.5);\n alpha-above: hsla(0 100% 50% / 1.1);\n alpha-below: hsla(0 100% 50% / -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(51, 204, 204, 0);\n opaque: #33cccc;\n partial: rgba(51, 204, 204, 0.5);\n named: rgba(51, 204, 204, 0.4);\n parenthesized: rgba(51, 204, 204, 0.4);\n}\nclamped {\n saturation: rgba(128, 128, 128, 0.5);\n lightness: rgba(255, 255, 255, 0.5);\n alpha-above: red;\n alpha-below: rgba(255, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsla/one_arg/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "basic {\n red: hsla(0 100% 50%);\n blue: hsla(240 100% 50%);\n grayish-yellow: hsla(60 60% 50%);\n}\n\nclamped {\n saturation-above: hsla(0 500% 50%);\n saturation-below: hsla(0 -100% 50%);\n lightness-above: hsla(0 100% 500%);\n lightness-below: hsla(0 100% -100%);\n}\n\nunits {\n hue-deg: hsla(0deg 100% 50%);\n saturation-unitless: hsla(0 50 50%);\n lightness-unitless: hsla(0 100% 50);\n}\n\nnamed {\n x: hsla($channels: 0 100% 50%);\n}\n" + ) + .unwrap(), + "basic {\n red: red;\n blue: blue;\n grayish-yellow: #cccc33;\n}\nclamped {\n saturation-above: red;\n saturation-below: gray;\n lightness-above: white;\n lightness-below: black;\n}\nunits {\n hue-deg: red;\n saturation-unitless: #bf4040;\n lightness-unitless: red;\n}\nnamed {\n x: red;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsla/one_arg/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "no-alpha {\n calc-1: hsla(calc(1) 2% 3%);\n calc-2: hsla(1 calc(2%) 3%);\n calc-3: hsla(1 2% calc(3%));\n\n var-1: hsla(var(--foo) 2% 3%);\n var-2: hsla(1 var(--foo) 3%);\n var-3: hsla(1 2% var(--foo));\n\n env-1: hsla(env(--foo) 2% 3%);\n env-2: hsla(1 env(--foo) 3%);\n env-3: hsla(1 2% env(--foo));\n\n min-1: hsla(min(1) 2% 3%);\n min-2: hsla(1 min(2%) 3%);\n min-3: hsla(1 2% min(3%));\n\n max-1: hsla(max(1) 2% 3%);\n max-2: hsla(1 max(2%) 3%);\n max-3: hsla(1 2% max(3%));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: hsla(var(--foo) 50%);\n multi-argument-var-2-of-2: hsla(0 var(--foo));\n multi-argument-var-1-of-1: hsla(var(--foo));\n}\n\nalpha {\n calc-1: hsla(calc(1) 2% 3% / 0.4);\n calc-2: hsla(1 calc(2%) 3% / 0.4);\n calc-3: hsla(1 2% calc(3%) / 0.4);\n calc-4: hsla(1 2% 3% / calc(0.4));\n\n var-1: hsla(var(--foo) 2% 3% / 0.4);\n var-2: hsla(1 var(--foo) 3% / 0.4);\n var-3: hsla(1 2% var(--foo) / 0.4);\n var-4: hsla(1 2% 3% / var(--foo));\n\n env-1: hsla(env(--foo) 2% 3% / 0.4);\n env-2: hsla(1 env(--foo) 3% / 0.4);\n env-3: hsla(1 2% env(--foo) / 0.4);\n env-4: hsla(1 2% 3% / env(--foo));\n\n min-1: hsla(min(1) 2% 3% / 0.4);\n min-2: hsla(1 min(2%) 3% / 0.4);\n min-3: hsla(1 2% min(3%) / 0.4);\n min-4: hsla(1 2% 3% / min(0.4));\n\n max-1: hsla(max(1) 2% 3% / 0.4);\n max-2: hsla(1 max(2%) 3% / 0.4);\n max-3: hsla(1 2% max(3%) / 0.4);\n max-4: hsla(1 2% 3% / max(0.4));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: hsla(var(--foo) 50% / 0.4);\n multi-argument-var-2-of-2: hsla(0 var(--foo) / 0.4);\n multi-argument-var-1-of-1: hsla(var(--foo) / 0.4);\n}\n" + ) + .unwrap(), + "no-alpha {\n calc-1: hsla(calc(1), 2%, 3%);\n calc-2: hsla(1, calc(2%), 3%);\n calc-3: hsla(1, 2%, calc(3%));\n var-1: hsla(var(--foo), 2%, 3%);\n var-2: hsla(1, var(--foo), 3%);\n var-3: hsla(1, 2%, var(--foo));\n env-1: hsla(env(--foo), 2%, 3%);\n env-2: hsla(1, env(--foo), 3%);\n env-3: hsla(1, 2%, env(--foo));\n min-1: hsla(min(1), 2%, 3%);\n min-2: hsla(1, min(2%), 3%);\n min-3: hsla(1, 2%, min(3%));\n max-1: hsla(max(1), 2%, 3%);\n max-2: hsla(1, max(2%), 3%);\n max-3: hsla(1, 2%, max(3%));\n multi-argument-var-1-of-2: hsla(var(--foo) 50%);\n multi-argument-var-2-of-2: hsla(0 var(--foo));\n multi-argument-var-1-of-1: hsla(var(--foo));\n}\nalpha {\n calc-1: hsla(calc(1), 2%, 3%, 0.4);\n calc-2: hsla(1, calc(2%), 3%, 0.4);\n calc-3: hsla(1 2% calc(3%)/0.4);\n calc-4: hsla(1 2% 3%/calc(0.4));\n var-1: hsla(var(--foo), 2%, 3%, 0.4);\n var-2: hsla(1, var(--foo), 3%, 0.4);\n var-3: hsla(1 2% var(--foo)/0.4);\n var-4: hsla(1 2% 3%/var(--foo));\n env-1: hsla(env(--foo), 2%, 3%, 0.4);\n env-2: hsla(1, env(--foo), 3%, 0.4);\n env-3: hsla(1 2% env(--foo)/0.4);\n env-4: hsla(1 2% 3%/env(--foo));\n min-1: hsla(min(1), 2%, 3%, 0.4);\n min-2: hsla(1, min(2%), 3%, 0.4);\n min-3: hsla(1 2% min(3%)/0.4);\n min-4: hsla(1 2% 3%/min(0.4));\n max-1: hsla(max(1), 2%, 3%, 0.4);\n max-2: hsla(1, max(2%), 3%, 0.4);\n max-3: hsla(1 2% max(3%)/0.4);\n max-4: hsla(1 2% 3%/max(0.4));\n multi-argument-var-1-of-2: hsla(var(--foo) 50%/0.4);\n multi-argument-var-2-of-2: hsla(0 var(--foo)/0.4);\n multi-argument-var-1-of-1: hsla(var(--foo)/0.4);\n}\n" + ); +} diff --git a/tests/core_functions/color/hsla/three_args/mod.rs b/tests/core_functions/color/hsla/three_args/mod.rs new file mode 100644 index 000000000..1ee7db48c --- /dev/null +++ b/tests/core_functions/color/hsla/three_args/mod.rs @@ -0,0 +1,31 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsla/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/hsla/three_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "// These test cases come from two official W3C test suites:\n//\n// * https://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-h-rotating-b.htm\n// * https://www.w3.org/Style/CSS/Test/CSS3/Color/current/html4/t040204-hsl-values-b.htm\n\nhue {\n @mixin test-hues($name, $hues...) {\n #{$name} {\n @each $hue in $hues {\n hue-#{$hue}: hsla($hue, 100%, 50%);\n }\n }\n }\n\n @include test-hues(\"red\", 0, -360, 260, 6120);\n @include test-hues(\"yellow\", 60, -300, 420, -9660);\n @include test-hues(\"green\", 120, -240, 480, 99840);\n @include test-hues(\"cyan\", 180, -180, 540, -900);\n @include test-hues(\"blue\", 240, -120, 600, -104880);\n @include test-hues(\"purple\", 300, -60, 660, 2820);\n}\n\nred-to-green {\n step-1: hsla(0, 100%, 50%);\n step-2: hsla(12, 100%, 50%);\n step-3: hsla(24, 100%, 50%);\n step-4: hsla(36, 100%, 50%);\n step-5: hsla(48, 100%, 50%);\n step-6: hsla(60, 100%, 50%);\n step-7: hsla(72, 100%, 50%);\n step-8: hsla(84, 100%, 50%);\n step-9: hsla(96, 100%, 50%);\n step-10: hsla(108, 100%, 50%);\n step-11: hsla(120, 100%, 50%);\n}\n\ngreen-to-blue {\n step-1: hsla(120, 100%, 50%);\n step-2: hsla(132, 100%, 50%);\n step-3: hsla(144, 100%, 50%);\n step-4: hsla(156, 100%, 50%);\n step-5: hsla(168, 100%, 50%);\n step-6: hsla(180, 100%, 50%);\n step-7: hsla(192, 100%, 50%);\n step-8: hsla(204, 100%, 50%);\n step-9: hsla(216, 100%, 50%);\n step-10: hsla(228, 100%, 50%);\n step-11: hsla(240, 100%, 50%);\n}\n\nblue-to-red {\n step-1: hsla(240, 100%, 50%);\n step-2: hsla(252, 100%, 50%);\n step-3: hsla(264, 100%, 50%);\n step-4: hsla(276, 100%, 50%);\n step-5: hsla(288, 100%, 50%);\n step-6: hsla(300, 100%, 50%);\n step-7: hsla(312, 100%, 50%);\n step-8: hsla(324, 100%, 50%);\n step-9: hsla(336, 100%, 50%);\n step-10: hsla(348, 100%, 50%);\n step-11: hsla(360, 100%, 50%);\n}\n\ngray-to {\n red {\n step-1: hsla(0, 20%, 50%);\n step-2: hsla(0, 60%, 50%);\n step-3: hsla(0, 100%, 50%);\n }\n\n yellow {\n step-1: hsla(60, 20%, 50%);\n step-2: hsla(60, 60%, 50%);\n step-3: hsla(60, 100%, 50%);\n }\n\n green {\n step-1: hsla(120, 20%, 50%);\n step-2: hsla(120, 60%, 50%);\n step-3: hsla(120, 100%, 50%);\n }\n\n cyan {\n step-1: hsla(180, 20%, 50%);\n step-2: hsla(180, 60%, 50%);\n step-3: hsla(180, 100%, 50%);\n }\n\n blue {\n step-1: hsla(240, 20%, 50%);\n step-2: hsla(240, 60%, 50%);\n step-3: hsla(240, 100%, 50%);\n }\n\n purple {\n step-1: hsla(300, 20%, 50%);\n step-2: hsla(300, 60%, 50%);\n step-3: hsla(300, 100%, 50%);\n }\n}\n\nblack-to-white-through {\n red {\n step-1: hsla(0, 100%, 0%);\n step-2: hsla(0, 100%, 10%);\n step-3: hsla(0, 100%, 20%);\n step-4: hsla(0, 100%, 30%);\n step-5: hsla(0, 100%, 40%);\n step-6: hsla(0, 100%, 50%);\n step-7: hsla(0, 100%, 60%);\n step-8: hsla(0, 100%, 70%);\n step-9: hsla(0, 100%, 80%);\n step-10: hsla(0, 100%, 90%);\n step-11: hsla(0, 100%, 100%);\n }\n\n yellow {\n step-1: hsla(60, 100%, 0%);\n step-2: hsla(60, 100%, 10%);\n step-3: hsla(60, 100%, 20%);\n step-4: hsla(60, 100%, 30%);\n step-5: hsla(60, 100%, 40%);\n step-6: hsla(60, 100%, 50%);\n step-7: hsla(60, 100%, 60%);\n step-8: hsla(60, 100%, 70%);\n step-9: hsla(60, 100%, 80%);\n step-10: hsla(60, 100%, 90%);\n step-11: hsla(60, 100%, 100%);\n }\n\n green {\n step-1: hsla(120, 100%, 0%);\n step-2: hsla(120, 100%, 10%);\n step-3: hsla(120, 100%, 20%);\n step-4: hsla(120, 100%, 30%);\n step-5: hsla(120, 100%, 40%);\n step-6: hsla(120, 100%, 50%);\n step-7: hsla(120, 100%, 60%);\n step-8: hsla(120, 100%, 70%);\n step-9: hsla(120, 100%, 80%);\n step-10: hsla(120, 100%, 90%);\n step-11: hsla(120, 100%, 100%);\n }\n\n cyan {\n step-1: hsla(180, 100%, 0%);\n step-2: hsla(180, 100%, 10%);\n step-3: hsla(180, 100%, 20%);\n step-4: hsla(180, 100%, 30%);\n step-5: hsla(180, 100%, 40%);\n step-6: hsla(180, 100%, 50%);\n step-7: hsla(180, 100%, 60%);\n step-8: hsla(180, 100%, 70%);\n step-9: hsla(180, 100%, 80%);\n step-10: hsla(180, 100%, 90%);\n step-11: hsla(180, 100%, 100%);\n }\n\n blue {\n step-1: hsla(240, 100%, 0%);\n step-2: hsla(240, 100%, 10%);\n step-3: hsla(240, 100%, 20%);\n step-4: hsla(240, 100%, 30%);\n step-5: hsla(240, 100%, 40%);\n step-6: hsla(240, 100%, 50%);\n step-7: hsla(240, 100%, 60%);\n step-8: hsla(240, 100%, 70%);\n step-9: hsla(240, 100%, 80%);\n step-10: hsla(240, 100%, 90%);\n step-11: hsla(240, 100%, 100%);\n }\n\n purple {\n step-1: hsla(300, 100%, 0%);\n step-2: hsla(300, 100%, 10%);\n step-3: hsla(300, 100%, 20%);\n step-4: hsla(300, 100%, 30%);\n step-5: hsla(300, 100%, 40%);\n step-6: hsla(300, 100%, 50%);\n step-7: hsla(300, 100%, 60%);\n step-8: hsla(300, 100%, 70%);\n step-9: hsla(300, 100%, 80%);\n step-10: hsla(300, 100%, 90%);\n step-11: hsla(300, 100%, 100%);\n }\n}\n\n// The W3C tests cover clamped hue, but not clamped saturation or lightness.\nclamped {\n saturation-above: hsla(0, 500%, 50%);\n saturation-below: hsla(0, -100%, 50%);\n lightness-above: hsla(0, 100%, 500%);\n lightness-below: hsla(0, 100%, -100%);\n}\n\nunits {\n hue-deg: hsla(0deg, 100%, 50%);\n saturation-unitless: hsla(0, 50, 50%);\n lightness-unitless: hsla(0, 100%, 50);\n}\n\nnamed {\n x: hsla($hue: 0, $saturation: 100%, $lightness: 50%);\n}\n" + ) + .unwrap(), + "hue red {\n hue-0: red;\n hue--360: red;\n hue-260: #5500ff;\n hue-6120: red;\n}\nhue yellow {\n hue-60: yellow;\n hue--300: yellow;\n hue-420: yellow;\n hue--9660: yellow;\n}\nhue green {\n hue-120: lime;\n hue--240: lime;\n hue-480: lime;\n hue-99840: lime;\n}\nhue cyan {\n hue-180: aqua;\n hue--180: aqua;\n hue-540: aqua;\n hue--900: aqua;\n}\nhue blue {\n hue-240: blue;\n hue--120: blue;\n hue-600: blue;\n hue--104880: blue;\n}\nhue purple {\n hue-300: fuchsia;\n hue--60: fuchsia;\n hue-660: fuchsia;\n hue-2820: fuchsia;\n}\nred-to-green {\n step-1: red;\n step-2: #ff3300;\n step-3: #ff6600;\n step-4: #ff9900;\n step-5: #ffcc00;\n step-6: yellow;\n step-7: #ccff00;\n step-8: #99ff00;\n step-9: #66ff00;\n step-10: #33ff00;\n step-11: lime;\n}\ngreen-to-blue {\n step-1: lime;\n step-2: #00ff33;\n step-3: #00ff66;\n step-4: #00ff99;\n step-5: #00ffcc;\n step-6: aqua;\n step-7: #00ccff;\n step-8: #0099ff;\n step-9: #0066ff;\n step-10: #0033ff;\n step-11: blue;\n}\nblue-to-red {\n step-1: blue;\n step-2: #3300ff;\n step-3: #6600ff;\n step-4: #9900ff;\n step-5: #cc00ff;\n step-6: fuchsia;\n step-7: #ff00cc;\n step-8: #ff0099;\n step-9: #ff0066;\n step-10: #ff0033;\n step-11: red;\n}\ngray-to red {\n step-1: #996666;\n step-2: #cc3333;\n step-3: red;\n}\ngray-to yellow {\n step-1: #999966;\n step-2: #cccc33;\n step-3: yellow;\n}\ngray-to green {\n step-1: #669966;\n step-2: #33cc33;\n step-3: lime;\n}\ngray-to cyan {\n step-1: #669999;\n step-2: #33cccc;\n step-3: aqua;\n}\ngray-to blue {\n step-1: #666699;\n step-2: #3333cc;\n step-3: blue;\n}\ngray-to purple {\n step-1: #996699;\n step-2: #cc33cc;\n step-3: fuchsia;\n}\nblack-to-white-through red {\n step-1: black;\n step-2: #330000;\n step-3: #660000;\n step-4: #990000;\n step-5: #cc0000;\n step-6: red;\n step-7: #ff3333;\n step-8: #ff6666;\n step-9: #ff9999;\n step-10: #ffcccc;\n step-11: white;\n}\nblack-to-white-through yellow {\n step-1: black;\n step-2: #333300;\n step-3: #666600;\n step-4: #999900;\n step-5: #cccc00;\n step-6: yellow;\n step-7: #ffff33;\n step-8: #ffff66;\n step-9: #ffff99;\n step-10: #ffffcc;\n step-11: white;\n}\nblack-to-white-through green {\n step-1: black;\n step-2: #003300;\n step-3: #006600;\n step-4: #009900;\n step-5: #00cc00;\n step-6: lime;\n step-7: #33ff33;\n step-8: #66ff66;\n step-9: #99ff99;\n step-10: #ccffcc;\n step-11: white;\n}\nblack-to-white-through cyan {\n step-1: black;\n step-2: #003333;\n step-3: #006666;\n step-4: #009999;\n step-5: #00cccc;\n step-6: aqua;\n step-7: #33ffff;\n step-8: #66ffff;\n step-9: #99ffff;\n step-10: #ccffff;\n step-11: white;\n}\nblack-to-white-through blue {\n step-1: black;\n step-2: #000033;\n step-3: #000066;\n step-4: #000099;\n step-5: #0000cc;\n step-6: blue;\n step-7: #3333ff;\n step-8: #6666ff;\n step-9: #9999ff;\n step-10: #ccccff;\n step-11: white;\n}\nblack-to-white-through purple {\n step-1: black;\n step-2: #330033;\n step-3: #660066;\n step-4: #990099;\n step-5: #cc00cc;\n step-6: fuchsia;\n step-7: #ff33ff;\n step-8: #ff66ff;\n step-9: #ff99ff;\n step-10: #ffccff;\n step-11: white;\n}\nclamped {\n saturation-above: red;\n saturation-below: gray;\n lightness-above: white;\n lightness-below: black;\n}\nunits {\n hue-deg: red;\n saturation-unitless: #bf4040;\n lightness-unitless: red;\n}\nnamed {\n x: red;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/hsla/three_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: hsla(calc(1), 2%, 3%);\n calc-2: hsla(1, calc(2%), 3%);\n calc-3: hsla(1, 2%, calc(3%));\n\n var-1: hsla(var(--foo), 2%, 3%);\n var-2: hsla(1, var(--foo), 3%);\n var-3: hsla(1, 2%, var(--foo));\n\n env-1: hsla(env(--foo), 2%, 3%);\n env-2: hsla(1, env(--foo), 3%);\n env-3: hsla(1, 2%, env(--foo));\n\n min-1: hsla(min(1), 2%, 3%);\n min-2: hsla(1, min(2%), 3%);\n min-3: hsla(1, 2%, min(3%));\n\n max-1: hsla(max(1), 2%, 3%);\n max-2: hsla(1, max(2%), 3%);\n max-3: hsla(1, 2%, max(3%));\n}\n" + ) + .unwrap(), + "a {\n calc-1: hsla(calc(1), 2%, 3%);\n calc-2: hsla(1, calc(2%), 3%);\n calc-3: hsla(1, 2%, calc(3%));\n var-1: hsla(var(--foo), 2%, 3%);\n var-2: hsla(1, var(--foo), 3%);\n var-3: hsla(1, 2%, var(--foo));\n env-1: hsla(env(--foo), 2%, 3%);\n env-2: hsla(1, env(--foo), 3%);\n env-3: hsla(1, 2%, env(--foo));\n min-1: hsla(min(1), 2%, 3%);\n min-2: hsla(1, min(2%), 3%);\n min-3: hsla(1, 2%, min(3%));\n max-1: hsla(max(1), 2%, 3%);\n max-2: hsla(1, max(2%), 3%);\n max-3: hsla(1, 2%, max(3%));\n}\n" + ); +} diff --git a/tests/core_functions/color/mod.rs b/tests/core_functions/color/mod.rs new file mode 100644 index 000000000..e1a6bed69 --- /dev/null +++ b/tests/core_functions/color/mod.rs @@ -0,0 +1,13 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod hsl; + +mod hsla; + +mod rgb; + +mod rgba; diff --git a/tests/core_functions/color/rgb/error/four_args/mod.rs b/tests/core_functions/color/rgb/error/four_args/mod.rs new file mode 100644 index 000000000..1ef2d20b0 --- /dev/null +++ b/tests/core_functions/color/rgb/error/four_args/mod.rs @@ -0,0 +1,13 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/error/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgb/error/mod.rs b/tests/core_functions/color/rgb/error/mod.rs new file mode 100644 index 000000000..bb111aec0 --- /dev/null +++ b/tests/core_functions/color/rgb/error/mod.rs @@ -0,0 +1,15 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "five_args", tests with expected error not implemented yet. + +mod four_args; + +mod one_arg; + +mod three_args; + +mod two_args; diff --git a/tests/core_functions/color/rgb/error/one_arg/mod.rs b/tests/core_functions/color/rgb/error/one_arg/mod.rs new file mode 100644 index 000000000..74aaf0c58 --- /dev/null +++ b/tests/core_functions/color/rgb/error/one_arg/mod.rs @@ -0,0 +1,25 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/error/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "bracketed", tests with expected error not implemented yet. + +// Ignoring "comma_separated", tests with expected error not implemented yet. + +// Ignoring "empty", tests with expected error not implemented yet. + +// Ignoring "four_elements", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "one_element", tests with expected error not implemented yet. + +// Ignoring "quoted_var_slash", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. + +// Ignoring "two_elements", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgb/error/three_args/mod.rs b/tests/core_functions/color/rgb/error/three_args/mod.rs new file mode 100644 index 000000000..7afc6b050 --- /dev/null +++ b/tests/core_functions/color/rgb/error/three_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/error/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgb/error/two_args/mod.rs b/tests/core_functions/color/rgb/error/two_args/mod.rs new file mode 100644 index 000000000..43c7901b1 --- /dev/null +++ b/tests/core_functions/color/rgb/error/two_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/error/two_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_type", tests with expected error not implemented yet. + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "color_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgb/four_args/mod.rs b/tests/core_functions/color/rgb/four_args/mod.rs new file mode 100644 index 000000000..41040656d --- /dev/null +++ b/tests/core_functions/color/rgb/four_args/mod.rs @@ -0,0 +1,57 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/rgb/four_args/alpha_percent" +#[test] +#[ignore] // failing +fn alpha_percent() { + assert_eq!( + rsass( + ".alpha-percent {\n negative: rgb(0, 0, 0, -10%);\n min: rgb(0, 0, 0, 0%);\n positive: rgb(0, 0, 0, 45.6%);\n max: rgb(0, 0, 0, 100%);\n above-max: rgb(0, 0, 0, 250%);\n}\n" + ) + .unwrap(), + ".alpha-percent {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/four_args/alpha_unitless" +#[test] +#[ignore] // failing +fn alpha_unitless() { + assert_eq!( + rsass( + ".alpha-unitless {\n negative: rgb(0, 0, 0, -10);\n min: rgb(0, 0, 0, 0);\n positive: rgb(0, 0, 0, 0.456);\n max: rgb(0, 0, 0, 1);\n above-max: rgb(0, 0, 0, 250);\n}\n" + ) + .unwrap(), + ".alpha-unitless {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/four_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "basic {\n transparent: rgb(0, 255, 127, 0);\n opaque: rgb(190, 173, 237, 1);\n partial: rgb(18, 52, 86, 0.5);\n named: rgb($red: 0, $green: 255, $blue: 127, $alpha: 0.3);\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n red: rgb(256, 0, 0, 0.5);\n green: rgb(0, -1, 0, 0.5);\n blue: rgb(0, 0, 9999, 0.5);\n alpha-above: rgb(0, 0, 0, 1.1);\n alpha-below: rgb(0, 0, 0, -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(0, 255, 127, 0);\n opaque: #beaded;\n partial: rgba(18, 52, 86, 0.5);\n named: rgba(0, 255, 127, 0.3);\n}\nclamped {\n red: rgba(255, 0, 0, 0.5);\n green: rgba(0, 0, 0, 0.5);\n blue: rgba(0, 0, 255, 0.5);\n alpha-above: black;\n alpha-below: rgba(0, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/four_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: rgb(calc(1), 2, 3, 0.4);\n calc-2: rgb(1, calc(2), 3, 0.4);\n calc-3: rgb(1, 2, calc(3), 0.4);\n calc-4: rgb(1, 2, 3, calc(0.4));\n\n var-1: rgb(var(--foo), 2, 3, 0.4);\n var-2: rgb(1, var(--foo), 3, 0.4);\n var-3: rgb(1, 2, var(--foo), 0.4);\n var-4: rgb(1, 2, 3, var(--foo));\n\n env-1: rgb(env(--foo), 2, 3, 0.4);\n env-2: rgb(1, env(--foo), 3, 0.4);\n env-3: rgb(1, 2, env(--foo), 0.4);\n env-4: rgb(1, 2, 3, env(--foo));\n\n min-1: rgb(min(1), 2, 3, 0.4);\n min-2: rgb(1, min(2), 3, 0.4);\n min-3: rgb(1, 2, min(3), 0.4);\n min-4: rgb(1, 2, 3, min(0.4));\n\n max-1: rgb(max(1), 2, 3, 0.4);\n max-2: rgb(1, max(2), 3, 0.4);\n max-3: rgb(1, 2, max(3), 0.4);\n max-4: rgb(1, 2, 3, max(0.4));\n\n calc-2-args: rgb(blue, calc(0.4));\n var-2-args-alpha: rgb(blue, var(--foo));\n var-2-args-color: rgb(var(--foo), 0.4);\n var-2-args-both: rgb(var(--foo), var(--foo));\n}\n" + ) + .unwrap(), + "a {\n calc-1: rgb(calc(1), 2, 3, 0.4);\n calc-2: rgb(1, calc(2), 3, 0.4);\n calc-3: rgb(1, 2, calc(3), 0.4);\n calc-4: rgb(1, 2, 3, calc(0.4));\n var-1: rgb(var(--foo), 2, 3, 0.4);\n var-2: rgb(1, var(--foo), 3, 0.4);\n var-3: rgb(1, 2, var(--foo), 0.4);\n var-4: rgb(1, 2, 3, var(--foo));\n env-1: rgb(env(--foo), 2, 3, 0.4);\n env-2: rgb(1, env(--foo), 3, 0.4);\n env-3: rgb(1, 2, env(--foo), 0.4);\n env-4: rgb(1, 2, 3, env(--foo));\n min-1: rgb(min(1), 2, 3, 0.4);\n min-2: rgb(1, min(2), 3, 0.4);\n min-3: rgb(1, 2, min(3), 0.4);\n min-4: rgb(1, 2, 3, min(0.4));\n max-1: rgb(max(1), 2, 3, 0.4);\n max-2: rgb(1, max(2), 3, 0.4);\n max-3: rgb(1, 2, max(3), 0.4);\n max-4: rgb(1, 2, 3, max(0.4));\n calc-2-args: rgb(0, 0, 255, calc(0.4));\n var-2-args-alpha: rgb(0, 0, 255, var(--foo));\n var-2-args-color: rgb(var(--foo), 0.4);\n var-2-args-both: rgb(var(--foo), var(--foo));\n}\n" + ); +} diff --git a/tests/core_functions/color/rgb/mod.rs b/tests/core_functions/color/rgb/mod.rs new file mode 100644 index 000000000..f8d567bd4 --- /dev/null +++ b/tests/core_functions/color/rgb/mod.rs @@ -0,0 +1,38 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod error; + +mod four_args; + +/// From "sass-spec/spec/core_functions/color/rgb/multi_argument_var" +#[test] +fn multi_argument_var() { + assert_eq!( + rsass( + "a {\n // var() is substituted before parsing, so it may contain multiple arguments.\n b: rgb(var(--foo), 3, 0.4);\n b: rgb(1, var(--foo), 0.4);\n b: rgb(1, 2, var(--foo));\n b: rgb(var(--foo), 0.4);\n b: rgb(1, var(--foo));\n b: rgb(var(--foo));\n}\n" + ) + .unwrap(), + "a {\n b: rgb(var(--foo), 3, 0.4);\n b: rgb(1, var(--foo), 0.4);\n b: rgb(1, 2, var(--foo));\n b: rgb(var(--foo), 0.4);\n b: rgb(1, var(--foo));\n b: rgb(var(--foo));\n}\n" + ); +} + +mod one_arg; + +mod three_args; + +/// From "sass-spec/spec/core_functions/color/rgb/two_args" +#[test] +#[ignore] // failing +fn two_args() { + assert_eq!( + rsass( + "opaque-to {\n opaque: rgb(#123, 1);\n partial: rgb(#123, 0.5);\n transparent: rgb(#123, 0);\n}\n\npartial-to {\n $color: rgb(0, 0, 255, 0.3);\n opaque: rgb($color, 1);\n partial: rgb($color, 0.5);\n transparent: rgb($color, 0);\n}\n\ntransparent-to {\n opaque: rgb(transparent, 1);\n partial: rgb(transparent, 0.5);\n transparent: rgb(transparent, 0);\n}\n\nclamped {\n opaque: rgb(#123, 1.1);\n transparent: rgb(#123, -0.1);\n}\n\nnamed {\n x: rgb($color: #123, $alpha: 0.5);\n}\n" + ) + .unwrap(), + "opaque-to {\n opaque: #112233;\n partial: rgba(17, 34, 51, 0.5);\n transparent: rgba(17, 34, 51, 0);\n}\npartial-to {\n opaque: blue;\n partial: rgba(0, 0, 255, 0.5);\n transparent: rgba(0, 0, 255, 0);\n}\ntransparent-to {\n opaque: black;\n partial: rgba(0, 0, 0, 0.5);\n transparent: rgba(0, 0, 0, 0);\n}\nclamped {\n opaque: #112233;\n transparent: rgba(17, 34, 51, 0);\n}\nnamed {\n x: rgba(17, 34, 51, 0.5);\n}\n" + ); +} diff --git a/tests/core_functions/color/rgb/one_arg/mod.rs b/tests/core_functions/color/rgb/one_arg/mod.rs new file mode 100644 index 000000000..555518379 --- /dev/null +++ b/tests/core_functions/color/rgb/one_arg/mod.rs @@ -0,0 +1,44 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/rgb/one_arg/alpha" +#[test] +#[ignore] // failing +fn alpha() { + assert_eq!( + rsass( + "basic {\n transparent: rgb(0 255 127 / 0);\n opaque: rgb(190 173 237 / 1);\n partial: rgb(18 52 86 / 0.5);\n percent: rgb(18 52 86 / 50%);\n named: rgb($channels: 0 255 127 / 0.3);\n\n // Extra parens shouldn\'t cause the slash to be forced into division.\n parenthesized: (rgb(0 255 127 / 0.3));\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n red: rgb(256 0 0 / 0.5);\n green: rgb(0 -1 0 / 0.5);\n blue: rgb(0 0 9999 / 0.5);\n alpha-above: rgb(0 0 0 / 1.1);\n alpha-below: rgb(0 0 0 / -0.1);\n alpha-above-percent: rgb(0 0 0 / 250%);\n alpha-below-percent: rgb(0 0 0 / -10%);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(0, 255, 127, 0);\n opaque: #beaded;\n partial: rgba(18, 52, 86, 0.5);\n percent: rgba(18, 52, 86, 0.5);\n named: rgba(0, 255, 127, 0.3);\n parenthesized: rgba(0, 255, 127, 0.3);\n}\nclamped {\n red: rgba(255, 0, 0, 0.5);\n green: rgba(0, 0, 0, 0.5);\n blue: rgba(0, 0, 255, 0.5);\n alpha-above: black;\n alpha-below: rgba(0, 0, 0, 0);\n alpha-above-percent: black;\n alpha-below-percent: rgba(0, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/one_arg/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "// Channels may be specified as unitless numbers between 0 and 255.\nunitless {\n numbers: rgb(18 52 86);\n beaded: rgb(190 173 237);\n springgreen: rgb(0 255 127);\n named: rgb($channels: 0 255 127);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgb(256 0 0);\n green: rgb(0 -1 0);\n blue: rgb(0 0 9999);\n }\n}\n\n// Channels may also be specified as percents between 0% and 100%, which may be\n// mixed with unitless numbers.\npercents {\n all-percent: rgb(7.1% 20.4% 33.9%);\n unitless-green: rgb(74.7% 173 93%);\n percent-green: rgb(190 68% 237);\n boundaries: rgb(0% 100% 50%);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgb(100.1% 0 0);\n green: rgb(0 -0.1% 0);\n blue: rgb(0 0 200%);\n }\n}\n" + ) + .unwrap(), + "unitless {\n numbers: #123456;\n beaded: #beaded;\n springgreen: springgreen;\n named: springgreen;\n}\nunitless clamped {\n red: red;\n green: black;\n blue: blue;\n}\npercents {\n all-percent: #123456;\n unitless-green: #beaded;\n percent-green: #beaded;\n boundaries: #00ff80;\n}\npercents clamped {\n red: red;\n green: black;\n blue: blue;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/one_arg/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "no-alpha {\n calc-1: rgb(calc(1) 2 3);\n calc-2: rgb(1 calc(2) 3);\n calc-3: rgb(1 2 calc(3));\n\n var-1: rgb(var(--foo) 2 3);\n var-2: rgb(1 var(--foo) 3);\n var-3: rgb(1 2 var(--foo));\n\n env-1: rgb(env(--foo) 2 3);\n env-2: rgb(1 env(--foo) 3);\n env-3: rgb(1 2 env(--foo));\n\n min-1: rgb(min(1) 2 3);\n min-2: rgb(1 min(2) 3);\n min-3: rgb(1 2 min(3));\n\n max-1: rgb(max(1) 2 3);\n max-2: rgb(1 max(2) 3);\n max-3: rgb(1 2 max(3));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: rgb(var(--foo) 2);\n multi-argument-var-2-of-2: rgb(1 var(--foo));\n multi-argument-var-1-of-1: rgb(var(--foo));\n}\n\nalpha {\n calc-1: rgb(calc(1) 2 3 / 0.4);\n calc-2: rgb(1 calc(2) 3 / 0.4);\n calc-3: rgb(1 2 calc(3) / 0.4);\n calc-4: rgb(1 2 3 / calc(0.4));\n\n var-1: rgb(var(--foo) 2 3 / 0.4);\n var-2: rgb(1 var(--foo) 3 / 0.4);\n var-3: rgb(1 2 var(--foo) / 0.4);\n var-4: rgb(1 2 3 / var(--foo));\n\n env-1: rgb(env(--foo) 2 3 / 0.4);\n env-2: rgb(1 env(--foo) 3 / 0.4);\n env-3: rgb(1 2 env(--foo) / 0.4);\n env-4: rgb(1 2 3 / env(--foo));\n\n min-1: rgb(min(1) 2 3 / 0.4);\n min-2: rgb(1 min(2) 3 / 0.4);\n min-3: rgb(1 2 min(3) / 0.4);\n min-4: rgb(1 2 3 / min(0.4));\n\n max-1: rgb(max(1) 2 3 / 0.4);\n max-2: rgb(1 max(2) 3 / 0.4);\n max-3: rgb(1 2 max(3) / 0.4);\n max-4: rgb(1 2 3 / max(0.4));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: rgb(var(--foo) 2 / 0.4);\n multi-argument-var-2-of-2: rgb(1 var(--foo) / 0.4);\n multi-argument-var-1-of-1: rgb(var(--foo) / 0.4);\n}\n" + ) + .unwrap(), + "no-alpha {\n calc-1: rgb(calc(1), 2, 3);\n calc-2: rgb(1, calc(2), 3);\n calc-3: rgb(1, 2, calc(3));\n var-1: rgb(var(--foo), 2, 3);\n var-2: rgb(1, var(--foo), 3);\n var-3: rgb(1, 2, var(--foo));\n env-1: rgb(env(--foo), 2, 3);\n env-2: rgb(1, env(--foo), 3);\n env-3: rgb(1, 2, env(--foo));\n min-1: rgb(min(1), 2, 3);\n min-2: rgb(1, min(2), 3);\n min-3: rgb(1, 2, min(3));\n max-1: rgb(max(1), 2, 3);\n max-2: rgb(1, max(2), 3);\n max-3: rgb(1, 2, max(3));\n multi-argument-var-1-of-2: rgb(var(--foo) 2);\n multi-argument-var-2-of-2: rgb(1 var(--foo));\n multi-argument-var-1-of-1: rgb(var(--foo));\n}\nalpha {\n calc-1: rgb(calc(1), 2, 3, 0.4);\n calc-2: rgb(1, calc(2), 3, 0.4);\n calc-3: rgb(1 2 calc(3)/0.4);\n calc-4: rgb(1 2 3/calc(0.4));\n var-1: rgb(var(--foo), 2, 3, 0.4);\n var-2: rgb(1, var(--foo), 3, 0.4);\n var-3: rgb(1 2 var(--foo)/0.4);\n var-4: rgb(1 2 3/var(--foo));\n env-1: rgb(env(--foo), 2, 3, 0.4);\n env-2: rgb(1, env(--foo), 3, 0.4);\n env-3: rgb(1 2 env(--foo)/0.4);\n env-4: rgb(1 2 3/env(--foo));\n min-1: rgb(min(1), 2, 3, 0.4);\n min-2: rgb(1, min(2), 3, 0.4);\n min-3: rgb(1 2 min(3)/0.4);\n min-4: rgb(1 2 3/min(0.4));\n max-1: rgb(max(1), 2, 3, 0.4);\n max-2: rgb(1, max(2), 3, 0.4);\n max-3: rgb(1 2 max(3)/0.4);\n max-4: rgb(1 2 3/max(0.4));\n multi-argument-var-1-of-2: rgb(var(--foo) 2/0.4);\n multi-argument-var-2-of-2: rgb(1 var(--foo)/0.4);\n multi-argument-var-1-of-1: rgb(var(--foo)/0.4);\n}\n" + ); +} diff --git a/tests/core_functions/color/rgb/three_args/mod.rs b/tests/core_functions/color/rgb/three_args/mod.rs new file mode 100644 index 000000000..d48d77db1 --- /dev/null +++ b/tests/core_functions/color/rgb/three_args/mod.rs @@ -0,0 +1,30 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgb/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/rgb/three_args/basic" +#[test] +fn basic() { + assert_eq!( + rsass( + "// Channels may be specified as unitless numbers between 0 and 255.\nunitless {\n numbers: rgb(18, 52, 86);\n beaded: rgb(190, 173, 237);\n springgreen: rgb(0, 255, 127);\n named: rgb($red: 0, $green: 255, $blue: 127);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgb(256, 0, 0);\n green: rgb(0, -1, 0);\n blue: rgb(0, 0, 9999);\n }\n}\n\n// Channels may also be specified as percents between 0% and 100%, which may be\n// mixed with unitless numbers.\npercents {\n all-percent: rgb(7.1%, 20.4%, 33.9%);\n unitless-green: rgb(74.7%, 173, 93%);\n percent-green: rgb(190, 68%, 237);\n boundaries: rgb(0%, 100%, 50%);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgb(100.1%, 0, 0);\n green: rgb(0, -0.1%, 0);\n blue: rgb(0, 0, 200%);\n }\n}\n" + ) + .unwrap(), + "unitless {\n numbers: #123456;\n beaded: #beaded;\n springgreen: springgreen;\n named: springgreen;\n}\nunitless clamped {\n red: red;\n green: black;\n blue: blue;\n}\npercents {\n all-percent: #123456;\n unitless-green: #beaded;\n percent-green: #beaded;\n boundaries: #00ff80;\n}\npercents clamped {\n red: red;\n green: black;\n blue: blue;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgb/three_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: rgb(calc(1), 2, 3);\n calc-2: rgb(1, calc(2), 3);\n calc-3: rgb(1, 2, calc(3));\n\n var-1: rgb(var(--foo), 2, 3);\n var-2: rgb(1, var(--foo), 3);\n var-3: rgb(1, 2, var(--foo));\n\n env-1: rgb(env(--foo), 2, 3);\n env-2: rgb(1, env(--foo), 3);\n env-3: rgb(1, 2, env(--foo));\n\n min-1: rgb(min(1), 2, 3);\n min-2: rgb(1, min(2), 3);\n min-3: rgb(1, 2, min(3));\n\n max-1: rgb(max(1), 2, 3);\n max-2: rgb(1, max(2), 3);\n max-3: rgb(1, 2, max(3));\n}\n" + ) + .unwrap(), + "a {\n calc-1: rgb(calc(1), 2, 3);\n calc-2: rgb(1, calc(2), 3);\n calc-3: rgb(1, 2, calc(3));\n var-1: rgb(var(--foo), 2, 3);\n var-2: rgb(1, var(--foo), 3);\n var-3: rgb(1, 2, var(--foo));\n env-1: rgb(env(--foo), 2, 3);\n env-2: rgb(1, env(--foo), 3);\n env-3: rgb(1, 2, env(--foo));\n min-1: rgb(min(1), 2, 3);\n min-2: rgb(1, min(2), 3);\n min-3: rgb(1, 2, min(3));\n max-1: rgb(max(1), 2, 3);\n max-2: rgb(1, max(2), 3);\n max-3: rgb(1, 2, max(3));\n}\n" + ); +} diff --git a/tests/core_functions/color/rgba/error/four_args/mod.rs b/tests/core_functions/color/rgba/error/four_args/mod.rs new file mode 100644 index 000000000..aeda33bfd --- /dev/null +++ b/tests/core_functions/color/rgba/error/four_args/mod.rs @@ -0,0 +1,13 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/error/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgba/error/mod.rs b/tests/core_functions/color/rgba/error/mod.rs new file mode 100644 index 000000000..a05372b61 --- /dev/null +++ b/tests/core_functions/color/rgba/error/mod.rs @@ -0,0 +1,15 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "five_args", tests with expected error not implemented yet. + +mod four_args; + +mod one_arg; + +mod three_args; + +mod two_args; diff --git a/tests/core_functions/color/rgba/error/one_arg/mod.rs b/tests/core_functions/color/rgba/error/one_arg/mod.rs new file mode 100644 index 000000000..349d8e08e --- /dev/null +++ b/tests/core_functions/color/rgba/error/one_arg/mod.rs @@ -0,0 +1,25 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/error/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "bracketed", tests with expected error not implemented yet. + +// Ignoring "comma_separated", tests with expected error not implemented yet. + +// Ignoring "empty", tests with expected error not implemented yet. + +// Ignoring "four_elements", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "one_element", tests with expected error not implemented yet. + +// Ignoring "quoted_var_slash", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. + +// Ignoring "two_elements", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgba/error/three_args/mod.rs b/tests/core_functions/color/rgba/error/three_args/mod.rs new file mode 100644 index 000000000..230d288a0 --- /dev/null +++ b/tests/core_functions/color/rgba/error/three_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/error/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "blue_type", tests with expected error not implemented yet. + +// Ignoring "green_type", tests with expected error not implemented yet. + +// Ignoring "red_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgba/error/two_args/mod.rs b/tests/core_functions/color/rgba/error/two_args/mod.rs new file mode 100644 index 000000000..760a6a3a9 --- /dev/null +++ b/tests/core_functions/color/rgba/error/two_args/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/error/two_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_type", tests with expected error not implemented yet. + +// Ignoring "alpha_unit", tests with expected error not implemented yet. + +// Ignoring "color_type", tests with expected error not implemented yet. diff --git a/tests/core_functions/color/rgba/four_args/mod.rs b/tests/core_functions/color/rgba/four_args/mod.rs new file mode 100644 index 000000000..c59ebf5d7 --- /dev/null +++ b/tests/core_functions/color/rgba/four_args/mod.rs @@ -0,0 +1,46 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/four_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "alpha_percent", start_version is 3.7. + +/// From "sass-spec/spec/core_functions/color/rgba/four_args/alpha_unitless" +#[test] +#[ignore] // failing +fn alpha_unitless() { + assert_eq!( + rsass( + ".alpha-unitless {\n negative: rgba(0, 0, 0, -10);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: rgba(0, 0, 0, 1);\n above-max: rgba(0, 0, 0, 250);\n}\n" + ) + .unwrap(), + ".alpha-unitless {\n negative: rgba(0, 0, 0, 0);\n min: rgba(0, 0, 0, 0);\n positive: rgba(0, 0, 0, 0.456);\n max: black;\n above-max: black;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgba/four_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "basic {\n transparent: rgba(0, 255, 127, 0);\n opaque: rgba(190, 173, 237, 1);\n partial: rgba(18, 52, 86, 0.5);\n named: rgba($red: 0, $green: 255, $blue: 127, $alpha: 0.3);\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n red: rgba(256, 0, 0, 0.5);\n green: rgba(0, -1, 0, 0.5);\n blue: rgba(0, 0, 9999, 0.5);\n alpha-above: rgba(0, 0, 0, 1.1);\n alpha-below: rgba(0, 0, 0, -0.1);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(0, 255, 127, 0);\n opaque: #beaded;\n partial: rgba(18, 52, 86, 0.5);\n named: rgba(0, 255, 127, 0.3);\n}\nclamped {\n red: rgba(255, 0, 0, 0.5);\n green: rgba(0, 0, 0, 0.5);\n blue: rgba(0, 0, 255, 0.5);\n alpha-above: black;\n alpha-below: rgba(0, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgba/four_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: rgba(calc(1), 2, 3, 0.4);\n calc-2: rgba(1, calc(2), 3, 0.4);\n calc-3: rgba(1, 2, calc(3), 0.4);\n calc-4: rgba(1, 2, 3, calc(0.4));\n\n var-1: rgba(var(--foo), 2, 3, 0.4);\n var-2: rgba(1, var(--foo), 3, 0.4);\n var-3: rgba(1, 2, var(--foo), 0.4);\n var-4: rgba(1, 2, 3, var(--foo));\n\n env-1: rgba(env(--foo), 2, 3, 0.4);\n env-2: rgba(1, env(--foo), 3, 0.4);\n env-3: rgba(1, 2, env(--foo), 0.4);\n env-4: rgba(1, 2, 3, env(--foo));\n\n min-1: rgba(min(1), 2, 3, 0.4);\n min-2: rgba(1, min(2), 3, 0.4);\n min-3: rgba(1, 2, min(3), 0.4);\n min-4: rgba(1, 2, 3, min(0.4));\n\n max-1: rgba(max(1), 2, 3, 0.4);\n max-2: rgba(1, max(2), 3, 0.4);\n max-3: rgba(1, 2, max(3), 0.4);\n max-4: rgba(1, 2, 3, max(0.4));\n\n calc-2-args: rgba(blue, calc(0.4));\n var-2-args-alpha: rgba(blue, var(--foo));\n var-2-args-color: rgba(var(--foo), 0.4);\n var-2-args-both: rgba(var(--foo), var(--foo));\n}\n" + ) + .unwrap(), + "a {\n calc-1: rgba(calc(1), 2, 3, 0.4);\n calc-2: rgba(1, calc(2), 3, 0.4);\n calc-3: rgba(1, 2, calc(3), 0.4);\n calc-4: rgba(1, 2, 3, calc(0.4));\n var-1: rgba(var(--foo), 2, 3, 0.4);\n var-2: rgba(1, var(--foo), 3, 0.4);\n var-3: rgba(1, 2, var(--foo), 0.4);\n var-4: rgba(1, 2, 3, var(--foo));\n env-1: rgba(env(--foo), 2, 3, 0.4);\n env-2: rgba(1, env(--foo), 3, 0.4);\n env-3: rgba(1, 2, env(--foo), 0.4);\n env-4: rgba(1, 2, 3, env(--foo));\n min-1: rgba(min(1), 2, 3, 0.4);\n min-2: rgba(1, min(2), 3, 0.4);\n min-3: rgba(1, 2, min(3), 0.4);\n min-4: rgba(1, 2, 3, min(0.4));\n max-1: rgba(max(1), 2, 3, 0.4);\n max-2: rgba(1, max(2), 3, 0.4);\n max-3: rgba(1, 2, max(3), 0.4);\n max-4: rgba(1, 2, 3, max(0.4));\n calc-2-args: rgba(0, 0, 255, calc(0.4));\n var-2-args-alpha: rgba(0, 0, 255, var(--foo));\n var-2-args-color: rgba(var(--foo), 0.4);\n var-2-args-both: rgba(var(--foo), var(--foo));\n}\n" + ); +} diff --git a/tests/core_functions/color/rgba/mod.rs b/tests/core_functions/color/rgba/mod.rs new file mode 100644 index 000000000..25daa42db --- /dev/null +++ b/tests/core_functions/color/rgba/mod.rs @@ -0,0 +1,38 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod error; + +mod four_args; + +/// From "sass-spec/spec/core_functions/color/rgba/multi_argument_var" +#[test] +fn multi_argument_var() { + assert_eq!( + rsass( + "a {\n // var() is substituted before parsing, so it may contain multiple arguments.\n b: rgba(var(--foo), 3, 0.4);\n b: rgba(1, var(--foo), 0.4);\n b: rgba(1, 2, var(--foo));\n b: rgba(var(--foo), 0.4);\n b: rgba(1, var(--foo));\n b: rgba(var(--foo));\n}\n" + ) + .unwrap(), + "a {\n b: rgba(var(--foo), 3, 0.4);\n b: rgba(1, var(--foo), 0.4);\n b: rgba(1, 2, var(--foo));\n b: rgba(var(--foo), 0.4);\n b: rgba(1, var(--foo));\n b: rgba(var(--foo));\n}\n" + ); +} + +mod one_arg; + +mod three_args; + +/// From "sass-spec/spec/core_functions/color/rgba/two_args" +#[test] +#[ignore] // failing +fn two_args() { + assert_eq!( + rsass( + "opaque-to {\n opaque: rgba(#123, 1);\n partial: rgba(#123, 0.5);\n transparent: rgba(#123, 0);\n}\n\npartial-to {\n $color: rgba(0, 0, 255, 0.3);\n opaque: rgba($color, 1);\n partial: rgba($color, 0.5);\n transparent: rgba($color, 0);\n}\n\ntransparent-to {\n opaque: rgba(transparent, 1);\n partial: rgba(transparent, 0.5);\n transparent: rgba(transparent, 0);\n}\n\nclamped {\n opaque: rgba(#123, 1.1);\n transparent: rgba(#123, -0.1);\n}\n\nnamed {\n x: rgba($color: #123, $alpha: 0.5);\n}\n" + ) + .unwrap(), + "opaque-to {\n opaque: #112233;\n partial: rgba(17, 34, 51, 0.5);\n transparent: rgba(17, 34, 51, 0);\n}\npartial-to {\n opaque: blue;\n partial: rgba(0, 0, 255, 0.5);\n transparent: rgba(0, 0, 255, 0);\n}\ntransparent-to {\n opaque: black;\n partial: rgba(0, 0, 0, 0.5);\n transparent: rgba(0, 0, 0, 0);\n}\nclamped {\n opaque: #112233;\n transparent: rgba(17, 34, 51, 0);\n}\nnamed {\n x: rgba(17, 34, 51, 0.5);\n}\n" + ); +} diff --git a/tests/core_functions/color/rgba/one_arg/mod.rs b/tests/core_functions/color/rgba/one_arg/mod.rs new file mode 100644 index 000000000..23dd49a34 --- /dev/null +++ b/tests/core_functions/color/rgba/one_arg/mod.rs @@ -0,0 +1,44 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/one_arg" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/rgba/one_arg/alpha" +#[test] +#[ignore] // failing +fn alpha() { + assert_eq!( + rsass( + "basic {\n transparent: rgba(0 255 127 / 0);\n opaque: rgba(190 173 237 / 1);\n partial: rgba(18 52 86 / 0.5);\n percent: rgba(18 52 86 / 50%);\n named: rgba($channels: 0 255 127 / 0.3);\n\n // Extra parens shouldn\'t cause the slash to be forced into division.\n parenthesized: (rgba(0 255 127 / 0.3));\n}\n\n// Channels that are out of bounds are clamped within bounds.\nclamped {\n red: rgba(256 0 0 / 0.5);\n green: rgba(0 -1 0 / 0.5);\n blue: rgba(0 0 9999 / 0.5);\n alpha-above: rgba(0 0 0 / 1.1);\n alpha-below: rgba(0 0 0 / -0.1);\n alpha-above-percent: rgba(0 0 0 / 250%);\n alpha-below-percent: rgba(0 0 0 / -10%);\n}\n" + ) + .unwrap(), + "basic {\n transparent: rgba(0, 255, 127, 0);\n opaque: #beaded;\n partial: rgba(18, 52, 86, 0.5);\n percent: rgba(18, 52, 86, 0.5);\n named: rgba(0, 255, 127, 0.3);\n parenthesized: rgba(0, 255, 127, 0.3);\n}\nclamped {\n red: rgba(255, 0, 0, 0.5);\n green: rgba(0, 0, 0, 0.5);\n blue: rgba(0, 0, 255, 0.5);\n alpha-above: black;\n alpha-below: rgba(0, 0, 0, 0);\n alpha-above-percent: black;\n alpha-below-percent: rgba(0, 0, 0, 0);\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgba/one_arg/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "// Channels may be specified as unitless numbers between 0 and 255.\nunitless {\n numbers: rgba(18 52 86);\n beaded: rgba(190 173 237);\n springgreen: rgba(0 255 127);\n named: rgba($channels: 0 255 127);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgba(256 0 0);\n green: rgba(0 -1 0);\n blue: rgba(0 0 9999);\n }\n}\n\n// Channels may also be specified as percents between 0% and 100%, which may be\n// mixed with unitless numbers.\npercents {\n all-percent: rgba(7.1% 20.4% 33.9%);\n unitless-green: rgba(74.7% 173 93%);\n percent-green: rgba(190 68% 237);\n boundaries: rgba(0% 100% 50%);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgba(100.1% 0 0);\n green: rgba(0 -0.1% 0);\n blue: rgba(0 0 200%);\n }\n}\n" + ) + .unwrap(), + "unitless {\n numbers: #123456;\n beaded: #beaded;\n springgreen: springgreen;\n named: springgreen;\n}\nunitless clamped {\n red: red;\n green: black;\n blue: blue;\n}\npercents {\n all-percent: #123456;\n unitless-green: #beaded;\n percent-green: #beaded;\n boundaries: #00ff80;\n}\npercents clamped {\n red: red;\n green: black;\n blue: blue;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgba/one_arg/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "no-alpha {\n calc-1: rgba(calc(1) 2 3);\n calc-2: rgba(1 calc(2) 3);\n calc-3: rgba(1 2 calc(3));\n\n var-1: rgba(var(--foo) 2 3);\n var-2: rgba(1 var(--foo) 3);\n var-3: rgba(1 2 var(--foo));\n\n env-1: rgba(env(--foo) 2 3);\n env-2: rgba(1 env(--foo) 3);\n env-3: rgba(1 2 env(--foo));\n\n min-1: rgba(min(1) 2 3);\n min-2: rgba(1 min(2) 3);\n min-3: rgba(1 2 min(3));\n\n max-1: rgba(max(1) 2 3);\n max-2: rgba(1 max(2) 3);\n max-3: rgba(1 2 max(3));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: rgba(var(--foo) 2);\n multi-argument-var-2-of-2: rgba(1 var(--foo));\n multi-argument-var-1-of-1: rgba(var(--foo));\n}\n\nalpha {\n calc-1: rgba(calc(1) 2 3 / 0.4);\n calc-2: rgba(1 calc(2) 3 / 0.4);\n calc-3: rgba(1 2 calc(3) / 0.4);\n calc-4: rgba(1 2 3 / calc(0.4));\n\n var-1: rgba(var(--foo) 2 3 / 0.4);\n var-2: rgba(1 var(--foo) 3 / 0.4);\n var-3: rgba(1 2 var(--foo) / 0.4);\n var-4: rgba(1 2 3 / var(--foo));\n\n env-1: rgba(env(--foo) 2 3 / 0.4);\n env-2: rgba(1 env(--foo) 3 / 0.4);\n env-3: rgba(1 2 env(--foo) / 0.4);\n env-4: rgba(1 2 3 / env(--foo));\n\n min-1: rgba(min(1) 2 3 / 0.4);\n min-2: rgba(1 min(2) 3 / 0.4);\n min-3: rgba(1 2 min(3) / 0.4);\n min-4: rgba(1 2 3 / min(0.4));\n\n max-1: rgba(max(1) 2 3 / 0.4);\n max-2: rgba(1 max(2) 3 / 0.4);\n max-3: rgba(1 2 max(3) / 0.4);\n max-4: rgba(1 2 3 / max(0.4));\n\n // var() is substituted before parsing, so it may contain multiple arguments.\n multi-argument-var-1-of-2: rgba(var(--foo) 2 / 0.4);\n multi-argument-var-2-of-2: rgba(1 var(--foo) / 0.4);\n multi-argument-var-1-of-1: rgba(var(--foo) / 0.4);\n}\n" + ) + .unwrap(), + "no-alpha {\n calc-1: rgba(calc(1), 2, 3);\n calc-2: rgba(1, calc(2), 3);\n calc-3: rgba(1, 2, calc(3));\n var-1: rgba(var(--foo), 2, 3);\n var-2: rgba(1, var(--foo), 3);\n var-3: rgba(1, 2, var(--foo));\n env-1: rgba(env(--foo), 2, 3);\n env-2: rgba(1, env(--foo), 3);\n env-3: rgba(1, 2, env(--foo));\n min-1: rgba(min(1), 2, 3);\n min-2: rgba(1, min(2), 3);\n min-3: rgba(1, 2, min(3));\n max-1: rgba(max(1), 2, 3);\n max-2: rgba(1, max(2), 3);\n max-3: rgba(1, 2, max(3));\n multi-argument-var-1-of-2: rgba(var(--foo) 2);\n multi-argument-var-2-of-2: rgba(1 var(--foo));\n multi-argument-var-1-of-1: rgba(var(--foo));\n}\nalpha {\n calc-1: rgba(calc(1), 2, 3, 0.4);\n calc-2: rgba(1, calc(2), 3, 0.4);\n calc-3: rgba(1 2 calc(3)/0.4);\n calc-4: rgba(1 2 3/calc(0.4));\n var-1: rgba(var(--foo), 2, 3, 0.4);\n var-2: rgba(1, var(--foo), 3, 0.4);\n var-3: rgba(1 2 var(--foo)/0.4);\n var-4: rgba(1 2 3/var(--foo));\n env-1: rgba(env(--foo), 2, 3, 0.4);\n env-2: rgba(1, env(--foo), 3, 0.4);\n env-3: rgba(1 2 env(--foo)/0.4);\n env-4: rgba(1 2 3/env(--foo));\n min-1: rgba(min(1), 2, 3, 0.4);\n min-2: rgba(1, min(2), 3, 0.4);\n min-3: rgba(1 2 min(3)/0.4);\n min-4: rgba(1 2 3/min(0.4));\n max-1: rgba(max(1), 2, 3, 0.4);\n max-2: rgba(1, max(2), 3, 0.4);\n max-3: rgba(1 2 max(3)/0.4);\n max-4: rgba(1 2 3/max(0.4));\n multi-argument-var-1-of-2: rgba(var(--foo) 2/0.4);\n multi-argument-var-2-of-2: rgba(1 var(--foo)/0.4);\n multi-argument-var-1-of-1: rgba(var(--foo)/0.4);\n}\n" + ); +} diff --git a/tests/core_functions/color/rgba/three_args/mod.rs b/tests/core_functions/color/rgba/three_args/mod.rs new file mode 100644 index 000000000..6a8d0243d --- /dev/null +++ b/tests/core_functions/color/rgba/three_args/mod.rs @@ -0,0 +1,31 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/color/rgba/three_args" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/color/rgba/three_args/basic" +#[test] +#[ignore] // failing +fn basic() { + assert_eq!( + rsass( + "// Channels may be specified as unitless numbers between 0 and 255.\nunitless {\n numbers: rgba(18, 52, 86);\n beaded: rgba(190, 173, 237);\n springgreen: rgba(0, 255, 127);\n named: rgba($red: 0, $green: 255, $blue: 127);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgba(256, 0, 0);\n green: rgba(0, -1, 0);\n blue: rgba(0, 0, 9999);\n }\n}\n\n// Channels may also be specified as percents between 0% and 100%, which may be\n// mixed with unitless numbers.\npercents {\n all-percent: rgba(7.1%, 20.4%, 33.9%);\n unitless-green: rgba(74.7%, 173, 93%);\n percent-green: rgba(190, 68%, 237);\n boundaries: rgba(0%, 100%, 50%);\n\n // Channels that are out of bounds are clamped within bounds.\n clamped {\n red: rgba(100.1%, 0, 0);\n green: rgba(0, -0.1%, 0);\n blue: rgba(0, 0, 200%);\n }\n}\n" + ) + .unwrap(), + "unitless {\n numbers: #123456;\n beaded: #beaded;\n springgreen: springgreen;\n named: springgreen;\n}\nunitless clamped {\n red: red;\n green: black;\n blue: blue;\n}\npercents {\n all-percent: #123456;\n unitless-green: #beaded;\n percent-green: #beaded;\n boundaries: #00ff80;\n}\npercents clamped {\n red: red;\n green: black;\n blue: blue;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/color/rgba/three_args/special_functions" +#[test] +#[ignore] // failing +fn special_functions() { + assert_eq!( + rsass( + "a {\n calc-1: rgba(calc(1), 2, 3);\n calc-2: rgba(1, calc(2), 3);\n calc-3: rgba(1, 2, calc(3));\n\n var-1: rgba(var(--foo), 2, 3);\n var-2: rgba(1, var(--foo), 3);\n var-3: rgba(1, 2, var(--foo));\n\n env-1: rgba(env(--foo), 2, 3);\n env-2: rgba(1, env(--foo), 3);\n env-3: rgba(1, 2, env(--foo));\n\n min-1: rgba(min(1), 2, 3);\n min-2: rgba(1, min(2), 3);\n min-3: rgba(1, 2, min(3));\n\n max-1: rgba(max(1), 2, 3);\n max-2: rgba(1, max(2), 3);\n max-3: rgba(1, 2, max(3));\n}\n" + ) + .unwrap(), + "a {\n calc-1: rgba(calc(1), 2, 3);\n calc-2: rgba(1, calc(2), 3);\n calc-3: rgba(1, 2, calc(3));\n var-1: rgba(var(--foo), 2, 3);\n var-2: rgba(1, var(--foo), 3);\n var-3: rgba(1, 2, var(--foo));\n env-1: rgba(env(--foo), 2, 3);\n env-2: rgba(1, env(--foo), 3);\n env-3: rgba(1, 2, env(--foo));\n min-1: rgba(min(1), 2, 3);\n min-2: rgba(1, min(2), 3);\n min-3: rgba(1, 2, min(3));\n max-1: rgba(max(1), 2, 3);\n max-2: rgba(1, max(2), 3);\n max-3: rgba(1, 2, max(3));\n}\n" + ); +} diff --git a/tests/core_functions/content_exists/errors/mod.rs b/tests/core_functions/content_exists/errors/mod.rs new file mode 100644 index 000000000..2b44cf386 --- /dev/null +++ b/tests/core_functions/content_exists/errors/mod.rs @@ -0,0 +1,9 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/content-exists/errors" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "inside-function", tests with expected error not implemented yet. + +// Ignoring "outside-of-mixin", tests with expected error not implemented yet. diff --git a/tests/core_functions/content_exists/mod.rs b/tests/core_functions/content_exists/mod.rs new file mode 100644 index 000000000..ede49a68a --- /dev/null +++ b/tests/core_functions/content_exists/mod.rs @@ -0,0 +1,19 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/content-exists" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/content-exists/basic" +#[test] +fn basic() { + assert_eq!( + rsass( + "@mixin check-for-content {\n content-exists: content-exists();\n @if false {\n @content;\n }\n}\n\n.should-be-true {\n @include check-for-content {\n content-given: yes;\n }\n}\n\n.should-be-false {\n @include check-for-content;\n}\n" + ) + .unwrap(), + ".should-be-true {\n content-exists: true;\n}\n.should-be-false {\n content-exists: false;\n}\n" + ); +} + +mod errors; diff --git a/tests/core_functions/get_function/errors/math/mod.rs b/tests/core_functions/get_function/errors/math/mod.rs new file mode 100644 index 000000000..b1b442700 --- /dev/null +++ b/tests/core_functions/get_function/errors/math/mod.rs @@ -0,0 +1,7 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/get-function/errors/math" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "division", tests with expected error not implemented yet. diff --git a/tests/core_functions/get_function/errors/mod.rs b/tests/core_functions/get_function/errors/mod.rs new file mode 100644 index 000000000..fe1cb45bb --- /dev/null +++ b/tests/core_functions/get_function/errors/mod.rs @@ -0,0 +1,17 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/get-function/errors" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "function-exists", tests with expected error not implemented yet. + +// Ignoring "illegal-argument", tests with expected error not implemented yet. + +// Ignoring "illegal-kwarg", tests with expected error not implemented yet. + +mod math; + +// Ignoring "non-existent", tests with expected error not implemented yet. + +// Ignoring "passed-fn-ref", tests with expected error not implemented yet. diff --git a/tests/core_functions/get_function/mod.rs b/tests/core_functions/get_function/mod.rs new file mode 100644 index 000000000..91418ea64 --- /dev/null +++ b/tests/core_functions/get_function/mod.rs @@ -0,0 +1,80 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/get-function" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/get-function/basic" +#[test] +fn basic() { + assert_eq!( + rsass( + "@function add-two($v) {\n @return $v + 2;\n}\n\n$add-two-fn: get-function(add-two);\n\n.result {\n inspect: inspect($add-two-fn);\n type-of: type-of($add-two-fn);\n result: call($add-two-fn, 10);\n}\n" + ) + .unwrap(), + ".result {\n inspect: get-function(\"add-two\");\n type-of: function;\n result: 12;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/get-function/builtins" +#[test] +fn builtins() { + assert_eq!( + rsass( + "$built-in: get-function(lighten);\n\n.result {\n inspect: inspect($built-in);\n type-of: type-of($built-in);\n result: call($built-in, red, 30%);\n}\n" + ) + .unwrap(), + ".result {\n inspect: get-function(\"lighten\");\n type-of: function;\n result: #ff9999;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/get-function/css-fn-reference" +#[test] +fn css_fn_reference() { + assert_eq!( + rsass( + "@function supports($something) {\n @return sass;\n}\n\n$sass-fn: get-function(supports);\n$css-fn: get-function(supports, $css: true);\n\n.result {\n sass-fn: call($sass-fn, 1px);\n css-fn: call($css-fn, inspect((all: inherit)));\n}\n\n" + ) + .unwrap(), + ".result {\n sass-fn: sass;\n css-fn: supports((all: inherit));\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/get-function/equality" +#[test] +#[ignore] // failing +fn equality() { + assert_eq!( + rsass( + "$builtin: get-function(rgb);\n$same-builtin: get-function(rgb);\n$different-builtin: get-function(lighten);\n@function lighten() {\n @return wut;\n}\n$redefined-builtin: get-function(lighten);\n.should-be-true {\n identical: $builtin == $builtin;\n same: $builtin == $same-builtin;\n}\n\n.should-be-false {\n different: $different-builtin == $builtin;\n redefined: $different-builtin == $redefined-builtin;\n}\n\n" + ) + .unwrap(), + ".should-be-true {\n identical: true;\n same: true;\n}\n.should-be-false {\n different: false;\n redefined: false;\n}\n" + ); +} + +mod errors; + +/// From "sass-spec/spec/core_functions/get-function/local-scope" +#[test] +fn local_scope() { + assert_eq!( + rsass( + "@function foo() {@return global}\n\n.first-scope {\n @function foo() {@return local}\n a: call(foo);\n}\n\n.second-scope {\n a: call(foo);\n}\n\n" + ) + .unwrap(), + ".first-scope {\n a: local;\n}\n.second-scope {\n a: global;\n}\n" + ); +} + +/// From "sass-spec/spec/core_functions/get-function/overrides" +#[test] +fn overrides() { + assert_eq!( + rsass( + "@function add-two($v) {\n @return $v + 2;\n}\n\n$add-two-fn: get-function(add-two);\n\n@function add-two($v) {\n @error \"This should not have been called.\";\n}\n\n$lighten-fn: get-function(lighten) !default;\n\n@function lighten($color, $amount: null) {\n $amount: 10% !default;\n @return call($lighten-fn, $color, $amount);\n}\n\n.result {\n captured-sass-fn: call($add-two-fn, 10);\n captured-ruby-fn: lighten(red);\n}\n" + ) + .unwrap(), + ".result {\n captured-sass-fn: 12;\n captured-ruby-fn: #ff3333;\n}\n" + ); +} diff --git a/tests/core_functions/invert/mod.rs b/tests/core_functions/invert/mod.rs new file mode 100644 index 000000000..a17ed76d5 --- /dev/null +++ b/tests/core_functions/invert/mod.rs @@ -0,0 +1,17 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/invert" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +/// From "sass-spec/spec/core_functions/invert/weight-parameter" +#[test] +fn weight_parameter() { + assert_eq!( + rsass( + ".invert-with-weight {\n zero-percent: invert(#edc, 0%);\n ten-percent: invert(#edc, 10%);\n keyword: invert(#edc, $weight: 10%);\n one-hundred-percent: invert(#edc, 100%);\n}\n" + ) + .unwrap(), + ".invert-with-weight {\n zero-percent: #eeddcc;\n ten-percent: #d8cabd;\n keyword: #d8cabd;\n one-hundred-percent: #112233;\n}\n" + ); +} diff --git a/tests/core_functions/join/error/mod.rs b/tests/core_functions/join/error/mod.rs new file mode 100644 index 000000000..d94e5a7c5 --- /dev/null +++ b/tests/core_functions/join/error/mod.rs @@ -0,0 +1,11 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/join/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "named", tests with expected error not implemented yet. + +// Ignoring "positional", tests with expected error not implemented yet. + +// Ignoring "positional_and_named", tests with expected error not implemented yet. diff --git a/tests/core_functions/join/mod.rs b/tests/core_functions/join/mod.rs new file mode 100644 index 000000000..6603719b3 --- /dev/null +++ b/tests/core_functions/join/mod.rs @@ -0,0 +1,19 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions/join" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod error; + +/// From "sass-spec/spec/core_functions/join/valid" +#[test] +fn valid() { + assert_eq!( + rsass( + "// 3.5 added the $bracketed parameter to join() and made it generally\n// bracketed-list-aware.\n.join {\n both-bracketed: join([foo bar], [baz bang]);\n first-bracketed: join([foo bar], baz bang);\n second-bracketed: join(foo bar, [baz bang]);\n bracketed-true: join(foo, bar, $bracketed: true);\n bracketed-false: join([foo], [bar], $bracketed: false);\n separator-and-bracketed: join(foo, bar, $separator: comma, $bracketed: true);\n bracketed-and-separator: join(foo, bar, $bracketed: true, $separator: comma);\n separator-and-bracketed-positional:\n join(foo, bar, comma, true);\n\n // All values are valid in boolean contexts.\n unusual-bracketed-type: join(foo, bar, $bracketed: foo);\n bracketed-null: join([foo], [bar], $bracketed: null);\n}" + ) + .unwrap(), + ".join {\n both-bracketed: [foo bar baz bang];\n first-bracketed: [foo bar baz bang];\n second-bracketed: foo bar baz bang;\n bracketed-true: [foo bar];\n bracketed-false: foo bar;\n separator-and-bracketed: [foo, bar];\n bracketed-and-separator: [foo, bar];\n separator-and-bracketed-positional: [foo, bar];\n unusual-bracketed-type: [foo bar];\n bracketed-null: foo bar;\n}\n" + ); +} diff --git a/tests/core_functions/main.rs b/tests/core_functions/main.rs new file mode 100644 index 000000000..27f207df1 --- /dev/null +++ b/tests/core_functions/main.rs @@ -0,0 +1,49 @@ +//! Tests auto-converted from "sass-spec/spec/core_functions" +//! version dd3a5edf, 2019-02-04 13:14:26 -0800. +//! See for source material.\n +use rsass::{compile_scss, OutputStyle}; + +mod color; + +mod content_exists; + +/// From "sass-spec/spec/core_functions/feature_exists" +#[test] +#[ignore] // failing +fn feature_exists() { + assert_eq!( + rsass( + ".feature-exists {\n custom-property: feature-exists(custom-property);\n}" + ) + .unwrap(), + ".feature-exists {\n custom-property: true;\n}\n" + ); +} + +mod get_function; + +mod invert; + +/// From "sass-spec/spec/core_functions/is_bracketed" +#[test] +fn is_bracketed() { + assert_eq!( + rsass( + ".is-bracketed {\n unbracketed-empty: is-bracketed(());\n unbracketed-singleton: is-bracketed(foo);\n unbracketed-multiple: is-bracketed(foo bar);\n bracketed-empty: is-bracketed([]);\n bracketed-singleton: is-bracketed([foo]);\n bracketed-multiple: is-bracketed([foo bar]);\n}" + ) + .unwrap(), + ".is-bracketed {\n unbracketed-empty: false;\n unbracketed-singleton: false;\n unbracketed-multiple: false;\n bracketed-empty: true;\n bracketed-singleton: true;\n bracketed-multiple: true;\n}\n" + ); +} + +mod join; + +fn rsass(input: &str) -> Result { + compile_scss(input.as_bytes(), OutputStyle::Expanded) + .map_err(|e| format!("rsass failed: {}", e)) + .and_then(|s| { + String::from_utf8(s) + .map(|s| s.replace("\n\n", "\n")) + .map_err(|e| format!("{:?}", e)) + }) +} diff --git a/tests/interpolate/t01_literal.rs b/tests/interpolate/t01_literal.rs deleted file mode 100644 index 88d7082e1..000000000 --- a/tests/interpolate/t01_literal.rs +++ /dev/null @@ -1,51 +0,0 @@ -use super::check; - -#[test] -fn t01_inline() { - check( - ".result {\n output: literal;\n output: #{literal};\n \ - output: \"[#{literal}]\";\n output: \"#{literal}\";\n \ - output: '#{literal}';\n output: \"['#{literal}']\";\n}\n", - ".result {\n output: literal;\n output: literal;\n \ - output: \"[literal]\";\n output: \"literal\";\n \ - output: \"literal\";\n output: \"['literal']\";\n}\n", - ) -} - -#[test] -fn t02_variable() { - check( - "$input: literal;\n\ - .result {\n output: $input;\n output: #{$input};\n \ - output: \"[#{$input}]\";\n output: \"#{$input}\";\n \ - output: '#{$input}';\n output: \"['#{$input}']\";\n}\n", - ".result {\n output: literal;\n output: literal;\n \ - output: \"[literal]\";\n output: \"literal\";\n \ - output: \"literal\";\n output: \"['literal']\";\n}\n", - ) -} - -#[test] -fn t03() { - check( - ".result {\n \ - output: #{#{literal}};\n output: #{\"[#{literal}]\"};\n \ - output: #{\"#{literal}\"};\n output: #{'#{literal}'};\n \ - output: #{\"['#{literal}']\"};\n}\n", - ".result {\n output: literal;\n output: [literal];\n \ - output: literal;\n output: literal;\n output: ['literal'];\n}\n", - ) -} - -#[test] -fn t06_escape_interpolation() { - check( - "$input: literal;\n\ - .result {\n output: \"[\\#{literal}]\";\n \ - output: \"\\#{literal}\";\n output: '\\#{literal}';\n \ - output: \"['\\#{literal}']\";\n}\n", - ".result {\n output: \"[\\#{literal}]\";\n \ - output: \"\\#{literal}\";\n output: '\\#{literal}';\n \ - output: \"['\\#{literal}']\";\n}\n", - ) -} diff --git a/tests/interpolate/t02_double_quoted.rs b/tests/interpolate/t02_double_quoted.rs deleted file mode 100644 index c2b722a8d..000000000 --- a/tests/interpolate/t02_double_quoted.rs +++ /dev/null @@ -1,27 +0,0 @@ -use super::check; - -#[test] -fn t01_inline() { - check( - ".result {\n output: \"dquoted\";\n output: #{\"dquoted\"};\n \ - output: \"[#{\"dquoted\"}]\";\n output: \"#{\"dquoted\"}\";\n \ - output: '#{\"dquoted\"}';\n output: \"['#{\"dquoted\"}']\";\n}\n", - ".result {\n output: \"dquoted\";\n output: dquoted;\n \ - output: \"[dquoted]\";\n output: \"dquoted\";\n \ - output: \"dquoted\";\n output: \"['dquoted']\";\n}\n", - ) -} - -#[test] -fn t06_escape_interpolation() { - check( - "$input: \"dquoted\";\n.result {\n \ - output: \"[\\#{\"dquoted\"}]\";\n \ - output: \"\\#{\"dquoted\"}\";\n \ - output: '\\#{\"dquoted\"}';\n \ - output: \"['\\#{\"dquoted\"}']\";\n}\n", - ".result {\n output: \"[#{\" dquoted \"}]\";\n \ - output: \"#{\" dquoted \"}\";\n output: '\\#{\"dquoted\"}';\n \ - output: \"['#{\" dquoted \"}']\";\n}\n", - ) -} diff --git a/tests/interpolate/t03_single_quoted.rs b/tests/interpolate/t03_single_quoted.rs deleted file mode 100644 index 8edbfdc29..000000000 --- a/tests/interpolate/t03_single_quoted.rs +++ /dev/null @@ -1,38 +0,0 @@ -use super::check; - -#[test] -fn t01_inline() { - check( - ".result {\n output: 'squoted';\n output: #{'squoted'};\n \ - output: \"[#{'squoted'}]\";\n output: \"#{'squoted'}\";\n \ - output: '#{'squoted'}';\n output: \"['#{'squoted'}']\";\n}\n", - ".result {\n output: 'squoted';\n output: squoted;\n \ - output: \"[squoted]\";\n output: \"squoted\";\n \ - output: \"squoted\";\n output: \"['squoted']\";\n}\n", - ) -} - -#[test] -fn t02_variable() { - check( - "$input: 'squoted';\n.result {\n output: $input;\n \ - output: #{$input};\n output: \"[#{$input}]\";\n \ - output: \"#{$input}\";\n output: '#{$input}';\n \ - output: \"['#{$input}']\";\n}\n", - ".result {\n output: \"squoted\";\n output: squoted;\n \ - output: \"[squoted]\";\n output: \"squoted\";\n \ - output: \"squoted\";\n output: \"['squoted']\";\n}\n", - ) -} - -#[test] -fn t06_escape_interpolation() { - check( - "$input: 'squoted';\n.result {\n output: \"[\\#{'squoted'}]\";\n \ - output: \"\\#{'squoted'}\";\n output: '\\#{'squoted'}';\n \ - output: \"['\\#{'squoted'}']\";\n}\n", - ".result {\n output: \"[\\#{'squoted'}]\";\n \ - output: \"\\#{'squoted'}\";\n output: \"#{\" squoted \"}\";\n \ - output: \"['\\#{'squoted'}']\";\n}\n", - ) -} diff --git a/tests/mixin/content/arguments/error/mod.rs b/tests/mixin/content/arguments/error/mod.rs new file mode 100644 index 000000000..39a09f805 --- /dev/null +++ b/tests/mixin/content/arguments/error/mod.rs @@ -0,0 +1,25 @@ +//! Tests auto-converted from "sass-spec/spec/mixin/content/arguments/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "args_for_argless", tests with expected error not implemented yet. + +// Ignoring "expected_args", tests with expected error not implemented yet. + +// Ignoring "invalid_arglist", tests with expected error not implemented yet. + +// Ignoring "invalid_named_arg", tests with expected error not implemented yet. + +// Ignoring "missing_arglist", tests with expected error not implemented yet. + +// Ignoring "missing_parens", tests with expected error not implemented yet. + +// Ignoring "missing_using", tests with expected error not implemented yet. + +// Ignoring "too_few_args", tests with expected error not implemented yet. + +// Ignoring "too_many_args", tests with expected error not implemented yet. + +// Ignoring "using_without_block", tests with expected error not implemented yet. diff --git a/tests/mixin/content/arguments/mod.rs b/tests/mixin/content/arguments/mod.rs new file mode 100644 index 000000000..0c5b37af9 --- /dev/null +++ b/tests/mixin/content/arguments/mod.rs @@ -0,0 +1,72 @@ +//! Tests auto-converted from "sass-spec/spec/mixin/content/arguments" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod error; + +/// From "sass-spec/spec/mixin/content/arguments/none" +#[test] +#[ignore] // failing +fn none() { + assert_eq!( + rsass( + "// `@content()` and `@content` should behave identically, as should\n// `@include foo` and `@include foo using ()`.\n\nno-parens {\n @mixin mixin {\n @content;\n }\n\n empty-using {\n @include mixin using () {\n x: y;\n }\n }\n\n defaults {\n @include mixin using ($arg1: value1, $arg2: value2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n }\n}\n\nparens {\n @mixin mixin {\n @content();\n }\n\n no-using {\n @include mixin {\n x: y;\n }\n }\n\n empty-using {\n @include mixin using () {\n x: y;\n }\n }\n\n defaults {\n @include mixin using ($arg1: value1, $arg2: value2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n }\n}\n" + ) + .unwrap(), + "no-parens empty-using {\n x: y;\n}\nno-parens defaults {\n arg1: value1;\n arg2: value2;\n}\nparens no-using {\n x: y;\n}\nparens empty-using {\n x: y;\n}\nparens defaults {\n arg1: value1;\n arg2: value2;\n}\n" + ); +} + +/// From "sass-spec/spec/mixin/content/arguments/passing" +#[test] +#[ignore] // failing +fn passing() { + assert_eq!( + rsass( + "// Arguments can be passed to content blocks in all the same ways as they\'re\n// passed to any other argument list.\n\nby-position {\n @mixin mixin {\n @content(value1, value2);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nby-name {\n @mixin mixin {\n @content($arg1: value1, $arg2: value2);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nlist-splat {\n @mixin mixin {\n @content((value1 value2)...);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nmap-splat {\n @mixin mixin {\n @content((arg1: value1, arg2: value2)...);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nmixed-splat {\n @mixin mixin {\n @content((value1,)..., (arg2: value2)...);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n" + ) + .unwrap(), + "by-position {\n arg1: value1;\n arg2: value2;\n}\nby-name {\n arg1: value1;\n arg2: value2;\n}\nlist-splat {\n arg1: value1;\n arg2: value2;\n}\nmap-splat {\n arg1: value1;\n arg2: value2;\n}\nmixed-splat {\n arg1: value1;\n arg2: value2;\n}\n" + ); +} + +/// From "sass-spec/spec/mixin/content/arguments/receiving" +#[test] +#[ignore] // failing +fn receiving() { + assert_eq!( + rsass( + "// Content blocks\' argument lists can define arguments in in all the same ways\n// as they\'re defined in any other argument list.\n\nwith-defaults {\n nothing-passed {\n @mixin mixin {\n @content;\n }\n\n @include mixin using ($arg1: value1, $arg2: value2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n }\n\n partial-override {\n @mixin mixin {\n @content($arg2: other2);\n }\n\n @include mixin using ($arg1: value1, $arg2: value2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n }\n\n total-override {\n @mixin mixin {\n @content(other1, other2);\n }\n\n @include mixin using ($arg1: value1, $arg2: value2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n }\n}\n\nwith-splat {\n nothing-passed {\n @mixin mixin {\n @content;\n }\n\n @include mixin using ($args...) {\n positional: inspect($args);\n keywords: inspect(keywords($args));\n }\n }\n\n positional-passed {\n @mixin mixin {\n @content(value1, value2, value3);\n }\n\n @include mixin using ($args...) {\n positional: inspect($args);\n keywords: inspect(keywords($args));\n }\n }\n\n named-passed {\n @mixin mixin {\n @content($arg1: value1, $arg2: value2);\n }\n\n @include mixin using ($args...) {\n positional: inspect($args);\n keywords: inspect(keywords($args));\n }\n }\n\n both-passed {\n @mixin mixin {\n @content(value1, $arg2: value2);\n }\n\n @include mixin using ($args...) {\n positional: inspect($args);\n keywords: inspect(keywords($args));\n }\n }\n}\n" + ) + .unwrap(), + "with-defaults nothing-passed {\n arg1: value1;\n arg2: value2;\n}\nwith-defaults partial-override {\n arg1: value1;\n arg2: other2;\n}\nwith-defaults total-override {\n arg1: other1;\n arg2: other2;\n}\nwith-splat nothing-passed {\n positional: ();\n keywords: ();\n}\nwith-splat positional-passed {\n positional: value1, value2, value3;\n keywords: ();\n}\nwith-splat named-passed {\n positional: ();\n keywords: (arg1: value1, arg2: value2);\n}\nwith-splat both-passed {\n positional: (value1,);\n keywords: (arg2: value2);\n}\n" + ); +} + +/// From "sass-spec/spec/mixin/content/arguments/scope" +#[test] +#[ignore] // failing +fn scope() { + assert_eq!( + rsass( + "// Arguments passed to @content blocks are lexically-scoped within those blocks.\n\n$var: top-level;\n\n@mixin mixin($var) {\n mixin-var-before: $var;\n @content(content-argument);\n mixin-var-after: $var;\n}\n\n@mixin inner {\n var-in-inner: $var;\n}\n\nscope {\n var-before: $var;\n @include mixin(mixin-argument) using ($var) {\n content-var-before: $var;\n @include inner;\n content-var-after: $var;\n }\n var-after: $var;\n}\n" + ) + .unwrap(), + "scope {\n var-before: top-level;\n mixin-var-before: mixin-argument;\n content-var-before: content-argument;\n var-in-inner: top-level;\n content-var-after: content-argument;\n mixin-var-after: mixin-argument;\n var-after: top-level;\n}\n" + ); +} + +/// From "sass-spec/spec/mixin/content/arguments/weird_syntax" +#[test] +#[ignore] // failing +fn weird_syntax() { + assert_eq!( + rsass( + "no-space-before-using {\n @mixin mixin {\n @content(value1, value2);\n }\n\n @include mixin()using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nno-space-after-using {\n @mixin mixin {\n @content(value1, value2);\n }\n\n @include mixin using($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nno-space-after-arglist {\n @mixin mixin {\n @content(value1, value2);\n }\n\n @include mixin using($arg1, $arg2){\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\nspace-after-content {\n @mixin mixin {\n @content (value1, value2);\n }\n\n @include mixin using ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n\ncase-insensitive-using {\n @mixin mixin {\n @content(value1, value2);\n }\n\n @include mixin UsInG ($arg1, $arg2) {\n arg1: $arg1;\n arg2: $arg2;\n }\n}\n" + ) + .unwrap(), + "no-space-before-using {\n arg1: value1;\n arg2: value2;\n}\nno-space-after-using {\n arg1: value1;\n arg2: value2;\n}\nno-space-after-arglist {\n arg1: value1;\n arg2: value2;\n}\nspace-after-content {\n arg1: value1;\n arg2: value2;\n}\ncase-insensitive-using {\n arg1: value1;\n arg2: value2;\n}\n" + ); +} diff --git a/tests/mixin/content/mod.rs b/tests/mixin/content/mod.rs new file mode 100644 index 000000000..d54adcab1 --- /dev/null +++ b/tests/mixin/content/mod.rs @@ -0,0 +1,31 @@ +//! Tests auto-converted from "sass-spec/spec/mixin/content" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +mod arguments; + +/// From "sass-spec/spec/mixin/content/before_if" +#[test] +fn before_if() { + assert_eq!( + rsass( + "// Regression test for sass/dart-sass#482.\n@mixin outer {\n a {@content}\n}\n\n@mixin inner {\n @content;\n}\n\n@include outer {\n @include inner {}\n x: y;\n}" + ) + .unwrap(), + "a {\n x: y;\n}\n" + ); +} + +/// From "sass-spec/spec/mixin/content/recursive" +#[test] +fn recursive() { + assert_eq!( + rsass( + "@mixin span($i) {\n x: y;\n @content;\n}\n\n.a {\n @include span(5) {\n .inner { @include span(2); }\n }\n}\n" + ) + .unwrap(), + ".a {\n x: y;\n}\n.a .inner {\n x: y;\n}\n" + ); +} diff --git a/tests/mixin/error/mod.rs b/tests/mixin/error/mod.rs new file mode 100644 index 000000000..2c84b032c --- /dev/null +++ b/tests/mixin/error/mod.rs @@ -0,0 +1,7 @@ +//! Tests auto-converted from "sass-spec/spec/mixin/error" +#[allow(unused)] +use super::rsass; +#[allow(unused)] +use rsass::set_precision; + +// Ignoring "no_content", tests with expected error not implemented yet. diff --git a/tests/mixin/main.rs b/tests/mixin/main.rs new file mode 100644 index 000000000..f52f34825 --- /dev/null +++ b/tests/mixin/main.rs @@ -0,0 +1,30 @@ +//! Tests auto-converted from "sass-spec/spec/mixin" +//! version dd3a5edf, 2019-02-04 13:14:26 -0800. +//! See for source material.\n +use rsass::{compile_scss, OutputStyle}; + +mod content; + +/// From "sass-spec/spec/mixin/environment_locality" +#[test] +fn environment_locality() { + assert_eq!( + rsass( + "// The \"$var\" variable should only be set locally, despite being in the same\n// mixin each time.\n@mixin with-local-variable($recurse) {\n $var: before;\n\n @if ($recurse) {\n @include with-local-variable($recurse: false);\n }\n\n var: $var;\n $var: after;\n}\n\n.environment-locality {\n @include with-local-variable($recurse: true);\n}\n" + ) + .unwrap(), + ".environment-locality {\n var: before;\n var: before;\n}\n" + ); +} + +mod error; + +fn rsass(input: &str) -> Result { + compile_scss(input.as_bytes(), OutputStyle::Expanded) + .map_err(|e| format!("rsass failed: {}", e)) + .and_then(|s| { + String::from_utf8(s) + .map(|s| s.replace("\n\n", "\n")) + .map_err(|e| format!("{:?}", e)) + }) +} diff --git a/tests/scope.rs b/tests/scope.rs deleted file mode 100644 index b68d0a77d..000000000 --- a/tests/scope.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! These are from the `scope` directory in the sass specification. -use rsass::{compile_scss, OutputStyle}; - -#[test] -fn clash() { - check( - "$foo: 42;\n$bar: 43;\n$baz: 45;\n\n\ - foo {\n foo: $foo;\n bar: $bar;\n baz: $baz;\n\n\ - $bar: 4; // this is a different $bar than `$bar !global`\n\n \ - foo: $foo;\n bar: $bar;\n baz: $baz;\n\n \ - @if true {\n \ - $foo: 3; // this is a different $foo than `$foo !global`\n \ - $bar: 5; // this is a different $bar than `$bar !global`\n\n \ - foo: $foo;\n bar: $bar;\n baz: $baz;\n }\n}\n", - "foo {\n foo: 42;\n bar: 43;\n baz: 45;\n foo: 42;\n \ - bar: 4;\n baz: 45;\n foo: 3;\n bar: 5;\n baz: 45;\n}\n", - ) -} - -#[test] -fn each() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n}\n\n\ - @each $item in 1337 {\n $foo: $item !global;\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn test_for() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n}\n\n\ - @for $i from 1337 to 1338 {\n $foo: $i !global;\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn function() { - check( - "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n\ - @function foo() {\n $foo: 1337 !global;\n @return $foo;\n}\n\n\ - @if foo() {}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn test_if() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n}\n\n\ - @if true {\n $foo: 1337 !global;\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn mixin() { - check( - "$foo: 42;\n\n\ - @mixin foo {\n $foo: 1337 !global;\n}\n\n\ - .foo {\n content: $foo;\n}\n\n\ - @include foo;\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn nested() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n\n \ - > .bar {\n $foo: 1337 !global;\n }\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn root() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n}\n\n\ - $foo: 1337 !global;\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn ruleset() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n $foo: 1337 !global;\n \ - content: $foo;\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n content: 1337;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -#[test] -fn test_while() { - check( - "$foo: 42;\n\n\ - .foo {\n content: $foo;\n}\n\n\ - $condition: 1337;\n\ - @while $condition > 0 {\n $foo: $condition !global;\n \ - $condition: 0;\n}\n\n\ - .bar {\n content: $foo;\n}\n", - ".foo {\n content: 42;\n}\n\n\ - .bar {\n content: 1337;\n}\n", - ) -} - -fn check(input: &str, expected: &str) { - assert_eq!( - compile_scss(input.as_bytes(), OutputStyle::Expanded) - .and_then(|s| Ok(String::from_utf8(s)?)) - .unwrap(), - expected - ); -} diff --git a/tests/scope/main.rs b/tests/scope/main.rs new file mode 100644 index 000000000..385ae3955 --- /dev/null +++ b/tests/scope/main.rs @@ -0,0 +1,134 @@ +//! Tests auto-converted from "sass-spec/spec/scope" +//! version dd3a5edf, 2019-02-04 13:14:26 -0800. +//! See for source material.\n +use rsass::{compile_scss, OutputStyle}; + +/// From "sass-spec/spec/scope/clash" +#[test] +fn clash() { + assert_eq!( + rsass( + "$foo: 42;\n$bar: 43;\n$baz: 45;\n\nfoo {\n foo: $foo;\n bar: $bar;\n baz: $baz;\n\n $bar: 4; // this is a different $bar than `$bar !global`\n\n foo: $foo;\n bar: $bar;\n baz: $baz;\n\n @if true {\n $foo: 3; // this is a different $foo than `$foo !global`\n $bar: 5; // this is a different $bar than `$bar !global`\n\n foo: $foo;\n bar: $bar;\n baz: $baz;\n }\n}\n" + ) + .unwrap(), + "foo {\n foo: 42;\n bar: 43;\n baz: 45;\n foo: 42;\n bar: 4;\n baz: 45;\n foo: 3;\n bar: 5;\n baz: 45;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/each" +#[test] +fn each() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n@each $item in 1337 {\n $foo: $item !global;\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/for" +#[test] +fn test_for() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n@for $i from 1337 to 1338 {\n $foo: $i !global;\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/function" +#[test] +fn function() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n@function foo() {\n $foo: 1337 !global;\n @return $foo;\n}\n\n@if foo() {}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/if" +#[test] +fn test_if() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n@if true {\n $foo: 1337 !global;\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/mixin" +#[test] +fn mixin() { + assert_eq!( + rsass( + "$foo: 42;\n\n@mixin foo {\n $foo: 1337 !global;\n}\n\n.foo {\n content: $foo;\n}\n\n@include foo;\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/nested" +#[test] +fn nested() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n\n > .bar {\n $foo: 1337 !global;\n }\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/root" +#[test] +fn root() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n$foo: 1337 !global;\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/ruleset" +#[test] +fn ruleset() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n $foo: 1337 !global;\n content: $foo;\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n content: 1337;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +/// From "sass-spec/spec/scope/while" +#[test] +fn test_while() { + assert_eq!( + rsass( + "$foo: 42;\n\n.foo {\n content: $foo;\n}\n\n$condition: 1337;\n@while $condition > 0 {\n $foo: $condition !global;\n $condition: 0;\n}\n\n.bar {\n content: $foo;\n}\n" + ) + .unwrap(), + ".foo {\n content: 42;\n}\n.bar {\n content: 1337;\n}\n" + ); +} + +fn rsass(input: &str) -> Result { + compile_scss(input.as_bytes(), OutputStyle::Expanded) + .map_err(|e| format!("rsass failed: {}", e)) + .and_then(|s| { + String::from_utf8(s) + .map(|s| s.replace("\n\n", "\n")) + .map_err(|e| format!("{:?}", e)) + }) +} diff --git a/tests/scss_tests/main.rs b/tests/scss_tests/main.rs new file mode 100644 index 000000000..8fe55665f --- /dev/null +++ b/tests/scss_tests/main.rs @@ -0,0 +1,1355 @@ +//! Tests auto-converted from "sass-spec/spec/scss-tests" +//! version dd3a5edf, 2019-02-04 13:14:26 -0800. +//! See for source material.\n +use rsass::{compile_scss, OutputStyle}; + +/// From "sass-spec/spec/scss-tests/001_test_one_line_comments" +#[test] +fn t001_test_one_line_comments() { + assert_eq!( + rsass(".foo {// bar: baz;}\n baz: bang; //}\n}\n").unwrap(), + ".foo {\n baz: bang;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/002_test_one_line_comments" +#[test] +fn t002_test_one_line_comments() { + assert_eq!( + rsass(".foo bar[val=\"//\"] {\n baz: bang; //}\n}\n").unwrap(), + ".foo bar[val=\"//\"] {\n baz: bang;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/003_test_variables" +#[test] +fn t003_test_variables() { + assert_eq!( + rsass("$var: foo;\n\nblat {a: $var}\n").unwrap(), + "blat {\n a: foo;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/004_test_variables" +#[test] +fn t004_test_variables() { + assert_eq!( + rsass( + "foo {\n $var: 2;\n $another-var: 4;\n a: $var;\n b: $var + $another-var;}\n" + ) + .unwrap(), + "foo {\n a: 2;\n b: 6;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/005_test_unicode_variables" +#[test] +fn t005_test_unicode_variables() { + assert_eq!( + rsass("$vär: foo;\n\nblat {a: $vär}\n").unwrap(), + "blat {\n a: foo;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/006_test_guard_assign" +#[test] +fn t006_test_guard_assign() { + assert_eq!( + rsass("$var: 1;\n$var: 2 !default;\n\nfoo {a: $var}\n").unwrap(), + "foo {\n a: 1;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/007_test_guard_assign" +#[test] +fn t007_test_guard_assign() { + assert_eq!( + rsass("$var: 2 !default;\n\nfoo {a: $var}\n").unwrap(), + "foo {\n a: 2;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/008_test_sass_script" +#[test] +fn t008_test_sass_script() { + assert_eq!( + rsass( + "foo {\n a: 1 + 2;\n b: 1 - 2;\n c: foo + bar;\n d: floor(12.3px); }\n" + ) + .unwrap(), + "foo {\n a: 3;\n b: -1;\n c: foobar;\n d: 12px;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/009_test_for_directive" +#[test] +fn t009_test_for_directive() { + assert_eq!( + rsass(".foo {\n @for $var from 1 to 5 {a: $var;}\n}\n").unwrap(), + ".foo {\n a: 1;\n a: 2;\n a: 3;\n a: 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/010_test_for_directive" +#[test] +fn t010_test_for_directive() { + assert_eq!( + rsass(".foo {\n @for $var from 1 through 5 {a: $var;}\n}\n") + .unwrap(), + ".foo {\n a: 1;\n a: 2;\n a: 3;\n a: 4;\n a: 5;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/011_test_if_directive" +#[test] +fn t011_test_if_directive() { + assert_eq!( + rsass( + "@if \"foo\" == \"foo\" {foo {a: b}}\n@if \"foo\" != \"foo\" {bar {a: b}}\n" + ) + .unwrap(), + "foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/012_test_if_directive" +#[test] +fn t012_test_if_directive() { + assert_eq!( + rsass( + "@if \"foo\" != \"foo\" {foo {a: b}}\n@else if \"foo\" == \"foo\" {bar {a: b}}\n@else if true {baz {a: b}}\n" + ) + .unwrap(), + "bar {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/013_test_if_directive" +#[test] +fn t013_test_if_directive() { + assert_eq!( + rsass("@if \"foo\" != \"foo\" {foo {a: b}}\n@else {bar {a: b}}\n") + .unwrap(), + "bar {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/014_test_comment_after_if_directive" +#[test] +fn t014_test_comment_after_if_directive() { + assert_eq!( + rsass( + "foo {\n @if true {a: b}\n /* This is a comment */\n c: d }\n" + ) + .unwrap(), + "foo {\n a: b;\n /* This is a comment */\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/015_test_comment_after_if_directive" +#[test] +fn t015_test_comment_after_if_directive() { + assert_eq!( + rsass( + "foo {\n @if true {a: b}\n @else {x: y}\n /* This is a comment */\n c: d }\n" + ) + .unwrap(), + "foo {\n a: b;\n /* This is a comment */\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/017_test_each_directive" +#[test] +fn t017_test_each_directive() { + assert_eq!( + rsass( + "a {\n @each $number in 1px 2px 3px 4px {\n b: $number;\n }\n}\nc {\n @each $str in foo, bar, baz, bang {\n d: $str;\n }\n}\n" + ) + .unwrap(), + "a {\n b: 1px;\n b: 2px;\n b: 3px;\n b: 4px;\n}\nc {\n d: foo;\n d: bar;\n d: baz;\n d: bang;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/019_test_css_import_directive" +#[test] +fn t019_test_css_import_directive() { + assert_eq!( + rsass("@import \"foo.css\";").unwrap(), + "@import url(foo.css);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/020_test_css_import_directive" +#[test] +fn t020_test_css_import_directive() { + assert_eq!( + rsass("@import \'foo.css\';").unwrap(), + "@import url(foo.css);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/021_test_css_import_directive" +#[test] +fn t021_test_css_import_directive() { + assert_eq!( + rsass("@import url(\"foo.css\");").unwrap(), + "@import url(\"foo.css\");\n" + ); +} + +/// From "sass-spec/spec/scss-tests/022_test_css_import_directive" +#[test] +fn t022_test_css_import_directive() { + assert_eq!( + rsass("@import url(\"foo.css\");").unwrap(), + "@import url(\"foo.css\");\n" + ); +} + +/// From "sass-spec/spec/scss-tests/023_test_css_import_directive" +#[test] +fn t023_test_css_import_directive() { + assert_eq!( + rsass("@import url(foo.css);").unwrap(), + "@import url(foo.css);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/024_test_media_import" +#[test] +#[ignore] // failing +fn t024_test_media_import() { + assert_eq!( + rsass("@import \"./fonts.sass\" all;").unwrap(), + "@import \"./fonts.sass\" all;\n" + ); +} + +/// From "sass-spec/spec/scss-tests/025_test_dynamic_media_import" +#[test] +#[ignore] // failing +fn t025_test_dynamic_media_import() { + assert_eq!( + rsass( + "$media: print;\n$key: -webkit-min-device-pixel-ratio;\n$value: 20;\n@import \"foo\" #{$media} and ($key + \"-foo\": $value + 5);\n" + ) + .unwrap(), + "@import \"foo\" print and (-webkit-min-device-pixel-ratio-foo: 25);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/027_test_protocol_relative_import" +#[test] +#[ignore] // failing +fn t027_test_protocol_relative_import() { + assert_eq!( + rsass("@import \"//fonts.googleapis.com/css?family=Droid+Sans\";") + .unwrap(), + "@import \"//fonts.googleapis.com/css?family=Droid+Sans\";\n" + ); +} + +/// From "sass-spec/spec/scss-tests/028_test_import_with_interpolation" +#[test] +fn t028_test_import_with_interpolation() { + assert_eq!( + rsass( + "$family: unquote(\"Droid+Sans\");\n@import url(\"http://fonts.googleapis.com/css?family=#{$family}\");\n" + ) + .unwrap(), + "@import url(\"http://fonts.googleapis.com/css?family=Droid+Sans\");\n" + ); +} + +/// From "sass-spec/spec/scss-tests/029_test_url_import" +#[test] +fn t029_test_url_import() { + assert_eq!( + rsass("@import url(fonts.sass);").unwrap(), + "@import url(fonts.sass);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/030_test_block_comment_in_script" +#[test] +fn t030_test_block_comment_in_script() { + assert_eq!( + rsass("foo {a: 1 + /* flang */ bar}\n").unwrap(), + "foo {\n a: 1bar;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/031_test_line_comment_in_script" +#[test] +fn t031_test_line_comment_in_script() { + assert_eq!( + rsass("foo {a: 1 + // flang }\n blang }\n").unwrap(), + "foo {\n a: 1blang;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/032_test_nested_rules" +#[test] +fn t032_test_nested_rules() { + assert_eq!( + rsass("foo {bar {a: b}}\n").unwrap(), + "foo bar {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/033_test_nested_rules" +#[test] +fn t033_test_nested_rules() { + assert_eq!( + rsass("foo {\n bar {a: b}\n baz {b: c}}\n").unwrap(), + "foo bar {\n a: b;\n}\nfoo baz {\n b: c;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/034_test_nested_rules" +#[test] +fn t034_test_nested_rules() { + assert_eq!( + rsass("foo {\n bar {baz {a: b}}\n bang {bip {a: b}}}\n").unwrap(), + "foo bar baz {\n a: b;\n}\nfoo bang bip {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/035_test_nested_rules_with_declarations" +#[test] +fn t035_test_nested_rules_with_declarations() { + assert_eq!( + rsass("foo {\n a: b;\n bar {c: d}}\n").unwrap(), + "foo {\n a: b;\n}\nfoo bar {\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/036_test_nested_rules_with_declarations" +#[test] +fn t036_test_nested_rules_with_declarations() { + assert_eq!( + rsass("foo {\n bar {c: d}\n a: b}\n").unwrap(), + "foo {\n a: b;\n}\nfoo bar {\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/037_test_nested_rules_with_declarations" +#[test] +fn t037_test_nested_rules_with_declarations() { + assert_eq!( + rsass( + "foo {\n ump: nump;\n grump: clump;\n bar {\n blat: bang;\n habit: rabbit;\n baz {a: b}\n bip {c: d}}\n bibble {\n bap {e: f}}}\n" + ) + .unwrap(), + "foo {\n ump: nump;\n grump: clump;\n}\nfoo bar {\n blat: bang;\n habit: rabbit;\n}\nfoo bar baz {\n a: b;\n}\nfoo bar bip {\n c: d;\n}\nfoo bibble bap {\n e: f;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/038_test_nested_rules_with_fancy_selectors" +#[test] +fn t038_test_nested_rules_with_fancy_selectors() { + assert_eq!( + rsass("foo {\n .bar {a: b}\n :baz {c: d}\n bang:bop {e: f}}\n") + .unwrap(), + "foo .bar {\n a: b;\n}\nfoo :baz {\n c: d;\n}\nfoo bang:bop {\n e: f;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/039_test_almost_ambiguous_nested_rules_and_declarations" +#[test] +fn t039_test_almost_ambiguous_nested_rules_and_declarations() { + assert_eq!( + rsass( + "foo {\n bar:baz:bang:bop:biddle:woo:look:at:all:these:pseudoclasses {a: b};\n bar:baz bang bop biddle woo look at all these elems {a: b};\n bar:baz bang bop biddle woo look at all these elems; }\n" + ) + .unwrap(), + "foo {\n bar: baz bang bop biddle woo look at all these elems;\n}\nfoo bar:baz:bang:bop:biddle:woo:look:at:all:these:pseudoclasses {\n a: b;\n}\nfoo bar:baz bang bop biddle woo look at all these elems {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/040_test_newlines_in_selectors" +#[test] +#[ignore] // failing +fn t040_test_newlines_in_selectors() { + assert_eq!( + rsass("foo\nbar {a: b}\n").unwrap(), + "foo\nbar {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/041_test_newlines_in_selectors" +#[test] +#[ignore] // failing +fn t041_test_newlines_in_selectors() { + assert_eq!( + rsass("foo,\nbar {\n baz,\n bang {a: b}}\n").unwrap(), + "foo baz,\nfoo bang,\nbar baz,\nbar bang {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/042_test_newlines_in_selectors" +#[test] +#[ignore] // failing +fn t042_test_newlines_in_selectors() { + assert_eq!( + rsass("foo\nbar {\n baz\n bang {a: b}\n\n bip bop {c: d}}\n") + .unwrap(), + "foo\nbar baz\nbang {\n a: b;\n}\nfoo\nbar bip bop {\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/043_test_newlines_in_selectors" +#[test] +#[ignore] // failing +fn t043_test_newlines_in_selectors() { + assert_eq!( + rsass("foo, bar\nbaz {\n bang, bip\n bop {a: b}}\n").unwrap(), + "foo bang, foo bip\nbop, bar\nbaz bang, bar\nbaz bip\nbop {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/044_test_trailing_comma_in_selector" +#[test] +#[ignore] // failing +fn t044_test_trailing_comma_in_selector() { + assert_eq!( + rsass("#foo #bar,,\n,#baz #boom, {a: b}\n\n#bip #bop, ,, {c: d}\n") + .unwrap(), + "#foo #bar,\n#baz #boom {\n a: b;\n}\n#bip #bop {\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/045_test_parent_selectors" +#[test] +fn t045_test_parent_selectors() { + assert_eq!( + rsass("foo {\n &:hover {a: b}\n bar &.baz {c: d}}\n").unwrap(), + "foo:hover {\n a: b;\n}\nbar foo.baz {\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/047_test_unknown_directive_bubbling" +#[test] +fn t047_test_unknown_directive_bubbling() { + assert_eq!( + rsass(".foo {\n @fblthp {\n .bar {a: b}\n }\n}\n").unwrap(), + "@fblthp {\n .foo .bar {\n a: b;\n }\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/048_test_namespace_properties" +#[test] +fn t048_test_namespace_properties() { + assert_eq!( + rsass( + "foo {\n bar: baz;\n bang: {\n bip: 1px;\n bop: bar;}}\n" + ) + .unwrap(), + "foo {\n bar: baz;\n bang-bip: 1px;\n bang-bop: bar;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/049_test_several_namespace_properties" +#[test] +fn t049_test_several_namespace_properties() { + assert_eq!( + rsass( + "foo {\n bar: baz;\n bang: {\n bip: 1px;\n bop: bar;}\n buzz: {\n fram: \"foo\";\n frum: moo;\n }\n}\n" + ) + .unwrap(), + "foo {\n bar: baz;\n bang-bip: 1px;\n bang-bop: bar;\n buzz-fram: \"foo\";\n buzz-frum: moo;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/050_test_nested_namespace_properties" +#[test] +fn t050_test_nested_namespace_properties() { + assert_eq!( + rsass( + "foo {\n bar: baz;\n bang: {\n bip: 1px;\n bop: bar;\n blat:{baf:bort}}}\n" + ) + .unwrap(), + "foo {\n bar: baz;\n bang-bip: 1px;\n bang-bop: bar;\n bang-blat-baf: bort;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/051_test_namespace_properties_with_value" +#[test] +fn t051_test_namespace_properties_with_value() { + assert_eq!( + rsass("foo {\n bar: baz {\n bip: bop;\n bing: bop; }}\n") + .unwrap(), + "foo {\n bar: baz;\n bar-bip: bop;\n bar-bing: bop;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/052_test_namespace_properties_with_script_value" +#[test] +fn t052_test_namespace_properties_with_script_value() { + assert_eq!( + rsass( + "foo {\n bar: baz + bang {\n bip: bop;\n bing: bop; }}\n" + ) + .unwrap(), + "foo {\n bar: bazbang;\n bar-bip: bop;\n bar-bing: bop;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/053_test_no_namespace_properties_without_space" +#[test] +fn t053_test_no_namespace_properties_without_space() { + assert_eq!( + rsass("foo {\n bar:baz {\n bip: bop }}\n").unwrap(), + "foo bar:baz {\n bip: bop;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/054_test_basic_mixins" +#[test] +fn t054_test_basic_mixins() { + assert_eq!( + rsass("@mixin foo {\n .foo {a: b}}\n\n@include foo;\n").unwrap(), + ".foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/055_test_basic_mixins" +#[test] +fn t055_test_basic_mixins() { + assert_eq!( + rsass( + "@mixin foo {\n .foo {a: b}}\n\nbar {\n @include foo;\n c: d; }\n" + ) + .unwrap(), + "bar {\n c: d;\n}\nbar .foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/056_test_basic_mixins" +#[test] +fn t056_test_basic_mixins() { + assert_eq!( + rsass("@mixin foo {a: b}\n\nbar {\n @include foo;\n c: d; }\n") + .unwrap(), + "bar {\n a: b;\n c: d;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/057_test_mixins_with_empty_args" +#[test] +fn t057_test_mixins_with_empty_args() { + assert_eq!( + rsass("@mixin foo() {a: b}\n\n.foo {@include foo();}\n").unwrap(), + ".foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/058_test_mixins_with_empty_args" +#[test] +fn t058_test_mixins_with_empty_args() { + assert_eq!( + rsass("@mixin foo() {a: b}\n\n.foo {@include foo;}\n").unwrap(), + ".foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/059_test_mixins_with_empty_args" +#[test] +fn t059_test_mixins_with_empty_args() { + assert_eq!( + rsass("@mixin foo {a: b}\n\n.foo {@include foo();}\n").unwrap(), + ".foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/060_test_mixins_with_args" +#[test] +fn t060_test_mixins_with_args() { + assert_eq!( + rsass("@mixin foo($a) {a: $a}\n\n.foo {@include foo(bar)}\n") + .unwrap(), + ".foo {\n a: bar;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/061_test_mixins_with_args" +#[test] +fn t061_test_mixins_with_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b) {\n a: $a;\n b: $b; }\n\n.foo {@include foo(bar, 12px)}\n" + ) + .unwrap(), + ".foo {\n a: bar;\n b: 12px;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/062_test_basic_function" +#[test] +fn t062_test_basic_function() { + assert_eq!( + rsass( + "@function foo() {\n @return 1 + 2;\n}\n\nbar {\n a: foo();\n}\n" + ) + .unwrap(), + "bar {\n a: 3;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/063_test_function_args" +#[test] +fn t063_test_function_args() { + assert_eq!( + rsass( + "@function plus($var1, $var2) {\n @return $var1 + $var2;\n}\n\nbar {\n a: plus(1, 2);\n}\n" + ) + .unwrap(), + "bar {\n a: 3;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/064_test_mixin_var_args" +#[test] +fn t064_test_mixin_var_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b...) {\n a: $a;\n b: $b;\n}\n\n.foo {@include foo(1, 2, 3, 4)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2, 3, 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/065_test_mixin_empty_var_args" +#[test] +#[ignore] // failing +fn t065_test_mixin_empty_var_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b...) {\n a: $a;\n b: length($b);\n}\n\n.foo {@include foo(1)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 0;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/066_test_mixin_var_args_act_like_list" +#[test] +fn t066_test_mixin_var_args_act_like_list() { + assert_eq!( + rsass( + "@mixin foo($a, $b...) {\n a: length($b);\n b: nth($b, 2);\n}\n\n.foo {@include foo(1, 2, 3, 4)}\n" + ) + .unwrap(), + ".foo {\n a: 3;\n b: 3;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/067_test_mixin_splat_args" +#[test] +#[ignore] // failing +fn t067_test_mixin_splat_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b, $c, $d) {\n a: $a;\n b: $b;\n c: $c;\n d: $d;\n}\n\n$list: 2, 3, 4;\n.foo {@include foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2;\n c: 3;\n d: 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/068_test_mixin_splat_expression" +#[test] +#[ignore] // failing +fn t068_test_mixin_splat_expression() { + assert_eq!( + rsass( + "@mixin foo($a, $b, $c, $d) {\n a: $a;\n b: $b;\n c: $c;\n d: $d;\n}\n\n.foo {@include foo(1, (2, 3, 4)...)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2;\n c: 3;\n d: 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/069_test_mixin_splat_args_with_var_args" +#[test] +#[ignore] // failing +fn t069_test_mixin_splat_args_with_var_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b...) {\n a: $a;\n b: $b;\n}\n\n$list: 2, 3, 4;\n.foo {@include foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2, 3, 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/070_test_mixin_splat_args_with_var_args_and_normal_args" +#[test] +#[ignore] // failing +fn t070_test_mixin_splat_args_with_var_args_and_normal_args() { + assert_eq!( + rsass( + "@mixin foo($a, $b, $c...) {\n a: $a;\n b: $b;\n c: $c;\n}\n\n$list: 2, 3, 4;\n.foo {@include foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2;\n c: 3, 4;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/071_test_mixin_splat_args_with_var_args_preserves_separator" +#[test] +#[ignore] // failing +fn t071_test_mixin_splat_args_with_var_args_preserves_separator() { + assert_eq!( + rsass( + "@mixin foo($a, $b...) {\n a: $a;\n b: $b;\n}\n\n$list: 3 4 5;\n.foo {@include foo(1, 2, $list...)}\n" + ) + .unwrap(), + ".foo {\n a: 1;\n b: 2 3 4 5;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/072_test_mixin_var_and_splat_args_pass_through_keywords" +#[test] +#[ignore] // failing +fn t072_test_mixin_var_and_splat_args_pass_through_keywords() { + assert_eq!( + rsass( + "@mixin foo($a...) {\n @include bar($a...);\n}\n\n@mixin bar($b, $c, $a) {\n a: $a;\n b: $b;\n c: $c;\n}\n\n.foo {@include foo(1, $c: 2, $a: 3)}\n" + ) + .unwrap(), + ".foo {\n a: 3;\n b: 1;\n c: 2;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/078_test_mixin_list_of_pairs_splat_treated_as_list" +#[test] +#[ignore] // failing +fn t078_test_mixin_list_of_pairs_splat_treated_as_list() { + assert_eq!( + rsass( + "@mixin foo($a, $b, $c) {\n a: $a;\n b: $b;\n c: $c;\n}\n\n.foo {\n @include foo((a 1, b 2, c 3)...);\n}\n" + ) + .unwrap(), + ".foo {\n a: a 1;\n b: b 2;\n c: c 3;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/083_test_function_var_args" +#[test] +fn t083_test_function_var_args() { + assert_eq!( + rsass( + "@function foo($a, $b...) {\n @return \"a: #{$a}, b: #{$b}\";\n}\n\n.foo {val: foo(1, 2, 3, 4)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2, 3, 4\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/084_test_function_empty_var_args" +#[test] +#[ignore] // failing +fn t084_test_function_empty_var_args() { + assert_eq!( + rsass( + "@function foo($a, $b...) {\n @return \"a: #{$a}, b: #{length($b)}\";\n}\n\n.foo {val: foo(1)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 0\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/085_test_function_var_args_act_like_list" +#[test] +fn t085_test_function_var_args_act_like_list() { + assert_eq!( + rsass( + "@function foo($a, $b...) {\n @return \"a: #{length($b)}, b: #{nth($b, 2)}\";\n}\n\n.foo {val: foo(1, 2, 3, 4)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 3, b: 3\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/086_test_function_splat_args" +#[test] +#[ignore] // failing +fn t086_test_function_splat_args() { + assert_eq!( + rsass( + "@function foo($a, $b, $c, $d) {\n @return \"a: #{$a}, b: #{$b}, c: #{$c}, d: #{$d}\";\n}\n\n$list: 2, 3, 4;\n.foo {val: foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2, c: 3, d: 4\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/087_test_function_splat_expression" +#[test] +#[ignore] // failing +fn t087_test_function_splat_expression() { + assert_eq!( + rsass( + "@function foo($a, $b, $c, $d) {\n @return \"a: #{$a}, b: #{$b}, c: #{$c}, d: #{$d}\";\n}\n\n.foo {val: foo(1, (2, 3, 4)...)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2, c: 3, d: 4\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/088_test_function_splat_args_with_var_args" +#[test] +#[ignore] // failing +fn t088_test_function_splat_args_with_var_args() { + assert_eq!( + rsass( + "@function foo($a, $b...) {\n @return \"a: #{$a}, b: #{$b}\";\n}\n\n$list: 2, 3, 4;\n.foo {val: foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2, 3, 4\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/089_test_function_splat_args_with_var_args_and_normal_args" +#[test] +#[ignore] // failing +fn t089_test_function_splat_args_with_var_args_and_normal_args() { + assert_eq!( + rsass( + "@function foo($a, $b, $c...) {\n @return \"a: #{$a}, b: #{$b}, c: #{$c}\";\n}\n\n$list: 2, 3, 4;\n.foo {val: foo(1, $list...)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2, c: 3, 4\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/090_test_function_splat_args_with_var_args_preserves_separator" +#[test] +#[ignore] // failing +fn t090_test_function_splat_args_with_var_args_preserves_separator() { + assert_eq!( + rsass( + "@function foo($a, $b...) {\n @return \"a: #{$a}, b: #{$b}\";\n}\n\n$list: 3 4 5;\n.foo {val: foo(1, 2, $list...)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 1, b: 2 3 4 5\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/091_test_function_var_and_splat_args_pass_through_keywords" +#[test] +#[ignore] // failing +fn t091_test_function_var_and_splat_args_pass_through_keywords() { + assert_eq!( + rsass( + "@function foo($a...) {\n @return bar($a...);\n}\n\n@function bar($b, $c, $a) {\n @return \"a: #{$a}, b: #{$b}, c: #{$c}\";\n}\n\n.foo {val: foo(1, $c: 2, $a: 3)}\n" + ) + .unwrap(), + ".foo {\n val: \"a: 3, b: 1, c: 2\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/098_test_function_list_of_pairs_splat_treated_as_list" +#[test] +#[ignore] // failing +fn t098_test_function_list_of_pairs_splat_treated_as_list() { + assert_eq!( + rsass( + "@function foo($a, $b, $c) {\n @return \"a: #{$a}, b: #{$b}, c: #{$c}\";\n}\n\n.foo {\n val: foo((a 1, b 2, c 3)...);\n}\n" + ) + .unwrap(), + ".foo {\n val: \"a: a 1, b: b 2, c: c 3\";\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/103_test_function_var_args_passed_to_native" +#[test] +#[ignore] // failing +fn t103_test_function_var_args_passed_to_native() { + assert_eq!( + rsass( + "@function foo($args...) {\n @return adjust-color($args...);\n}\n\n.foo {val: foo(#102030, $blue: 5)}\n" + ) + .unwrap(), + ".foo {\n val: #102035;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/104_test_basic_selector_interpolation" +#[test] +fn t104_test_basic_selector_interpolation() { + assert_eq!( + rsass("foo#{1 + 2} baz {a: b}\n").unwrap(), + "foo3 baz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/105_test_basic_selector_interpolation" +#[test] +fn t105_test_basic_selector_interpolation() { + assert_eq!( + rsass("foo#{\".bar\"} baz {a: b}\n").unwrap(), + "foo.bar baz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/106_test_basic_selector_interpolation" +#[test] +fn t106_test_basic_selector_interpolation() { + assert_eq!( + rsass("#{\"foo\"}.bar baz {a: b}\n").unwrap(), + "foo.bar baz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/107_test_selector_only_interpolation" +#[test] +fn t107_test_selector_only_interpolation() { + assert_eq!( + rsass("#{\"foo\" + \" bar\"} {a: b}\n").unwrap(), + "foo bar {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/108_test_selector_interpolation_before_element_name" +#[test] +fn t108_test_selector_interpolation_before_element_name() { + assert_eq!( + rsass("#{\"foo\" + \" bar\"}baz {a: b}\n").unwrap(), + "foo barbaz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/109_test_selector_interpolation_in_string" +#[test] +fn t109_test_selector_interpolation_in_string() { + assert_eq!( + rsass("foo[val=\"bar #{\"foo\" + \" bar\"} baz\"] {a: b}\n").unwrap(), + "foo[val=\"bar foo bar baz\"] {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/110_test_selector_interpolation_in_pseudoclass" +#[test] +fn t110_test_selector_interpolation_in_pseudoclass() { + assert_eq!( + rsass("foo:nth-child(#{5 + \"n\"}) {a: b}\n").unwrap(), + "foo:nth-child(5n) {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/111_test_selector_interpolation_at_class_begininng" +#[test] +fn t111_test_selector_interpolation_at_class_begininng() { + assert_eq!( + rsass("$zzz: zzz;\n.#{$zzz} { a: b; }\n").unwrap(), + ".zzz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/112_test_selector_interpolation_at_id_begininng" +#[test] +fn t112_test_selector_interpolation_at_id_begininng() { + assert_eq!( + rsass("$zzz: zzz;\n##{$zzz} { a: b; }\n").unwrap(), + "#zzz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/113_test_selector_interpolation_at_pseudo_begininng" +#[test] +fn t113_test_selector_interpolation_at_pseudo_begininng() { + assert_eq!( + rsass("$zzz: zzz;\n:#{$zzz}::#{$zzz} { a: b; }\n").unwrap(), + ":zzz::zzz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/114_test_selector_interpolation_at_attr_beginning" +#[test] +fn t114_test_selector_interpolation_at_attr_beginning() { + assert_eq!( + rsass("$zzz: zzz;\n[#{$zzz}=foo] { a: b; }\n").unwrap(), + "[zzz=foo] {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/115_test_selector_interpolation_at_attr_end" +#[test] +fn t115_test_selector_interpolation_at_attr_end() { + assert_eq!( + rsass("$zzz: zzz;\n[foo=#{$zzz}] { a: b; }\n").unwrap(), + "[foo=zzz] {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/116_test_selector_interpolation_at_dashes" +#[test] +fn t116_test_selector_interpolation_at_dashes() { + assert_eq!( + rsass("$a : a;\n$b : b;\ndiv { -foo-#{$a}-#{$b}-foo: foo }\n") + .unwrap(), + "div {\n -foo-a-b-foo: foo;\n}\n" + ); +} + +// Ignoring "117_test_selector_interpolation_in_reference_combinator", end_version is 3.5. + +/// From "sass-spec/spec/scss-tests/119_test_basic_prop_name_interpolation" +#[test] +fn t119_test_basic_prop_name_interpolation() { + assert_eq!( + rsass("foo {bar#{\"baz\" + \"bang\"}: blip}\n").unwrap(), + "foo {\n barbazbang: blip;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/120_test_basic_prop_name_interpolation" +#[test] +fn t120_test_basic_prop_name_interpolation() { + assert_eq!( + rsass("foo {bar#{1 + 2}: blip}\n").unwrap(), + "foo {\n bar3: blip;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/121_test_prop_name_only_interpolation" +#[test] +fn t121_test_prop_name_only_interpolation() { + assert_eq!( + rsass("foo {#{\"baz\" + \"bang\"}: blip}\n").unwrap(), + "foo {\n bazbang: blip;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/122_test_directive_interpolation" +#[test] +fn t122_test_directive_interpolation() { + assert_eq!( + rsass("$baz: 12;\n@foo bar#{$baz} qux {a: b}\n").unwrap(), + "@foo bar12 qux {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/128_test_supports_with_expressions" +#[test] +#[ignore] // failing +fn t128_test_supports_with_expressions() { + assert_eq!( + rsass( + "$query: \"(feature1: val)\";\n$feature: feature2;\n$val: val;\n@supports (#{$query} and ($feature: $val)) or (not ($feature + 3: $val + 4)) {\n foo {a: b}\n}\n" + ) + .unwrap(), + "@supports ((feature1: val) and (feature2: val)) or (not (feature23: val4)) {\n foo {\n a: b;\n }\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/129_test_supports_bubbling" +#[test] +#[ignore] // failing +fn t129_test_supports_bubbling() { + assert_eq!( + rsass( + "a {\n @supports (foo: bar) {\n b: c;\n @supports (baz: bang) {\n d: e;\n }\n }\n}\n" + ) + .unwrap(), + "@supports (foo: bar) {\n a {\n b: c;\n }\n @supports (baz: bang) {\n a {\n d: e;\n }\n }\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/130_test_random_directive_interpolation" +#[test] +#[ignore] // failing +fn t130_test_random_directive_interpolation() { + assert_eq!( + rsass( + "$domain: \"sass-lang.com\";\n@foo url(http://#{$domain}/),\n #{domain($domain)},\n \"foo#{\'ba\' + \'r\'}baz\",\n foo#{\'ba\' + \'r\'}baz {\n .foo {a: b}\n}\n" + ) + .unwrap(), + "@foo url(http://sass-lang.com/),\n domain(\"sass-lang.com\"),\n \"foobarbaz\",\n foobarbaz {\n .foo {\n a: b;\n }\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/131_test_nested_mixin_def" +#[test] +fn t131_test_nested_mixin_def() { + assert_eq!( + rsass("foo {\n @mixin bar {a: b}\n @include bar; }\n").unwrap(), + "foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/132_test_nested_mixin_shadow" +#[test] +fn t132_test_nested_mixin_shadow() { + assert_eq!( + rsass( + "@mixin bar {a: b}\n\nfoo {\n @mixin bar {c: d}\n @include bar;\n}\n\nbaz {@include bar}\n" + ) + .unwrap(), + "foo {\n c: d;\n}\nbaz {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/133_test_nested_function_def" +#[test] +fn t133_test_nested_function_def() { + assert_eq!( + rsass( + "foo {\n @function foo() {@return 1}\n a: foo(); }\n\nbar {b: foo()}\n" + ) + .unwrap(), + "foo {\n a: 1;\n}\nbar {\n b: foo();\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/134_test_nested_function_shadow" +#[test] +fn t134_test_nested_function_shadow() { + assert_eq!( + rsass( + "@function foo() {@return 1}\n\nfoo {\n @function foo() {@return 2}\n a: foo();\n}\n\nbaz {b: foo()}\n" + ) + .unwrap(), + "foo {\n a: 2;\n}\nbaz {\n b: 1;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/171_test_loud_comment_in_compressed_mode" +#[test] +fn t171_test_loud_comment_in_compressed_mode() { + assert_eq!(rsass("/*! foo */\n").unwrap(), "/*! foo */\n"); +} + +/// From "sass-spec/spec/scss-tests/172_test_parsing_decimals_followed_by_comments_doesnt_take_forever" +#[test] +#[ignore] // failing +fn t172_test_parsing_decimals_followed_by_comments_doesnt_take_forever() { + assert_eq!( + rsass( + ".foo {\n padding: 4.21052631578947% 4.21052631578947% 5.631578947368421% /**/\n}\n" + ) + .unwrap(), + ".foo {\n padding: 4.2105263158% 4.2105263158% 5.6315789474%;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/173_test_parsing_many_numbers_doesnt_take_forever" +#[test] +fn t173_test_parsing_many_numbers_doesnt_take_forever() { + assert_eq!( + rsass( + ".foo {\n padding: 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%;\n}\n" + ) + .unwrap(), + ".foo {\n padding: 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%, 80% 90%;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/174_test_import_comments_in_imports" +#[test] +#[ignore] // failing +fn t174_test_import_comments_in_imports() { + assert_eq!( + rsass( + "@import \"foo.css\", // this is a comment\n \"bar.css\", /* this is another comment */\n \"baz.css\"; // this is a third comment\n" + ) + .unwrap(), + "@import url(foo.css);\n@import url(bar.css);\n@import url(baz.css);\n" + ); +} + +/// From "sass-spec/spec/scss-tests/176_test_newline_selector_rendered_multiple_times" +#[test] +#[ignore] // failing +fn t176_test_newline_selector_rendered_multiple_times() { + assert_eq!( + rsass( + "@for $i from 1 through 2 {\n form {\n input,\n select {\n color: white;\n }\n }\n}\n" + ) + .unwrap(), + "form input,\nform select {\n color: white;\n}\nform input,\nform select {\n color: white;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/177_test_prop_name_interpolation_after_hyphen" +#[test] +fn t177_test_prop_name_interpolation_after_hyphen() { + assert_eq!( + rsass("a { -#{\"foo\"}-bar: b; }\n").unwrap(), + "a {\n -foo-bar: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/178_test_star_plus_and_parent" +#[test] +fn t178_test_star_plus_and_parent() { + assert_eq!( + rsass("foo {*+html & {a: b}}\n").unwrap(), + "* + html foo {\n a: b;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/179_test_weird_added_space" +#[test] +fn t179_test_weird_added_space() { + assert_eq!( + rsass("$value : bip;\n\nfoo {\n bar: -moz-#{$value};\n}\n").unwrap(), + "foo {\n bar: -moz-bip;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/180_test_interpolation_with_bracket_on_next_line" +#[test] +fn t180_test_interpolation_with_bracket_on_next_line() { + assert_eq!( + rsass("a.#{\"foo\"} b\n{color: red}\n").unwrap(), + "a.foo b {\n color: red;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/181_test_interpolation" +#[test] +fn t181_test_interpolation() { + assert_eq!( + rsass("$bar : \"#foo\";\nul li#{$bar} a span.label { foo: bar; }\n") + .unwrap(), + "ul li#foo a span.label {\n foo: bar;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/182_test_mixin_with_keyword_args" +#[test] +fn t182_test_mixin_with_keyword_args() { + assert_eq!( + rsass( + "@mixin a-mixin($required, $arg1: default-val1, $arg2: default-val2) {\n required: $required;\n arg1: $arg1;\n arg2: $arg2;\n}\n.mixed { @include a-mixin(foo, $arg2: non-default-val2); }\n" + ) + .unwrap(), + ".mixed {\n required: foo;\n arg1: default-val1;\n arg2: non-default-val2;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/183_test_passing_required_args_as_a_keyword_arg" +#[test] +fn t183_test_passing_required_args_as_a_keyword_arg() { + assert_eq!( + rsass( + "@mixin a-mixin($required, $arg1: default-val1, $arg2: default-val2) {\n required: $required;\n arg1: $arg1;\n arg2: $arg2; }\n.mixed { @include a-mixin($required: foo); }\n" + ) + .unwrap(), + ".mixed {\n required: foo;\n arg1: default-val1;\n arg2: default-val2;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/184_test_passing_all_as_keyword_args_in_opposite_order" +#[test] +fn t184_test_passing_all_as_keyword_args_in_opposite_order() { + assert_eq!( + rsass( + "@mixin a-mixin($required, $arg1: default-val1, $arg2: default-val2) {\n required: $required;\n arg1: $arg1;\n arg2: $arg2; }\n.mixed { @include a-mixin($arg2: non-default-val2, $arg1: non-default-val1, $required: foo); }\n" + ) + .unwrap(), + ".mixed {\n required: foo;\n arg1: non-default-val1;\n arg2: non-default-val2;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/185_test_keyword_args_in_functions" +#[test] +fn t185_test_keyword_args_in_functions() { + assert_eq!( + rsass(".keyed { color: rgba($color: #a7c, $alpha: 0.4) }\n").unwrap(), + ".keyed {\n color: rgba(170, 119, 204, 0.4);\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/186_test_newlines_removed_from_selectors_when_compressed" +#[test] +#[ignore] // failing +fn t186_test_newlines_removed_from_selectors_when_compressed() { + assert_eq!( + rsass("a\n, b {\n z & {\n display: block;\n }\n}\n").unwrap(), + "z a\n, z b {\n display: block;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/187_test_multiline_var" +#[test] +fn t187_test_multiline_var() { + assert_eq!( + rsass( + "foo {\n $var1: 1 +\n 2;\n $var2: true and\n false;\n $var3: a b\n c;\n a: $var1;\n b: $var2;\n c: $var3; }\n" + ) + .unwrap(), + "foo {\n a: 3;\n b: false;\n c: a b c;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/188_test_mixin_content" +#[test] +#[ignore] // failing +fn t188_test_mixin_content() { + assert_eq!( + rsass( + "$color: blue;\n@mixin context($class, $color: red) {\n .#{$class} {\n background-color: $color;\n @content;\n border-color: $color;\n }\n}\n@include context(parent) {\n @include context(child, $color: yellow) {\n color: $color;\n }\n}\n" + ) + .unwrap(), + ".parent {\n background-color: red;\n border-color: red;\n}\n.parent .child {\n background-color: yellow;\n color: blue;\n border-color: yellow;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/189_test_empty_content" +#[test] +fn t189_test_empty_content() { + assert_eq!( + rsass("@mixin foo { @content }\na { b: c; @include foo {} }\n") + .unwrap(), + "a {\n b: c;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/190_test_options_passed_to_script" +#[test] +fn t190_test_options_passed_to_script() { + assert_eq!( + rsass("foo {color: darken(black, 10%)}\n").unwrap(), + "foo {\n color: black;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/191_test_color_translation_functions" +#[test] +fn t191_test_color_translation_functions() { + assert_eq!( + rsass( + "$color: #c09853;\n\n.bar {\n\tcolor1: rgba($color,0.5);\n\tcolor2: rgba($color,1);\n}\n\n.darken {\n\tcolor1: darken($color, 10%); \n\tcolor2: darken($color, 20%); \n\tcolor3: darken($color, 30%); \n\tcolor4: darken($color, 40%); \n\tcolor5: darken($color, 50%); \n\tcolor6: darken($color, 60%); \n\tcolor7: darken($color, 70%); \n\tcolor8: darken($color, 80%); \n\tcolor9: darken($color, 90%); \n\tcolor10: darken($color, 100%); \n}\n\n.lighten {\n\tcolor1: lighten($color, 10%); \n\tcolor2: lighten($color, 20%); \n\tcolor3: lighten($color, 30%); \n\tcolor4: lighten($color, 40%); \n\tcolor5: lighten($color, 50%); \n\tcolor6: lighten($color, 60%); \n\tcolor7: lighten($color, 70%); \n\tcolor8: lighten($color, 80%); \n\tcolor9: lighten($color, 90%); \n\tcolor10: lighten($color, 100%); \n}\n" + ) + .unwrap(), + ".bar {\n color1: rgba(192, 152, 83, 0.5);\n color2: #c09853;\n}\n.darken {\n color1: #a47e3c;\n color2: #7f612e;\n color3: #594521;\n color4: #342813;\n color5: #0f0b05;\n color6: black;\n color7: black;\n color8: black;\n color9: black;\n color10: black;\n}\n.lighten {\n color1: #ceae78;\n color2: #dbc59e;\n color3: #e9dbc3;\n color4: #f7f1e8;\n color5: white;\n color6: white;\n color7: white;\n color8: white;\n color9: white;\n color10: white;\n}\n" + ); +} + +/// From "sass-spec/spec/scss-tests/191_test_extend_in_media_in_rule" +#[test] +#[ignore] // failing +fn t191_test_extend_in_media_in_rule() { + assert_eq!( + rsass( + ".foo {\n @media screen {\n @extend %bar;\n }\n}\n\n@media screen {\n %bar {\n a: b;\n }\n}\n" + ) + .unwrap(), + "@media screen {\n .foo {\n a: b;\n }\n}\n" + ); +} + +fn rsass(input: &str) -> Result { + compile_scss(input.as_bytes(), OutputStyle::Expanded) + .map_err(|e| format!("rsass failed: {}", e)) + .and_then(|s| { + String::from_utf8(s) + .map(|s| s.replace("\n\n", "\n")) + .map_err(|e| format!("{:?}", e)) + }) +} diff --git a/tests/unicode.rs b/tests/unicode.rs index 7b1dad7f6..33cf72bec 100644 --- a/tests/unicode.rs +++ b/tests/unicode.rs @@ -1,5 +1,3 @@ -//! These are from the `output_styles/compressed/basic` directory in the -//! sass specification. use rsass::{compile_scss, OutputStyle}; #[test] @@ -18,7 +16,7 @@ fn unicode_in_expanded() { #[test] fn unicode_in_compressed() { // Blåbärsöl is a proper swedish word. Translates to blueberry beer. - // The charset declaration is replace with a byte order mark. + // The charset declaration is replaced with a byte order mark. check( "a {\n \ content: \"Blåbärsöl\";\n\ diff --git a/tests/value/main.rs b/tests/value/main.rs deleted file mode 100644 index 90be8251f..000000000 --- a/tests/value/main.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod unquote; - -use rsass::compile_value; - -pub fn check_eval(expression: &str, expected: &str) { - assert_eq!( - compile_value(expression.as_bytes()) - .and_then(|s| Ok(String::from_utf8(s)?)) - .unwrap(), - expected - ) -} diff --git a/tests/value/unquote.rs b/tests/value/unquote.rs deleted file mode 100644 index 47f3a297f..000000000 --- a/tests/value/unquote.rs +++ /dev/null @@ -1,26 +0,0 @@ -/// From `sass-spec/spec/libsass/unquote` -use super::check_eval; - -#[test] -fn a() { - check_eval("unquote(\"foo\")", "foo") -} -#[test] -fn b() { - check_eval( - "unquote(\"I'm a \\\"fashion\\\" \\\"expert\\\".\")", - "I'm a \"fashion\" \"expert\".", - ) -} -#[test] -fn c() { - check_eval("unquote(\\\"wha)", "\\\"wha") -} -#[test] -fn d() { - check_eval("unquote(\"column1\\tcolumn2\")", "column1tcolumn2") -} -#[test] -fn e() { - check_eval("unquote(23+1)", "24") -}