grass/tests/arglist.rs
2020-07-06 18:41:50 -04:00

54 lines
1002 B
Rust

#![cfg(test)]
#[macro_use]
mod macros;
test!(
length_of_empty_arglist,
"@mixin foo($a...) {\n color: length($list: $a);\n}\na {\n @include foo;\n}\n",
"a {\n color: 0;\n}\n"
);
test!(
length_of_arglist_in_mixin,
"@mixin foo($a...) {\n color: length($list: $a);\n}\na {\n @include foo(a, 2, c);\n}\n",
"a {\n color: 3;\n}\n"
);
test!(
arglist_in_at_each,
"@function sum($numbers...) {
$sum: 0;
@each $number in $numbers {
$sum: $sum + $number;
}
@return $sum;
}
a {
width: sum(50px, 30px, 100px);
}",
"a {\n width: 180px;\n}\n"
);
error!(
emit_empty_arglist,
"@function foo($a...) {
@return $a;
}
a {
color: foo();
}",
"Error: () isn't a valid CSS value."
);
test!(
inspect_empty_arglist,
"@function foo($a...) {
@return inspect($a);
}
a {
color: foo();
}",
"a {\n color: ();\n}\n"
);