Skip to content

Commit

Permalink
More autoconverted tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Feb 10, 2019
1 parent fad8624 commit 959249e
Show file tree
Hide file tree
Showing 60 changed files with 2,805 additions and 295 deletions.
4 changes: 4 additions & 0 deletions src/spectest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -52,6 +54,7 @@ fn main() -> Result<(), Error> {
"is_superselector", // multiple input files
],
)?;
handle_suite(&base, "scope", &[])?;
handle_suite(
&base,
"scss",
Expand All @@ -61,6 +64,7 @@ fn main() -> Result<(), Error> {
"huge", // stack overflow
],
)?;
handle_suite(&base, "scss-tests", &[])?;
handle_suite(&base, "values", &[])?;
Ok(())
}
Expand Down
5 changes: 5 additions & 0 deletions tests/core_functions/color/hsl/basic/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions tests/core_functions/color/hsl/error/four_args/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions tests/core_functions/color/hsl/error/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
25 changes: 25 additions & 0 deletions tests/core_functions/color/hsl/error/one_arg/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions tests/core_functions/color/hsl/error/three_args/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions tests/core_functions/color/hsl/error/two_args/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
57 changes: 57 additions & 0 deletions tests/core_functions/color/hsl/four_args/mod.rs
Original file line number Diff line number Diff line change
@@ -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"
);
}
29 changes: 29 additions & 0 deletions tests/core_functions/color/hsl/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 44 additions & 0 deletions tests/core_functions/color/hsl/one_arg/mod.rs
Original file line number Diff line number Diff line change
@@ -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"
);
}
Loading

0 comments on commit 959249e

Please sign in to comment.