grass/tests/arglist.rs

65 lines
1.2 KiB
Rust
Raw Normal View History

2020-06-17 05:24:42 -04:00
#![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"
);
2020-07-06 18:10:22 -04:00
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"
);
test!(
empty_arglist_is_allowed_in_map_functions,
"@function foo($a...) {
@return map-get($map: $a, $key: foo);
}
a {
color: inspect(foo());
}",
"a {\n color: null;\n}\n"
);