2020-06-22 10:11:30 -04:00
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
test!(
|
|
|
|
min_not_evaluated_units_percent,
|
|
|
|
"a {\n color: min(1%, 2%);\n}\n",
|
|
|
|
"a {\n color: min(1%, 2%);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_not_evaluated_units_px,
|
|
|
|
"a {\n color: min(1px, 2px);\n}\n",
|
|
|
|
"a {\n color: min(1px, 2px);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_not_evaluated_no_units,
|
|
|
|
"a {\n color: min(1, 2);\n}\n",
|
|
|
|
"a {\n color: min(1, 2);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_not_evaluated_incompatible_units,
|
|
|
|
"a {\n color: min(1%, 2vh);\n}\n",
|
|
|
|
"a {\n color: min(1%, 2vh);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_not_evaluated_interpolation,
|
|
|
|
"$a: 1%;\n$b: 2%;\na {\n color: min(#{$a}, #{$b});;\n}\n",
|
|
|
|
"a {\n color: min(1%, 2%);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_evaluated_variable_units_percent,
|
|
|
|
"$a: 1%;\n$b: 2%;\na {\n color: min($a, $b);\n}\n",
|
|
|
|
"a {\n color: 1%;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_evaluated_variable_units_px,
|
|
|
|
"$a: 1px;\n$b: 2px;\na {\n color: min($a, $b);\n}\n",
|
|
|
|
"a {\n color: 1px;\n}\n"
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
min_arg_of_incorrect_type,
|
|
|
|
"$a: 1px;\n$b: 2px;\na {\n color: min($a, $b, foo);\n}\n", "Error: foo is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
min_too_few_args,
|
|
|
|
"a {\n color: min();\n}\n", "Error: At least one argument must be passed."
|
|
|
|
);
|
|
|
|
// note: we explicitly have units in the opposite order of `dart-sass`.
|
|
|
|
// see https://github.com/sass/dart-sass/issues/766
|
|
|
|
error!(
|
|
|
|
min_incompatible_units,
|
|
|
|
"$a: 1px;\n$b: 2%;\na {\n color: min($a, $b);\n}\n", "Error: Incompatible units px and %."
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_not_evaluated_units_percent,
|
|
|
|
"a {\n color: max(1%, 2%);\n}\n",
|
|
|
|
"a {\n color: max(1%, 2%);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_not_evaluated_units_px,
|
|
|
|
"a {\n color: max(1px, 2px);\n}\n",
|
|
|
|
"a {\n color: max(1px, 2px);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_not_evaluated_no_units,
|
|
|
|
"a {\n color: max(1, 2);\n}\n",
|
|
|
|
"a {\n color: max(1, 2);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_not_evaluated_incompatible_units,
|
|
|
|
"a {\n color: max(1%, 2vh);\n}\n",
|
|
|
|
"a {\n color: max(1%, 2vh);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_not_evaluated_interpolation,
|
|
|
|
"$a: 1%;\n$b: 2%;\na {\n color: max(#{$a}, #{$b});;\n}\n",
|
|
|
|
"a {\n color: max(1%, 2%);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_evaluated_variable_units_percent,
|
|
|
|
"$a: 1%;\n$b: 2%;\na {\n color: max($a, $b);\n}\n",
|
|
|
|
"a {\n color: 2%;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_evaluated_variable_units_px,
|
|
|
|
"$a: 1px;\n$b: 2px;\na {\n color: max($a, $b);\n}\n",
|
|
|
|
"a {\n color: 2px;\n}\n"
|
|
|
|
);
|
2020-06-22 10:21:18 -04:00
|
|
|
test!(
|
|
|
|
max_evaluated_binop,
|
|
|
|
"a {\n color: max(100% - lightness(red) - 2%);\n}\n",
|
2020-07-03 20:15:00 -04:00
|
|
|
"a {\n color: 48%;\n}\n"
|
2020-06-22 10:21:18 -04:00
|
|
|
);
|
2020-06-22 10:11:30 -04:00
|
|
|
error!(
|
|
|
|
max_arg_of_incorrect_type,
|
|
|
|
"$a: 1px;\n$b: 2px;\na {\n color: max($a, $b, foo);\n}\n", "Error: foo is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
max_too_few_args,
|
|
|
|
"a {\n color: max();\n}\n", "Error: At least one argument must be passed."
|
|
|
|
);
|
|
|
|
// note: we explicitly have units in the opposite order of `dart-sass`.
|
|
|
|
// see https://github.com/sass/dart-sass/issues/766
|
|
|
|
error!(
|
|
|
|
max_incompatible_units,
|
|
|
|
"$a: 1px;\n$b: 2%;\na {\n color: max($a, $b);\n}\n", "Error: Incompatible units px and %."
|
|
|
|
);
|
2020-06-22 10:22:13 -04:00
|
|
|
// todo: special functions, min(calc(1), $b);
|
2021-07-11 02:13:05 -04:00
|
|
|
test!(
|
|
|
|
min_containing_max,
|
|
|
|
"a {\n color: min(1, max(2));\n}\n",
|
|
|
|
"a {\n color: min(1, max(2));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_containing_min,
|
|
|
|
"a {\n color: max(1, min(2));\n}\n",
|
|
|
|
"a {\n color: max(1, min(2));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_containing_max_as_only_arg,
|
|
|
|
"a {\n color: min(max(1px, 2px));\n}\n",
|
|
|
|
"a {\n color: min(max(1px, 2px));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
max_containing_min_as_only_arg,
|
|
|
|
"a {\n color: max(min(1px, 2px));\n}\n",
|
|
|
|
"a {\n color: max(min(1px, 2px));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
extremely_nested_min_and_max,
|
|
|
|
"a {\n color: min(max(min(max(min(min(1), max(2))))), min(max(min(3))));\n}\n",
|
|
|
|
"a {\n color: min(max(min(max(min(min(1), max(2))))), min(max(min(3))));\n}\n"
|
|
|
|
);
|
2021-07-12 01:59:30 -04:00
|
|
|
test!(
|
|
|
|
decimal_without_leading_integer_is_evaluated,
|
|
|
|
"a {\n color: min(.2, .4);\n}\n",
|
|
|
|
"a {\n color: 0.2;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
decimal_with_leading_integer_is_not_evaluated,
|
|
|
|
"a {\n color: min(0.2, 0.4);\n}\n",
|
|
|
|
"a {\n color: min(0.2, 0.4);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_env,
|
|
|
|
"a {\n color: min(env(\"foo\"));\n}\n",
|
|
|
|
"a {\n color: min(env(\"foo\"));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_calc_with_div_and_spaces,
|
|
|
|
"a {\n color: min(calc(1 / 2));\n}\n",
|
|
|
|
"a {\n color: min(calc(1 / 2));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_calc_with_div_without_spaces,
|
|
|
|
"a {\n color: min(calc(1/2));\n}\n",
|
|
|
|
"a {\n color: min(calc(1/2));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_calc_with_plus_only,
|
|
|
|
"a {\n color: min(calc(+));\n}\n",
|
|
|
|
"a {\n color: min(calc(+));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_calc_space_separated_list,
|
|
|
|
"a {\n color: min(calc(1 2));\n}\n",
|
|
|
|
"a {\n color: min(calc(1 2));\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
min_conains_special_fn_var,
|
|
|
|
"a {\n color: min(1, var(--foo));\n}\n",
|
|
|
|
"a {\n color: min(1, var(--foo));\n}\n"
|
|
|
|
);
|