css_ast/functions/
path_function.rs1use super::prelude::*;
2use crate::FillRuleStyleValue;
3
4#[node]
13#[derive(Parse, Peek, ToCursors, ToSpan, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
15#[cfg_attr(feature = "visitable", derive(csskit_derives::Visitable), visit(self))]
16#[derive(csskit_derives::NodeWithMetadata)]
17pub struct PathFunction<'a> {
18 #[atom(CssAtomSet::Path)]
19 pub name: T![Function],
20 pub fill_rule: Option<FillRuleStyleValue<'a>>,
21 #[semantic_eq(skip)]
22 pub comma: Option<T![,]>,
23 pub path: T![String],
24 #[semantic_eq(skip)]
25 pub close: T![')'],
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31 use crate::CssAtomSet;
32 use css_parse::{assert_parse, assert_parse_error, assert_peek_false};
33
34 #[test]
35 fn test_parses() {
36 assert_parse!(CssAtomSet::ATOMS, PathFunction, "path('M 0 0 L 10 10')");
37 assert_parse!(CssAtomSet::ATOMS, PathFunction, "path(evenodd,'M 0 0 L 10 10 Z')");
38 }
39
40 #[test]
41 fn test_errors() {
42 assert_peek_false!(CssAtomSet::ATOMS, PathFunction, "circle(10px)");
43 assert_parse_error!(CssAtomSet::ATOMS, PathFunction, "path()");
44 }
45}