2020-04-02 12:07:54 -04:00
|
|
|
#![cfg(test)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
error!(
|
|
|
|
variable_after_varargs,
|
|
|
|
"@function foo($a..., $b) {\n @return $a;\n}\n", "Error: expected \")\"."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
varargs_one_period,
|
|
|
|
"@function foo($a.) {\n @return $a;\n}\n", "Error: expected \".\"."
|
|
|
|
);
|
|
|
|
error!(
|
|
|
|
varargs_two_periods,
|
|
|
|
"@function foo($a..) {\n @return $a;\n}\n", "Error: expected \".\"."
|
|
|
|
);
|
2020-04-02 13:33:26 -04:00
|
|
|
test!(
|
|
|
|
mixin_varargs_are_comma_separated,
|
|
|
|
"@mixin foo($a...) {\n color: $a;\n}\n\na {\n @include foo(1, 2, 3, 4, 5);\n}\n",
|
|
|
|
"a {\n color: 1, 2, 3, 4, 5;\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
function_varargs_are_comma_separated,
|
|
|
|
"@function foo($a...) {\n @return $a;\n}\n\na {\n color: foo(1, 2, 3, 4, 5);\n}\n",
|
|
|
|
"a {\n color: 1, 2, 3, 4, 5;\n}\n"
|
|
|
|
);
|
2020-04-04 18:17:04 -04:00
|
|
|
test!(
|
|
|
|
default_args_are_lazily_evaluated,
|
|
|
|
"$da: a;\n\n@mixin foo($x: $da) {\n color: $x;\n}\n$da: b;\n\na {\n @include foo();\n}\n",
|
|
|
|
"a {\n color: b;\n}\n"
|
|
|
|
);
|
2020-04-23 13:54:49 -04:00
|
|
|
test!(
|
|
|
|
variable_being_subtracted,
|
|
|
|
"$index: 1;\n\n@function foo($a) {\n @return $a;\n}\n\na {\n color: foo($index - 1);\n}\n",
|
|
|
|
"a {\n color: 0;\n}\n"
|
|
|
|
);
|
2020-04-24 23:15:41 -04:00
|
|
|
test!(
|
|
|
|
parens_in_default_arg_value,
|
|
|
|
"@function foo($arg1: bar()) {\n @return true;\n}\n\na {\n color: foo();\n}\n",
|
|
|
|
"a {\n color: true;\n}\n"
|
|
|
|
);
|
2020-04-26 13:51:44 -04:00
|
|
|
test!(
|
|
|
|
self_referential_default_arg_value,
|
|
|
|
"@function foo($a, $b: $a) {\n @return $b;\n}\n\na {\n color: foo(2);\n}\n",
|
|
|
|
"a {\n color: 2;\n}\n"
|
|
|
|
);
|
2020-07-03 15:06:26 -04:00
|
|
|
test!(
|
|
|
|
arg_errors_are_lazy_for_if,
|
|
|
|
"a {\n color: if(false, unit(foo), red);\n}\n",
|
|
|
|
"a {\n color: red;\n}\n"
|
|
|
|
);
|
2020-05-24 10:16:47 -04:00
|
|
|
error!(
|
2020-06-18 03:09:24 -04:00
|
|
|
#[ignore = "expects incorrect char, '{'"]
|
2020-05-24 10:16:47 -04:00
|
|
|
nothing_after_open,
|
2020-06-16 19:38:30 -04:00
|
|
|
"a { color:rgb(; }", "Error: expected \")\"."
|
2020-05-24 13:50:45 -04:00
|
|
|
);
|
2020-06-18 03:09:24 -04:00
|
|
|
error!(
|
|
|
|
nothing_after_open_paren_in_fn_args,
|
|
|
|
"@function foo(", "Error: expected \")\"."
|
|
|
|
);
|
2020-07-03 15:06:26 -04:00
|
|
|
error!(
|
|
|
|
args_are_evaluated_eagerly,
|
|
|
|
"@function foo($a) {\n @return foo;\n}\n\na {\n color: foo(unit(bar));\n}\n",
|
|
|
|
"Error: $number: bar is not a number."
|
|
|
|
);
|
2020-07-25 14:10:57 -04:00
|
|
|
test!(
|
|
|
|
variable_is_only_hyphens,
|
|
|
|
"$--: red;
|
|
|
|
|
|
|
|
a {
|
|
|
|
color: foo($--);
|
|
|
|
}",
|
|
|
|
"a {\n color: foo(red);\n}\n"
|
|
|
|
);
|
|
|
|
test!(
|
|
|
|
no_space_after_colon_in_keyword_arg,
|
|
|
|
"@function foo($a) {
|
|
|
|
@return $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
$b: red;
|
|
|
|
|
|
|
|
a {
|
|
|
|
color: foo($a:$b);
|
|
|
|
}",
|
|
|
|
"a {\n color: red;\n}\n"
|
|
|
|
);
|