grass/tests/use.rs

61 lines
1.2 KiB
Rust
Raw Normal View History

2020-07-25 19:23:37 -04:00
#![cfg(test)]
#[macro_use]
mod macros;
error!(
after_style,
"a {}
@use \"foo\";
",
"Error: @use rules must be written before any other rules."
);
2020-07-26 13:36:01 -04:00
error!(
interpolation_in_as_identifier,
2020-07-26 13:49:13 -04:00
"@use \"sass:math\" as m#{a}th;", "Error: expected \";\"."
2020-07-26 13:36:01 -04:00
);
error!(
use_as_quoted_string,
2020-07-26 13:49:13 -04:00
"@use \"sass:math\" as \"math\";", "Error: Expected identifier."
2020-07-26 13:36:01 -04:00
);
error!(
use_as_missing_s,
2020-07-26 13:49:13 -04:00
"@use \"sass:math\" a math;", "Error: expected \";\"."
2020-07-26 13:36:01 -04:00
);
error!(
unknown_module_get_variable,
2020-07-26 13:49:13 -04:00
"a { color: foo.$bar; }", "Error: There is no module with the namespace \"foo\"."
);
error!(
unknown_module_get_function,
2020-07-26 13:49:13 -04:00
"a { color: foo.bar(); }", "Error: There is no module with the namespace \"foo\"."
);
error!(
unknown_function,
2020-07-26 13:49:13 -04:00
"@use \"sass:math\";\na { color: math.bar(); }", "Error: Undefined function."
);
2020-07-26 13:36:01 -04:00
test!(
use_as,
"@use \"sass:math\" as foo;
a {
color: foo.clamp(0, 1, 2);
}",
"a {\n color: 1;\n}\n"
);
test!(
use_as_uppercase,
"@use \"sass:math\" AS foo;
a {
color: foo.clamp(0, 1, 2);
}",
"a {\n color: 1;\n}\n"
);
2020-07-27 18:55:38 -04:00
test!(
use_as_universal,
"@use \"sass:math\" as *;
a {
color: cos(2);
}",
"a {\n color: -0.4161468365;\n}\n"
);