2020-02-09 16:05:07 -05:00
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
test!(
|
|
|
|
percentage_decimal,
|
|
|
|
"a {\n color: percentage(0.2);\n}\n",
|
|
|
|
"a {\n color: 20%;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
percentage_division,
|
|
|
|
"a {\n color: percentage(100px / 50px);\n}\n",
|
|
|
|
"a {\n color: 200%;\n}\n"
|
|
|
|
);
|
2022-12-26 15:33:04 -05:00
|
|
|
test!(
|
|
|
|
percentage_nan,
|
|
|
|
"a {\n color: percentage((0/0));\n}\n",
|
|
|
|
"a {\n color: NaN%;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
percentage_infinity,
|
|
|
|
"a {\n color: percentage((1/0));\n}\n",
|
|
|
|
"a {\n color: Infinity%;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
percentage_neg_infinity,
|
|
|
|
"a {\n color: percentage((-1/0));\n}\n",
|
|
|
|
"a {\n color: -Infinity%;\n}\n"
|
|
|
|
);
|
2020-02-09 16:05:07 -05:00
|
|
|
test!(
|
|
|
|
integer_division,
|
|
|
|
"a {\n color: percentage(2);\n}\n",
|
|
|
|
"a {\n color: 200%;\n}\n"
|
|
|
|
);
|
2020-02-09 16:10:32 -05:00
|
|
|
test!(
|
|
|
|
rounds_down,
|
|
|
|
"a {\n color: round(10.4px);\n}\n",
|
|
|
|
"a {\n color: 10px;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
rounds_up,
|
|
|
|
"a {\n color: round(10.6px);\n}\n",
|
|
|
|
"a {\n color: 11px;\n}\n"
|
|
|
|
);
|
2020-02-09 16:14:24 -05:00
|
|
|
test!(
|
|
|
|
floor_below_pt_5,
|
|
|
|
"a {\n color: floor(10.4px);\n}\n",
|
|
|
|
"a {\n color: 10px;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
floor_above_pt_5,
|
|
|
|
"a {\n color: floor(10.6px);\n}\n",
|
|
|
|
"a {\n color: 10px;\n}\n"
|
|
|
|
);
|
2020-05-25 14:44:46 -04:00
|
|
|
test!(
|
|
|
|
floor_big_int,
|
|
|
|
"a {\n color: floor(1.000000000000000001);\n}\n",
|
|
|
|
"a {\n color: 1;\n}\n"
|
|
|
|
);
|
2020-02-09 16:14:24 -05:00
|
|
|
test!(
|
|
|
|
ceil_below_pt_5,
|
|
|
|
"a {\n color: ceil(10.4px);\n}\n",
|
|
|
|
"a {\n color: 11px;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
ceil_above_pt_5,
|
|
|
|
"a {\n color: ceil(10.6px);\n}\n",
|
|
|
|
"a {\n color: 11px;\n}\n"
|
|
|
|
);
|
2020-05-25 14:44:46 -04:00
|
|
|
test!(
|
|
|
|
ceil_big_int,
|
|
|
|
"a {\n color: ceil(1.000000000000000001);\n}\n",
|
2022-12-26 15:33:04 -05:00
|
|
|
"a {\n color: 1;\n}\n"
|
2020-05-25 14:44:46 -04:00
|
|
|
);
|
2020-02-14 12:30:48 -05:00
|
|
|
test!(
|
|
|
|
abs_positive,
|
|
|
|
"a {\n color: abs(10);\n}\n",
|
|
|
|
"a {\n color: 10;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
abs_negative,
|
|
|
|
"a {\n color: abs(-10);\n}\n",
|
|
|
|
"a {\n color: 10;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
abs_unit,
|
|
|
|
"a {\n color: abs(-10px);\n}\n",
|
|
|
|
"a {\n color: 10px;\n}\n"
|
|
|
|
);
|
2020-02-15 08:16:17 -05:00
|
|
|
test!(
|
|
|
|
comparable_unitless,
|
|
|
|
"a {\n color: comparable(1, 2);\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
comparable_none_px,
|
|
|
|
"a {\n color: comparable(1, 2px);\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
comparable_px_px,
|
|
|
|
"a {\n color: comparable(1px, 2px);\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
comparable_absolute,
|
|
|
|
"a {\n color: comparable(1px, 2in);\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
comparable_absolute_font_relative,
|
|
|
|
"a {\n color: comparable(1px, 2em);\n}\n",
|
|
|
|
"a {\n color: false;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
comparable_named,
|
|
|
|
"a {\n color: comparable($number1: 1, $number2: 2);\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
2020-05-25 14:44:46 -04:00
|
|
|
test!(
|
|
|
|
random_limit_one,
|
|
|
|
"a {\n color: random(1);\n}\n",
|
|
|
|
"a {\n color: 1;\n}\n"
|
|
|
|
);
|
2022-12-26 15:33:04 -05:00
|
|
|
error!(
|
2020-05-25 14:44:46 -04:00
|
|
|
random_limit_big_one,
|
|
|
|
"a {\n color: random(1000000000000000001 - 1000000000000000000);\n}\n",
|
2022-12-26 15:33:04 -05:00
|
|
|
"Error: $limit: Must be greater than 0, was 0."
|
2020-05-25 14:44:46 -04:00
|
|
|
);
|
2023-01-03 04:09:42 +00:00
|
|
|
error!(
|
|
|
|
percentage_non_number_arg,
|
|
|
|
"a {\n color: percentage(a);\n}\n", "Error: $number: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
round_non_number_arg,
|
|
|
|
"a {\n color: round(a);\n}\n", "Error: $number: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
ceil_non_number_arg,
|
|
|
|
"a {\n color: ceil(a);\n}\n", "Error: $number: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
floor_non_number_arg,
|
|
|
|
"a {\n color: floor(a);\n}\n", "Error: $number: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
abs_non_number_arg,
|
|
|
|
"a {\n color: abs(a);\n}\n", "Error: $number: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
comparable_non_number_arg_both,
|
|
|
|
"a {\n color: comparable(a, b);\n}\n", "Error: $number1: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
comparable_non_number_arg_first,
|
|
|
|
"a {\n color: comparable(a, 1);\n}\n", "Error: $number1: a is not a number."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
comparable_non_number_arg_last,
|
|
|
|
"a {\n color: comparable(1, b);\n}\n", "Error: $number2: b is not a number."
|
|
|
|
);
|