2020-02-08 20:32:10 -05:00
|
|
|
#![cfg(test)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
test!(
|
|
|
|
uppercase_ident,
|
|
|
|
"a {\n color: to-upper-case(aBc123);\n}\n",
|
|
|
|
"a {\n color: ABC123;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
lowercase_ident,
|
|
|
|
"a {\n color: to-lower-case(AbC123);\n}\n",
|
|
|
|
"a {\n color: abc123;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
uppercase_named_arg,
|
|
|
|
"a {\n color: to-upper-case($string: aBc123);\n}\n",
|
|
|
|
"a {\n color: ABC123;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
lowercase_named_arg,
|
|
|
|
"a {\n color: to-lower-case($string: AbC123);\n}\n",
|
|
|
|
"a {\n color: abc123;\n}\n"
|
|
|
|
);
|
2020-02-08 20:38:37 -05:00
|
|
|
test!(
|
|
|
|
length_ident,
|
|
|
|
"a {\n color: str-length(AbC123);\n}\n",
|
|
|
|
"a {\n color: 6;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
length_named_arg,
|
|
|
|
"a {\n color: str-length($string: aBc123);\n}\n",
|
|
|
|
"a {\n color: 6;\n}\n"
|
2020-02-09 03:13:31 -05:00
|
|
|
);
|
2020-02-14 14:23:54 -05:00
|
|
|
test!(
|
|
|
|
str_slice_dbl_quote,
|
|
|
|
"a {\n color: str-slice(\"abcd\", 2, 3);\n}\n",
|
|
|
|
"a {\n color: \"bc\";\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_sgl_quote,
|
|
|
|
"a {\n color: str-slice('abcd', 2, 3);\n}\n",
|
|
|
|
"a {\n color: \"bc\";\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_no_quote,
|
|
|
|
"a {\n color: str-slice(abcd, 2, 3);\n}\n",
|
|
|
|
"a {\n color: bc;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_no_end,
|
|
|
|
"a {\n color: str-slice(abcd, 2);\n}\n",
|
|
|
|
"a {\n color: bcd;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_negative_start_negative_end,
|
|
|
|
"a {\n color: str-slice(abcd, -3, -2);\n}\n",
|
|
|
|
"a {\n color: bc;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_negative_end,
|
|
|
|
"a {\n color: str-slice(abcd, 2, -2);\n}\n",
|
|
|
|
"a {\n color: bc;\n}\n"
|
|
|
|
);
|
2020-02-15 08:32:46 -05:00
|
|
|
test!(
|
|
|
|
str_slice_start_0,
|
|
|
|
"a {\n color: str-slice(cde, 0);\n}\n",
|
|
|
|
"a {\n color: cde;\n}\n"
|
|
|
|
);
|
2020-02-15 08:51:00 -05:00
|
|
|
test!(
|
|
|
|
str_slice_start_below_negative_str_len,
|
|
|
|
"a {\n color: str-slice(cde, -100);\n}\n",
|
|
|
|
"a {\n color: cde;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_slice_end_below_negative_str_len,
|
|
|
|
"a {\n color: str-slice(\"cde\", 0, -100);\n}\n",
|
|
|
|
"a {\n color: \"\";\n}\n"
|
|
|
|
);
|
2020-02-15 08:54:10 -05:00
|
|
|
test!(
|
|
|
|
str_slice_end_0,
|
|
|
|
"a {\n color: str-slice(\"cde\", 1, 0);\n}\n",
|
|
|
|
"a {\n color: \"\";\n}\n"
|
|
|
|
);
|
2020-02-15 09:45:43 -05:00
|
|
|
test!(
|
|
|
|
str_len_dbl_quotes,
|
|
|
|
"a {\n color: str-length(\"cde\");\n}\n",
|
|
|
|
"a {\n color: 3;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_len_unquoted,
|
|
|
|
"a {\n color: str-length(cde);\n}\n",
|
|
|
|
"a {\n color: 3;\n}\n"
|
|
|
|
);
|
2020-02-16 18:45:14 -05:00
|
|
|
test!(
|
|
|
|
unquote_empty_string_is_null,
|
|
|
|
"a {\n color: unquote('');\n}\n",
|
|
|
|
""
|
|
|
|
);
|
2020-02-16 21:34:52 -05:00
|
|
|
test!(
|
|
|
|
str_len_space,
|
|
|
|
"a {\n color: str-length(\"foo bar\");\n}\n",
|
|
|
|
"a {\n color: 7;\n}\n"
|
|
|
|
);
|
2020-03-22 15:58:32 -04:00
|
|
|
test!(
|
|
|
|
str_index_char,
|
|
|
|
"a {\n color: str-index(abcd, a);\n}\n",
|
|
|
|
"a {\n color: 1;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
str_index_str,
|
|
|
|
"a {\n color: str-index(abcd, ab);\n}\n",
|
|
|
|
"a {\n color: 1;\n}\n"
|
|
|
|
);
|
|
|
|
test!(str_index_null, "a {\n color: str-index(abcd, X);\n}\n", "");
|