remove test macro shorthand for unchanged output

This commit is contained in:
Connor Skees 2020-11-20 04:34:36 -05:00
parent d7e7053d03
commit 884b92f476
18 changed files with 565 additions and 112 deletions

View File

@ -1,34 +1,81 @@
#[macro_use]
mod macros;
test!(preserves_named_color_case, "a {\n color: OrAnGe;\n}\n");
test!(
preserves_named_color_case,
"a {\n color: OrAnGe;\n}\n",
"a {\n color: OrAnGe;\n}\n"
);
test!(
named_color_casing_is_color,
"a {\n color: hue(RED);\n}\n",
"a {\n color: 0deg;\n}\n"
);
test!(preserves_hex_color_case, "a {\n color: #FfFfFf;\n}\n");
test!(
preserves_hex_color_case,
"a {\n color: #FfFfFf;\n}\n",
"a {\n color: #FfFfFf;\n}\n"
);
test!(
preserves_hex_8_val_10000000,
"a {\n color: #10000000;\n}\n",
"a {\n color: #10000000;\n}\n"
);
test!(
preserves_hex_8_val_12312312,
"a {\n color: #12312312;\n}\n",
"a {\n color: #12312312;\n}\n"
);
test!(
preserves_hex_8_val_ab234cff,
"a {\n color: #ab234cff;\n}\n",
"a {\n color: #ab234cff;\n}\n"
);
test!(preserves_hex_6_val_000000, "a {\n color: #000000;\n}\n");
test!(preserves_hex_6_val_123123, "a {\n color: #123123;\n}\n");
test!(preserves_hex_6_val_ab234c, "a {\n color: #ab234c;\n}\n");
test!(preserves_hex_4_val_0000, "a {\n color: #0000;\n}\n");
test!(preserves_hex_4_val_123a, "a {\n color: #123a;\n}\n");
test!(preserves_hex_4_val_ab2f, "a {\n color: #ab2f;\n}\n");
test!(preserves_hex_3_val_000, "a {\n color: #000;\n}\n");
test!(preserves_hex_3_val_123, "a {\n color: #123;\n}\n");
test!(preserves_hex_3_val_ab2, "a {\n color: #ab2;\n}\n");
test!(
preserves_hex_6_val_000000,
"a {\n color: #000000;\n}\n",
"a {\n color: #000000;\n}\n"
);
test!(
preserves_hex_6_val_123123,
"a {\n color: #123123;\n}\n",
"a {\n color: #123123;\n}\n"
);
test!(
preserves_hex_6_val_ab234c,
"a {\n color: #ab234c;\n}\n",
"a {\n color: #ab234c;\n}\n"
);
test!(
preserves_hex_4_val_0000,
"a {\n color: #0000;\n}\n",
"a {\n color: #0000;\n}\n"
);
test!(
preserves_hex_4_val_123a,
"a {\n color: #123a;\n}\n",
"a {\n color: #123a;\n}\n"
);
test!(
preserves_hex_4_val_ab2f,
"a {\n color: #ab2f;\n}\n",
"a {\n color: #ab2f;\n}\n"
);
test!(
preserves_hex_3_val_000,
"a {\n color: #000;\n}\n",
"a {\n color: #000;\n}\n"
);
test!(
preserves_hex_3_val_123,
"a {\n color: #123;\n}\n",
"a {\n color: #123;\n}\n"
);
test!(
preserves_hex_3_val_ab2,
"a {\n color: #ab2;\n}\n",
"a {\n color: #ab2;\n}\n"
);
test!(
converts_rgb_to_named_color,
"a {\n color: rgb(0, 0, 0);\n}\n",
@ -84,9 +131,14 @@ test!(
"a {\n color: alpha(red);\n}\n",
"a {\n color: 1;\n}\n"
);
test!(opacity_function_number, "a {\n color: opacity(1);\n}\n");
test!(
opacity_function_number,
"a {\n color: opacity(1);\n}\n",
"a {\n color: opacity(1);\n}\n"
);
test!(
opacity_function_number_unit,
"a {\n color: opacity(1px);\n}\n",
"a {\n color: opacity(1px);\n}\n"
);
test!(

View File

@ -13,22 +13,27 @@ test!(
);
test!(
preserves_outer_comments_before,
"a {\n /* hi */\n color: red;\n}\n",
"a {\n /* hi */\n color: red;\n}\n"
);
test!(
preserves_outer_comments_after,
"a {\n color: red;\n /* hi */\n}\n",
"a {\n color: red;\n /* hi */\n}\n"
);
test!(
preserves_outer_comments_two,
"a {\n /* foo */\n /* bar */\n color: red;\n}\n",
"a {\n /* foo */\n /* bar */\n color: red;\n}\n"
);
test!(
preserves_toplevel_comment_before,
"/* foo */\na {\n color: red;\n}\n",
"/* foo */\na {\n color: red;\n}\n"
);
test!(
preserves_toplevel_comment_after,
"a {\n color: red;\n}\n/* foo */\n",
"a {\n color: red;\n}\n/* foo */\n"
);
test!(

View File

@ -111,7 +111,11 @@ test!(
"@if false {}\n\n@Else {\n a {\n color: red;\n }\n}\n",
"@Else {\n a {\n color: red;\n }\n}\n"
);
test!(uppercase_if, "@If true {\n a {\n color: red;\n }\n}\n");
test!(
uppercase_if,
"@If true {\n a {\n color: red;\n }\n}\n",
"@If true {\n a {\n color: red;\n }\n}\n"
);
error!(nothing_after_if, "@if", "Error: Expected expression.");
error!(
nothing_after_dollar,

View File

@ -257,10 +257,26 @@ test!(
"a {\n color: join([a], (b, ));\n}\n",
"a {\n color: [a, b];\n}\n"
);
test!(bracketed_ident, "a {\n color: [a];\n}\n");
test!(bracketed_space_list, "a {\n color: [a b];\n}\n");
test!(bracketed_comma_list, "a {\n color: [a, b];\n}\n");
test!(bracketed_as_space_list, "a {\n color: [a b] c;\n}\n");
test!(
bracketed_ident,
"a {\n color: [a];\n}\n",
"a {\n color: [a];\n}\n"
);
test!(
bracketed_space_list,
"a {\n color: [a b];\n}\n",
"a {\n color: [a b];\n}\n"
);
test!(
bracketed_comma_list,
"a {\n color: [a, b];\n}\n",
"a {\n color: [a, b];\n}\n"
);
test!(
bracketed_as_space_list,
"a {\n color: [a b] c;\n}\n",
"a {\n color: [a b] c;\n}\n"
);
test!(
trailing_comma_bare,
"a {\n color: 1,;\n}\n",
@ -293,14 +309,17 @@ test!(
);
test!(
long_space_separated_list,
"a {\n color: a b c d e f g h i j k l m n o p q r s t u v w x y z;\n}\n",
"a {\n color: a b c d e f g h i j k l m n o p q r s t u v w x y z;\n}\n"
);
test!(
long_comma_separated_list,
"a {\n color: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;\n}\n",
"a {\n color: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;\n}\n"
);
test!(
deeply_nested_square_braces,
"a {\n color: [[[[[[a]]]]]];\n}\n",
"a {\n color: [[[[[[a]]]]]];\n}\n"
);
test!(
@ -338,7 +357,11 @@ test!(
"a {\n color: length(zip((a, b, c)));\n}\n",
"a {\n color: 3;\n}\n"
);
test!(empty_bracketed_list, "a {\n empty: [];\n}\n");
test!(
empty_bracketed_list,
"a {\n empty: [];\n}\n",
"a {\n empty: [];\n}\n"
);
test!(
empty_bracketed_list_equality,
"a {\n color: []==[];\n}\n",

View File

@ -1,18 +1,5 @@
#[macro_export]
macro_rules! test {
($( #[$attr:meta] ),*$func:ident, $input:expr) => {
$(#[$attr])*
#[test]
#[allow(non_snake_case)]
fn $func() {
let sass = grass::from_string($input.to_string(), &grass::Options::default())
.expect(concat!("failed to parse on ", $input));
assert_eq!(
String::from($input),
sass
);
}
};
($( #[$attr:meta] ),*$func:ident, $input:expr, $output:expr) => {
$(#[$attr])*
#[test]

View File

@ -3,6 +3,7 @@ mod macros;
test!(
basic_toplevel,
"@media foo {\n a {\n color: red;\n }\n}\n",
"@media foo {\n a {\n color: red;\n }\n}\n"
);
error!(

View File

@ -3,15 +3,18 @@ mod macros;
test!(
ident_starts_with_hyphen,
"a {\n foo: -webkit-bar-baz;\n}\n",
"a {\n foo: -webkit-bar-baz;\n}\n"
);
test!(
ident_starts_with_double_hyphen,
"a {\n foo: --webkit-bar-baz;\n}\n",
"a {\n foo: --webkit-bar-baz;\n}\n"
);
test!(ident_with_num, "el1 {\n a: b;\n}\n");
test!(ident_with_num, "el1 {\n a: b;\n}\n", "el1 {\n a: b;\n}\n");
test!(
emits_double_newline_between_unrelated_styles,
"a {\n color: red;\n}\n\nb {\n color: blue;\n}\n",
"a {\n color: red;\n}\n\nb {\n color: blue;\n}\n"
);
test!(
@ -61,14 +64,17 @@ test!(
);
test!(
does_not_combine_idents_with_leading_hyphen,
"a {\n color: a -b;\n}\n",
"a {\n color: a -b;\n}\n"
);
test!(
does_not_combine_idents_with_leading_hyphen_list,
"a {\n color: a -b c;\n}\n",
"a {\n color: a -b c;\n}\n"
);
test!(
does_not_combine_idents_with_leading_hyphen_all,
"a {\n color: -a -b -c;\n}\n",
"a {\n color: -a -b -c;\n}\n"
);
test!(

View File

@ -33,9 +33,21 @@ test!(
"a {\n color: 1.0000;\n}\n",
"a {\n color: 1;\n}\n"
);
test!(many_nines_not_rounded, "a {\n color: 0.999999;\n}\n");
test!(positive_integer, "a {\n color: 1;\n}\n");
test!(negative_integer, "a {\n color: -1;\n}\n");
test!(
many_nines_not_rounded,
"a {\n color: 0.999999;\n}\n",
"a {\n color: 0.999999;\n}\n"
);
test!(
positive_integer,
"a {\n color: 1;\n}\n",
"a {\n color: 1;\n}\n"
);
test!(
negative_integer,
"a {\n color: -1;\n}\n",
"a {\n color: -1;\n}\n"
);
test!(
positive_float_no_leading_zero,
"a {\n color: .1;\n}\n",
@ -46,8 +58,16 @@ test!(
"a {\n color: -.1;\n}\n",
"a {\n color: -0.1;\n}\n"
);
test!(positive_float_leading_zero, "a {\n color: 0.1;\n}\n");
test!(negative_float_leading_zero, "a {\n color: -0.1;\n}\n");
test!(
positive_float_leading_zero,
"a {\n color: 0.1;\n}\n",
"a {\n color: 0.1;\n}\n"
);
test!(
negative_float_leading_zero,
"a {\n color: -0.1;\n}\n",
"a {\n color: -0.1;\n}\n"
);
test!(
negative_near_zero_no_sign,
"a {\n color: -0.000000000001;\n}\n",
@ -98,7 +118,7 @@ test!(
"a {\n color: 1.2e-5;\n}\n",
"a {\n color: 0.000012;\n}\n"
);
test!(unit_e, "a {\n color: 1e;\n}\n");
test!(unit_e, "a {\n color: 1e;\n}\n", "a {\n color: 1e;\n}\n");
test!(
positive_scientific_notation_zero,
"a {\n color: 1e0;\n}\n",

View File

@ -6,30 +6,70 @@ test!(
"a, b {\n a, b {\n color: red\n}\n}\n",
"a a, a b, b a, b b {\n color: red;\n}\n"
);
test!(selector_element, "a {\n color: red;\n}\n");
test!(selector_id, "#id {\n color: red;\n}\n");
test!(selector_class, ".class {\n color: red;\n}\n");
test!(selector_el_descendant, "a a {\n color: red;\n}\n");
test!(selector_universal, "* {\n color: red;\n}\n");
test!(selector_el_class_and, "a.class {\n color: red;\n}\n");
test!(selector_el_id_and, "a#class {\n color: red;\n}\n");
test!(
selector_element,
"a {\n color: red;\n}\n",
"a {\n color: red;\n}\n"
);
test!(
selector_id,
"#id {\n color: red;\n}\n",
"#id {\n color: red;\n}\n"
);
test!(
selector_class,
".class {\n color: red;\n}\n",
".class {\n color: red;\n}\n"
);
test!(
selector_el_descendant,
"a a {\n color: red;\n}\n",
"a a {\n color: red;\n}\n"
);
test!(
selector_universal,
"* {\n color: red;\n}\n",
"* {\n color: red;\n}\n"
);
test!(
selector_el_class_and,
"a.class {\n color: red;\n}\n",
"a.class {\n color: red;\n}\n"
);
test!(
selector_el_id_and,
"a#class {\n color: red;\n}\n",
"a#class {\n color: red;\n}\n"
);
test!(
selector_el_class_descendant,
"a .class {\n color: red;\n}\n",
"a .class {\n color: red;\n}\n"
);
test!(selector_el_id_descendant, "a #class {\n color: red;\n}\n");
test!(
selector_el_id_descendant,
"a #class {\n color: red;\n}\n",
"a #class {\n color: red;\n}\n"
);
test!(
selector_el_universal_descendant,
"a * {\n color: red;\n}\n",
"a * {\n color: red;\n}\n"
);
test!(
selector_universal_el_descendant,
"* a {\n color: red;\n}\n",
"* a {\n color: red;\n}\n"
);
test!(selector_attribute_any, "[attr] {\n color: red;\n}\n");
test!(
selector_attribute_any,
"[attr] {\n color: red;\n}\n",
"[attr] {\n color: red;\n}\n"
);
test!(
selector_attribute_any_lower_case_insensitive,
"[attr=val i] {\n color: red;\n}\n",
"[attr=val i] {\n color: red;\n}\n"
);
test!(
@ -39,18 +79,22 @@ test!(
);
test!(
selector_attribute_any_upper_case_insensitive,
"[attr=val I] {\n color: red;\n}\n",
"[attr=val I] {\n color: red;\n}\n"
);
test!(
selector_attribute_arbitrary_modifier,
"[attr=val c] {\n color: red;\n}\n",
"[attr=val c] {\n color: red;\n}\n"
);
test!(
selector_attribute_i_in_attr,
"[atitr=val] {\n color: red;\n}\n",
"[atitr=val] {\n color: red;\n}\n"
);
test!(
selector_attribute_i_in_val,
"[attr=vail] {\n color: red;\n}\n",
"[attr=vail] {\n color: red;\n}\n"
);
test!(
@ -60,6 +104,7 @@ test!(
);
test!(
selector_attribute_equals,
"[attr=val] {\n color: red;\n}\n",
"[attr=val] {\n color: red;\n}\n"
);
test!(
@ -74,10 +119,12 @@ test!(
);
test!(
selector_attribute_quotes_non_ident,
"[attr=\"1\"] {\n color: red;\n}\n",
"[attr=\"1\"] {\n color: red;\n}\n"
);
test!(
selector_attribute_quotes_custom_property,
"[attr=\"--foo\"] {\n color: red;\n}\n",
"[attr=\"--foo\"] {\n color: red;\n}\n"
);
test!(
@ -87,10 +134,12 @@ test!(
);
test!(
selector_attribute_quoted_escape,
"[attr=\"v\\al\"] {\n color: red;\n}\n",
"[attr=\"v\\al\"] {\n color: red;\n}\n"
);
test!(
selector_attribute_namespace,
"[*|foo] {\n color: red;\n}\n",
"[*|foo] {\n color: red;\n}\n"
);
error!(
@ -99,32 +148,46 @@ error!(
);
test!(
selector_attribute_maintains_quotes_around_invalid_identifier,
"[attr=\"val.\"] {\n color: red;\n}\n",
"[attr=\"val.\"] {\n color: red;\n}\n"
);
error!(
attribute_attr_quoted,
"[\"attr\"=val] {\n color: red;\n}\n", "Error: Expected identifier."
);
test!(selector_attribute_in, "[attr~=val] {\n color: red;\n}\n");
test!(
selector_attribute_in,
"[attr~=val] {\n color: red;\n}\n",
"[attr~=val] {\n color: red;\n}\n"
);
test!(
selector_attribute_begins_hyphen_or_exact,
"[attr|=val] {\n color: red;\n}\n",
"[attr|=val] {\n color: red;\n}\n"
);
test!(
selector_attribute_starts_with,
"[attr^=val] {\n color: red;\n}\n",
"[attr^=val] {\n color: red;\n}\n"
);
test!(
selector_attribute_ends_with,
"[attr$=val] {\n color: red;\n}\n",
"[attr$=val] {\n color: red;\n}\n"
);
test!(
selector_attribute_contains,
"[attr*=val] {\n color: red;\n}\n",
"[attr*=val] {\n color: red;\n}\n"
);
test!(selector_el_attribute_and, "a[attr] {\n color: red;\n}\n");
test!(
selector_el_attribute_and,
"a[attr] {\n color: red;\n}\n",
"a[attr] {\n color: red;\n}\n"
);
test!(
selector_el_attribute_descendant,
"a [attr] {\n color: red;\n}\n",
"a [attr] {\n color: red;\n}\n"
);
test!(
@ -132,42 +195,74 @@ test!(
"a {\n [#{&}] {\n color: red;\n }\n}\n",
"a [a] {\n color: red;\n}\n"
);
test!(selector_el_mul_el, "a, b {\n color: red;\n}\n");
test!(
selector_el_mul_el,
"a, b {\n color: red;\n}\n",
"a, b {\n color: red;\n}\n"
);
test!(
selector_el_immediate_child_el,
"a > b {\n color: red;\n}\n",
"a > b {\n color: red;\n}\n"
);
test!(selector_el_following_el, "a + b {\n color: red;\n}\n");
test!(selector_el_preceding_el, "a ~ b {\n color: red;\n}\n");
test!(selector_pseudo, ":pseudo {\n color: red;\n}\n");
test!(selector_el_and_pseudo, "a:pseudo {\n color: red;\n}\n");
test!(
selector_el_following_el,
"a + b {\n color: red;\n}\n",
"a + b {\n color: red;\n}\n"
);
test!(
selector_el_preceding_el,
"a ~ b {\n color: red;\n}\n",
"a ~ b {\n color: red;\n}\n"
);
test!(
selector_pseudo,
":pseudo {\n color: red;\n}\n",
":pseudo {\n color: red;\n}\n"
);
test!(
selector_el_and_pseudo,
"a:pseudo {\n color: red;\n}\n",
"a:pseudo {\n color: red;\n}\n"
);
test!(
selector_el_pseudo_descendant,
"a :pseudo {\n color: red;\n}\n",
"a :pseudo {\n color: red;\n}\n"
);
test!(
selector_pseudo_el_descendant,
":pseudo a {\n color: red;\n}\n",
":pseudo a {\n color: red;\n}\n"
);
test!(selector_pseudoelement, "::before {\n color: red;\n}\n");
test!(
selector_pseudoelement,
"::before {\n color: red;\n}\n",
"::before {\n color: red;\n}\n"
);
test!(
selector_el_and_pseudoelement,
"a::before {\n color: red;\n}\n",
"a::before {\n color: red;\n}\n"
);
test!(
selector_el_pseudoelement_descendant,
"a ::before {\n color: red;\n}\n",
"a ::before {\n color: red;\n}\n"
);
test!(
selector_pseudoelement_el_descendant,
"::before a {\n color: red;\n}\n",
"::before a {\n color: red;\n}\n"
);
test!(
selector_pseudo_paren_comma,
":pseudo(a, b, c) {\n color: red;\n}\n",
":pseudo(a, b, c) {\n color: red;\n}\n"
);
test!(
selector_pseudo_paren_space,
":pseudo(a b c) {\n color: red;\n}\n",
":pseudo(a b c) {\n color: red;\n}\n"
);
test!(
@ -177,14 +272,17 @@ test!(
);
test!(
selector_el_pseudo_paren_and,
"a:pseudo(a, b, c) {\n color: red;\n}\n",
"a:pseudo(a, b, c) {\n color: red;\n}\n"
);
test!(
selector_el_pseudo_paren_descendant,
"a :pseudo(a, b, c) {\n color: red;\n}\n",
"a :pseudo(a, b, c) {\n color: red;\n}\n"
);
test!(
selector_pseudo_paren_el_descendant,
":pseudo(a, b, c) a {\n color: red;\n}\n",
":pseudo(a, b, c) a {\n color: red;\n}\n"
);
test!(
@ -192,7 +290,11 @@ test!(
"a {\n :pseudo(a, b, c) {\n color: red;\n }\n}\n",
"a :pseudo(a, b, c) {\n color: red;\n}\n"
);
test!(selector_mul, "a, b {\n color: red;\n}\n");
test!(
selector_mul,
"a, b {\n color: red;\n}\n",
"a, b {\n color: red;\n}\n"
);
test!(
outer_ampersand,
"a, b {\n& c {\n color: red;\n}\n}\n",
@ -298,7 +400,11 @@ test!(
"a {\n + {\n b {\n color: red;\n }\n}\n",
"a + b {\n color: red;\n}\n"
);
test!(simple_multiple_newline, "a,\nb {\n color: red;\n}\n");
test!(
simple_multiple_newline,
"a,\nb {\n color: red;\n}\n",
"a,\nb {\n color: red;\n}\n"
);
test!(
nested_multiple_newline,
"a,\nb {\n c {\n color: blue;\n }\n color: red;\n}\n",
@ -335,8 +441,16 @@ test!(
"#{&} a {\n color: red;\n}\n",
"a {\n color: red;\n}\n"
);
test!(allows_id_start_with_number, "#2foo {\n color: red;\n}\n");
test!(allows_id_only_number, "#2 {\n color: red;\n}\n");
test!(
allows_id_start_with_number,
"#2foo {\n color: red;\n}\n",
"#2foo {\n color: red;\n}\n"
);
test!(
allows_id_only_number,
"#2 {\n color: red;\n}\n",
"#2 {\n color: red;\n}\n"
);
test!(
id_interpolation,
"$zzz: zzz;\n##{$zzz} {\n a: b;\n}\n",
@ -347,7 +461,11 @@ test!(
"$bar: \"#foo\";\nul li#{$bar} {\n foo: bar;\n}\n",
"ul li#foo {\n foo: bar;\n}\n"
);
test!(escaped_space, "a\\ b {\n color: foo;\n}\n");
test!(
escaped_space,
"a\\ b {\n color: foo;\n}\n",
"a\\ b {\n color: foo;\n}\n"
);
test!(
escaped_bang,
"\\! {\n color: red;\n}\n",
@ -355,6 +473,7 @@ test!(
);
test!(
multiple_consecutive_immediate_child,
"> > foo {\n color: foo;\n}\n",
"> > foo {\n color: foo;\n}\n"
);
error!(
@ -418,6 +537,7 @@ test!(
);
test!(
touching_universal_stays_the_same,
"a* {\n color: red;\n}\n",
"a* {\n color: red;\n}\n"
);
test!(

View File

@ -13,10 +13,12 @@ test!(
);
test!(
calc_multiple_args,
"a {\n color: calc(1, 2, a, b, c);\n}\n",
"a {\n color: calc(1, 2, a, b, c);\n}\n"
);
test!(
calc_does_not_evaluate_arithmetic,
"a {\n color: calc(1 + 2);\n}\n",
"a {\n color: calc(1 + 2);\n}\n"
);
test!(
@ -24,14 +26,24 @@ test!(
"a {\n color: calc(#{1 + 2});\n}\n",
"a {\n color: calc(3);\n}\n"
);
test!(calc_retains_silent_comment, "a {\n color: calc(//);\n}\n");
test!(
calc_retains_silent_comment,
"a {\n color: calc(//);\n}\n",
"a {\n color: calc(//);\n}\n"
);
test!(
calc_retains_multiline_comment,
"a {\n color: calc(/**/);\n}\n",
"a {\n color: calc(/**/);\n}\n"
);
test!(calc_nested_parens, "a {\n color: calc((((()))));\n}\n");
test!(
calc_nested_parens,
"a {\n color: calc((((()))));\n}\n",
"a {\n color: calc((((()))));\n}\n"
);
test!(
calc_invalid_arithmetic,
"a {\n color: calc(2px + 2px + 5%);\n}\n",
"a {\n color: calc(2px + 2px + 5%);\n}\n"
);
test!(
@ -81,10 +93,12 @@ test!(
);
test!(
element_multiple_args,
"a {\n color: element(1, 2, a, b, c);\n}\n",
"a {\n color: element(1, 2, a, b, c);\n}\n"
);
test!(
element_does_not_evaluate_arithmetic,
"a {\n color: element(1 + 2);\n}\n",
"a {\n color: element(1 + 2);\n}\n"
);
test!(
@ -94,14 +108,17 @@ test!(
);
test!(
element_retains_silent_comment,
"a {\n color: element(//);\n}\n",
"a {\n color: element(//);\n}\n"
);
test!(
element_retains_multiline_comment,
"a {\n color: element(/**/);\n}\n",
"a {\n color: element(/**/);\n}\n"
);
test!(
element_nested_parens,
"a {\n color: element((((()))));\n}\n",
"a {\n color: element((((()))));\n}\n"
);
test!(
@ -121,10 +138,12 @@ test!(
);
test!(
expression_multiple_args,
"a {\n color: expression(1, 2, a, b, c);\n}\n",
"a {\n color: expression(1, 2, a, b, c);\n}\n"
);
test!(
expression_does_not_evaluate_arithmetic,
"a {\n color: expression(1 + 2);\n}\n",
"a {\n color: expression(1 + 2);\n}\n"
);
test!(
@ -134,14 +153,17 @@ test!(
);
test!(
expression_retains_silent_comment,
"a {\n color: expression(//);\n}\n",
"a {\n color: expression(//);\n}\n"
);
test!(
expression_retains_multiline_comment,
"a {\n color: expression(/**/);\n}\n",
"a {\n color: expression(/**/);\n}\n"
);
test!(
expression_nested_parens,
"a {\n color: expression((((()))));\n}\n",
"a {\n color: expression((((()))));\n}\n"
);
test!(
@ -161,10 +183,12 @@ test!(
);
test!(
progid_multiple_args,
"a {\n color: progid:(1, 2, a, b, c);\n}\n",
"a {\n color: progid:(1, 2, a, b, c);\n}\n"
);
test!(
progid_does_not_evaluate_arithmetic,
"a {\n color: progid:(1 + 2);\n}\n",
"a {\n color: progid:(1 + 2);\n}\n"
);
test!(
@ -174,18 +198,22 @@ test!(
);
test!(
progid_retains_silent_comment,
"a {\n color: progid:(//);\n}\n",
"a {\n color: progid:(//);\n}\n"
);
test!(
progid_retains_multiline_comment,
"a {\n color: progid:(/**/);\n}\n",
"a {\n color: progid:(/**/);\n}\n"
);
test!(
progid_nested_parens,
"a {\n color: progid:((((()))));\n}\n",
"a {\n color: progid:((((()))));\n}\n"
);
test!(
progid_values_after_colon,
"a {\n color: progid:apple.bottoM..jeans.boots();\n}\n",
"a {\n color: progid:apple.bottoM..jeans.boots();\n}\n"
);
error!(

View File

@ -76,8 +76,16 @@ test!(
"a {\n color: blu\\65;\n}\n",
"a {\n color: blue;\n}\n"
);
test!(double_escape_is_preserved, "a {\n color: r\\\\65;\n}\n");
test!(semicolon_in_string, "a {\n color: \";\";\n}\n");
test!(
double_escape_is_preserved,
"a {\n color: r\\\\65;\n}\n",
"a {\n color: r\\\\65;\n}\n"
);
test!(
semicolon_in_string,
"a {\n color: \";\";\n}\n",
"a {\n color: \";\";\n}\n"
);
test!(
single_character_escape_sequence_has_space,
"a {\n color: \\fg1;\n}\n",
@ -133,7 +141,11 @@ test!(
"a {\n color: quote(\\b);\n}\n",
"a {\n color: \"\\\\b \";\n}\n"
);
test!(escaped_backslash, "a {\n color: \"\\\\\";\n}\n");
test!(
escaped_backslash,
"a {\n color: \"\\\\\";\n}\n",
"a {\n color: \"\\\\\";\n}\n"
);
test!(
double_quotes_when_containing_single_quote,
"a {\n color: '\\\'';\n}\n",
@ -141,14 +153,17 @@ test!(
);
test!(
allows_escaped_quote_at_start_of_ident,
"a {\n color: \\\"c\\\";\n}\n",
"a {\n color: \\\"c\\\";\n}\n"
);
test!(
quoted_escaped_newline_unchanged,
"a {\n color: \"\\a\";\n}\n",
"a {\n color: \"\\a\";\n}\n"
);
test!(
unquoted_escape_minus_unquoted,
"a {\n color: \\a - foo;\n}\n",
"a {\n color: \\a - foo;\n}\n"
);
test!(

View File

@ -234,4 +234,8 @@ test!(
"a {\n color: str-insert($string: \"foo\", $insert: \"X\", $index: -99999999999999999999);\n}\n",
"a {\n color: \"Xfoo\";\n}\n"
);
test!(hash_in_string, "a {\n color: \"#foo\";\n}\n");
test!(
hash_in_string,
"a {\n color: \"#foo\";\n}\n",
"a {\n color: \"#foo\";\n}\n"
);

View File

@ -1,8 +1,16 @@
#[macro_use]
mod macros;
test!(basic_style, "a {\n color: red;\n}\n");
test!(two_styles, "a {\n color: red;\n color: blue;\n}\n");
test!(
basic_style,
"a {\n color: red;\n}\n",
"a {\n color: red;\n}\n"
);
test!(
two_styles,
"a {\n color: red;\n color: blue;\n}\n",
"a {\n color: red;\n color: blue;\n}\n"
);
test!(
two_inner_rulesets,
"a {\n b {\n color: red;\n}\n c {\n color: white;\n}\n}\n",
@ -10,6 +18,7 @@ test!(
);
test!(
two_rulesets,
"a {\n color: red;\n}\n\nc {\n color: white;\n}\n",
"a {\n color: red;\n}\n\nc {\n color: white;\n}\n"
);
test!(
@ -38,10 +47,19 @@ test!(
"a {\n color: red\n blue;\n}\n",
"a {\n color: red blue;\n}\n"
);
test!(hyphenated_style_property, "a {\n font-family: Arial;\n}\n");
test!(hyphenated_style_value, "a {\n color: Open-Sans;\n}\n");
test!(
hyphenated_style_property,
"a {\n font-family: Arial;\n}\n",
"a {\n font-family: Arial;\n}\n"
);
test!(
hyphenated_style_value,
"a {\n color: Open-Sans;\n}\n",
"a {\n color: Open-Sans;\n}\n"
);
test!(
space_separated_style_value,
"a {\n border: solid red;\n}\n",
"a {\n border: solid red;\n}\n"
);
test!(
@ -51,10 +69,12 @@ test!(
);
test!(
double_quoted_style_value,
"a {\n font: \"Open-Sans\";\n}\n",
"a {\n font: \"Open-Sans\";\n}\n"
);
test!(
comma_style_value,
"a {\n font: Open-Sans, sans-serif;\n}\n",
"a {\n font: Open-Sans, sans-serif;\n}\n"
);
test!(
@ -148,7 +168,11 @@ test!(
"foo {\n a: b {\n c: d {\n e: f;\n }\n }\n}\n",
"foo {\n a: b;\n a-c: d;\n a-c-e: f;\n}\n"
);
test!(curly_braces_in_quotes, "a {\n color: \"{foo}\";\n}\n");
test!(
curly_braces_in_quotes,
"a {\n color: \"{foo}\";\n}\n",
"a {\n color: \"{foo}\";\n}\n"
);
test!(
escaped_interpolation,
"a {\n color: \"\\#{foo}\";\n}\n",
@ -156,6 +180,7 @@ test!(
);
test!(
styles_after_quoted,
"a {\n color: \"red\";\n color: blue;\n}\n",
"a {\n color: \"red\";\n color: blue;\n}\n"
);
test!(

View File

@ -1,19 +1,31 @@
#[macro_use]
mod macros;
test!(unary_pos_unquoted_ident, "a {\n color: +foo;\n}\n");
test!(
unary_pos_unquoted_ident,
"a {\n color: +foo;\n}\n",
"a {\n color: +foo;\n}\n"
);
test!(
unary_pos_whitespace,
"a {\n color: + foo;\n}\n",
"a {\n color: +foo;\n}\n"
);
test!(unary_pos_dblquoted_ident, "a {\n color: +\"foo\";\n}\n");
test!(
unary_pos_dblquoted_ident,
"a {\n color: +\"foo\";\n}\n",
"a {\n color: +\"foo\";\n}\n"
);
test!(
unary_pos_sglquoted_ident,
"a {\n color: +'foo';\n}\n",
"a {\n color: +\"foo\";\n}\n"
);
test!(unary_pos_color, "a {\n color: +\"foo\";\n}\n");
test!(
unary_pos_color,
"a {\n color: +\"foo\";\n}\n",
"a {\n color: +\"foo\";\n}\n"
);
test!(
unary_pos_number_unit,
"a {\n color: +1px;\n}\n",
@ -29,15 +41,31 @@ test!(
"a {\n color: bar,+ \"bar\" - foo;\n}\n",
"a {\n color: bar, +\"bar\"-foo;\n}\n"
);
test!(unary_neg_unquoted_ident, "a {\n color: -foo;\n}\n");
test!(unary_neg_dblquoted_ident, "a {\n color: -\"foo\";\n}\n");
test!(
unary_neg_unquoted_ident,
"a {\n color: -foo;\n}\n",
"a {\n color: -foo;\n}\n"
);
test!(
unary_neg_dblquoted_ident,
"a {\n color: -\"foo\";\n}\n",
"a {\n color: -\"foo\";\n}\n"
);
test!(
unary_neg_sglquoted_ident,
"a {\n color: -'foo';\n}\n",
"a {\n color: -\"foo\";\n}\n"
);
test!(unary_neg_color, "a {\n color: -\"foo\";\n}\n");
test!(unary_neg_number, "a {\n color: -1px;\n}\n");
test!(
unary_neg_color,
"a {\n color: -\"foo\";\n}\n",
"a {\n color: -\"foo\";\n}\n"
);
test!(
unary_neg_number,
"a {\n color: -1px;\n}\n",
"a {\n color: -1px;\n}\n"
);
test!(
unary_neg_whitespace,
"a {\n color: - 1px;\n}\n",
@ -58,4 +86,8 @@ test!(
"a {\n color: -(null);\n}\n",
"a {\n color: -;\n}\n"
);
test!(negative_null_as_ident, "a {\n color: -null;\n}\n");
test!(
negative_null_as_ident,
"a {\n color: -null;\n}\n",
"a {\n color: -null;\n}\n"
);

View File

@ -1,12 +1,36 @@
#[macro_use]
mod macros;
test!(unit_none, "a {\n height: 1;\n}\n");
test!(unit_not_attached, "a {\n height: 1 px;\n}\n");
test!(unit_px, "a {\n height: 1px;\n}\n");
test!(unit_em, "a {\n height: 1em;\n}\n");
test!(unit_rem, "a {\n height: 1rem;\n}\n");
test!(unit_percent, "a {\n height: 1%;\n}\n");
test!(
unit_none,
"a {\n height: 1;\n}\n",
"a {\n height: 1;\n}\n"
);
test!(
unit_not_attached,
"a {\n height: 1 px;\n}\n",
"a {\n height: 1 px;\n}\n"
);
test!(
unit_px,
"a {\n height: 1px;\n}\n",
"a {\n height: 1px;\n}\n"
);
test!(
unit_em,
"a {\n height: 1em;\n}\n",
"a {\n height: 1em;\n}\n"
);
test!(
unit_rem,
"a {\n height: 1rem;\n}\n",
"a {\n height: 1rem;\n}\n"
);
test!(
unit_percent,
"a {\n height: 1%;\n}\n",
"a {\n height: 1%;\n}\n"
);
test!(
unit_times_none,
"a {\n color: 3px * 2;\n}\n",

View File

@ -3,10 +3,15 @@ mod macros;
test!(
basic_unknown_at_rule,
"@foo {\n a {\n color: red;\n }\n}\n",
"@foo {\n a {\n color: red;\n }\n}\n"
);
test!(unknown_at_rule_no_selector, "@foo {\n color: red;\n}\n");
test!(unknown_at_rule_no_body, "@foo;\n");
test!(
unknown_at_rule_no_selector,
"@foo {\n color: red;\n}\n",
"@foo {\n color: red;\n}\n"
);
test!(unknown_at_rule_no_body, "@foo;\n", "@foo;\n");
test!(unknown_at_rule_no_body_eof, "@foo", "@foo;\n");
test!(
unknown_at_rule_interpolated_eof_no_body,

View File

@ -43,13 +43,19 @@ test!(
);
test!(
silent_comment,
"a {\n color: url(//some/absolute/path);\n}\n",
"a {\n color: url(//some/absolute/path);\n}\n"
);
test!(
multiline_comment,
"a {\n color: url(/*looks-like-a*/comment);\n}\n",
"a {\n color: url(/*looks-like-a*/comment);\n}\n"
);
test!(plain_css_function, "a {\n color: url(fn(\"s\"));\n}\n");
test!(
plain_css_function,
"a {\n color: url(fn(\"s\"));\n}\n",
"a {\n color: url(fn(\"s\"));\n}\n"
);
test!(
builtin_function,
"a {\n color: url(if(true, \"red.png\", \"blue.png\"));\n}\n",
@ -70,10 +76,19 @@ test!(
"a {\n color: url(\"hello-#{world}.png\");\n}\n",
"a {\n color: url(\"hello-world.png\");\n}\n"
);
test!(simple_forward_slash, "a {\n color: url(foo/bar.css);\n}\n");
test!(http_url, "a {\n color: url(http://foo.bar.com);\n}\n");
test!(
simple_forward_slash,
"a {\n color: url(foo/bar.css);\n}\n",
"a {\n color: url(foo/bar.css);\n}\n"
);
test!(
http_url,
"a {\n color: url(http://foo.bar.com);\n}\n",
"a {\n color: url(http://foo.bar.com);\n}\n"
);
test!(
google_fonts_url,
"a {\n color: url(http://fonts.googleapis.com/css?family=Karla:400,700,400italic|Anonymous+Pro:400,700,400italic);\n}\n",
"a {\n color: url(http://fonts.googleapis.com/css?family=Karla:400,700,400italic|Anonymous+Pro:400,700,400italic);\n}\n"
);
test!(
@ -83,6 +98,7 @@ test!(
);
test!(
many_forward_slashes,
"a {\n color: url(http://box_////fudge.css);\n}\n",
"a {\n color: url(http://box_////fudge.css);\n}\n"
);
test!(
@ -95,7 +111,11 @@ test!(
"a {\n color: url(\n);\n}\n",
"a {\n color: url();\n}\n"
);
test!(url_comma_list, "a {\n color: url(1, 2, a, b, c);\n}\n");
test!(
url_comma_list,
"a {\n color: url(1, 2, a, b, c);\n}\n",
"a {\n color: url(1, 2, a, b, c);\n}\n"
);
test!(
url_contains_only_interpolation,
"a {\n color: url(#{1 + 2});\n}\n",
@ -106,7 +126,11 @@ test!(
"a {\n color: url(#{http}://foo);\n}\n",
"a {\n color: url(http://foo);\n}\n"
);
test!(url_dot_dot, "a {\n color: url(../foo/bar/..baz/);\n}\n");
test!(
url_dot_dot,
"a {\n color: url(../foo/bar/..baz/);\n}\n",
"a {\n color: url(../foo/bar/..baz/);\n}\n"
);
test!(
silent_comment_in_interpolation,
"$roboto-font-path: \"../fonts/roboto\";\n\na {\n color: url(#{//}\n $roboto-font-path});\n}\n",

View File

@ -6,35 +6,108 @@ test!(
"a {\n color: 'foo';\n}\n",
"a {\n color: \"foo\";\n}\n"
);
test!(double_quote, "a {\n color: \"foo\";\n}\n");
test!(comma_list_ident, "a {\n color: foo, bar, baz;\n}\n");
test!(space_list_ident, "a {\n color: foo bar baz;\n}\n");
test!(comma_list_number, "a {\n color: 1, 2, 3;\n}\n");
test!(space_list_number, "a {\n color: 1 2 3;\n}\n");
test!(comma_space_list_number, "a {\n color: 1 1, 2 2, 3 3;\n}\n");
test!(preserves_keyword_true, "a {\n color: true;\n}\n");
test!(preserves_keyword_false, "a {\n color: false;\n}\n");
test!(
double_quote,
"a {\n color: \"foo\";\n}\n",
"a {\n color: \"foo\";\n}\n"
);
test!(
comma_list_ident,
"a {\n color: foo, bar, baz;\n}\n",
"a {\n color: foo, bar, baz;\n}\n"
);
test!(
space_list_ident,
"a {\n color: foo bar baz;\n}\n",
"a {\n color: foo bar baz;\n}\n"
);
test!(
comma_list_number,
"a {\n color: 1, 2, 3;\n}\n",
"a {\n color: 1, 2, 3;\n}\n"
);
test!(
space_list_number,
"a {\n color: 1 2 3;\n}\n",
"a {\n color: 1 2 3;\n}\n"
);
test!(
comma_space_list_number,
"a {\n color: 1 1, 2 2, 3 3;\n}\n",
"a {\n color: 1 1, 2 2, 3 3;\n}\n"
);
test!(
preserves_keyword_true,
"a {\n color: true;\n}\n",
"a {\n color: true;\n}\n"
);
test!(
preserves_keyword_false,
"a {\n color: false;\n}\n",
"a {\n color: false;\n}\n"
);
test!(
does_not_preserve_keyword_null,
"a {\n color: null;\n}\n",
""
);
test!(preserves_keyword_auto, "a {\n color: auto;\n}\n");
test!(preserves_keyword_initial, "a {\n color: initial;\n}\n");
test!(preserves_keyword_infinity, "a {\n color: infinity;\n}\n");
test!(
preserves_keyword_auto,
"a {\n color: auto;\n}\n",
"a {\n color: auto;\n}\n"
);
test!(
preserves_keyword_initial,
"a {\n color: initial;\n}\n",
"a {\n color: initial;\n}\n"
);
test!(
preserves_keyword_infinity,
"a {\n color: infinity;\n}\n",
"a {\n color: infinity;\n}\n"
);
error!(
keyword_not_expects_expression,
"a {\n color: not;\n}\n", "Error: Expected expression."
);
test!(preserves_keyword_and, "a {\n color: and;\n}\n");
test!(preserves_keyword_or, "a {\n color: or;\n}\n");
test!(preserves_keyword_unset, "a {\n color: unset;\n}\n");
test!(preserves_keyword_nan, "a {\n color: NaN;\n}\n");
test!(preserves_keyword_from, "a {\n color: FRoM;\n}\n");
test!(preserves_keyword_to, "a {\n color: To;\n}\n");
test!(preserves_keyword_through, "a {\n color: ThRouGh;\n}\n");
test!(
preserves_keyword_and,
"a {\n color: and;\n}\n",
"a {\n color: and;\n}\n"
);
test!(
preserves_keyword_or,
"a {\n color: or;\n}\n",
"a {\n color: or;\n}\n"
);
test!(
preserves_keyword_unset,
"a {\n color: unset;\n}\n",
"a {\n color: unset;\n}\n"
);
test!(
preserves_keyword_nan,
"a {\n color: NaN;\n}\n",
"a {\n color: NaN;\n}\n"
);
test!(
preserves_keyword_from,
"a {\n color: FRoM;\n}\n",
"a {\n color: FRoM;\n}\n"
);
test!(
preserves_keyword_to,
"a {\n color: To;\n}\n",
"a {\n color: To;\n}\n"
);
test!(
preserves_keyword_through,
"a {\n color: ThRouGh;\n}\n",
"a {\n color: ThRouGh;\n}\n"
);
test!(
preserves_quotes,
"a {\n color: \"'foo' \\\"bar\\\"\";\n}\n",
"a {\n color: \"'foo' \\\"bar\\\"\";\n}\n"
);
test!(
@ -47,7 +120,7 @@ test!(
"a {\n color: 1 , 2 , 3 ;\n}\n",
"a {\n color: 1, 2, 3;\n}\n"
);
test!(number, "a {\n color: 1;\n}\n");
test!(number, "a {\n color: 1;\n}\n", "a {\n color: 1;\n}\n");
test!(
removes_paren_around_single_value,
"a {\n color: (foo);\n}\n",
@ -55,9 +128,14 @@ test!(
);
test!(
undefined_function_call_is_ident,
"a {\n color: foo();\n}\n",
"a {\n color: foo();\n}\n"
);
test!(hash_identifier_is_not_color, "a {\n color: #foo;\n}\n");
test!(
hash_identifier_is_not_color,
"a {\n color: #foo;\n}\n",
"a {\n color: #foo;\n}\n"
);
test!(
hash_identifier_is_string,
"a {\n color: type-of(#foo);\n}\n",