2020-02-22 13:03:02 -05:00
|
|
|
#![cfg(test)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
test!(
|
|
|
|
basic_toplevel,
|
|
|
|
"@media foo {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-05-20 20:13:53 -04:00
|
|
|
error!(
|
|
|
|
no_params,
|
|
|
|
"@media {\n a {\n color: red;\n }\n}\n", "Error: Expected identifier."
|
2020-02-22 17:09:15 -05:00
|
|
|
);
|
2020-02-22 15:34:32 -05:00
|
|
|
test!(
|
|
|
|
basic_nested,
|
|
|
|
"a {\n @media foo {\n color: red;\n }\n}\n",
|
|
|
|
"@media foo {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-05-20 20:13:53 -04:00
|
|
|
test!(empty_body, "@media (min-width: 2px) {}", "");
|
2020-07-04 22:46:28 -04:00
|
|
|
test!(
|
|
|
|
newlines_are_not_emitted_for_child_styles,
|
|
|
|
"a {
|
|
|
|
@media screen {
|
|
|
|
b {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
c {
|
|
|
|
color: green;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media screen {\n a b {\n color: red;\n }\n a c {\n color: green;\n }\n}\n"
|
|
|
|
);
|
2020-07-06 15:37:03 -04:00
|
|
|
test!(
|
|
|
|
multiple_identifiers_in_query,
|
|
|
|
"@media not screen {
|
|
|
|
a {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media not screen {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-07-06 18:59:21 -04:00
|
|
|
test!(
|
|
|
|
multiple_identifiers_in_query_second_is_and,
|
|
|
|
"@media print and (foo: 1 2 3) {
|
|
|
|
a {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media print and (foo: 1 2 3) {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-07-07 11:23:09 -04:00
|
|
|
test!(
|
|
|
|
single_identifier_inside_parens,
|
|
|
|
"@media (color) {a {color: red;}}",
|
|
|
|
"@media (color) {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-07-09 13:43:27 -04:00
|
|
|
test!(
|
|
|
|
quoted_colon_in_parens,
|
|
|
|
"@media screen and (\":\") {
|
|
|
|
a {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media screen and (:) {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-08-07 11:39:14 -04:00
|
|
|
test!(
|
|
|
|
multiline_comments_everywhere,
|
|
|
|
"@media/**/foo/**/and/**/(/**/bar/**/)/**/{
|
|
|
|
a {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media foo and (bar) {\n a {\n color: red;\n }\n}\n"
|
|
|
|
);
|
2020-08-07 12:04:37 -04:00
|
|
|
test!(
|
|
|
|
comparison_in_query,
|
|
|
|
"@media (100px < 400px) {
|
|
|
|
a {
|
|
|
|
interpolation: in-parens
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media (100px < 400px) {\n a {\n interpolation: in-parens;\n }\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
interpolated_comparison_in_query,
|
|
|
|
"@media (#{100px < 400px}) {
|
|
|
|
a {
|
|
|
|
interpolation: in-parens
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"@media (true) {\n a {\n interpolation: in-parens;\n }\n}\n"
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
media_feature_missing_closing_paren,
|
|
|
|
"@media foo and (bar:a", "Error: expected \")\"."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
media_feature_missing_curly_brace_after_hash,
|
|
|
|
"@media foo and # {}", "Error: expected \"{\"."
|
|
|
|
);
|