css_ast/functions/
xywh_function.rs1use super::prelude::*;
2
3#[node]
12#[derive(Parse, Peek, ToCursors, ToSpan, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
14#[cfg_attr(feature = "visitable", derive(csskit_derives::Visitable), visit(self))]
15#[derive(csskit_derives::NodeWithMetadata)]
16pub struct XywhFunction<'a> {
17 #[atom(CssAtomSet::Xywh)]
18 pub name: T![Function],
19 pub params: XywhFunctionParams<'a>,
20 #[semantic_eq(skip)]
21 pub close: T![')'],
22}
23
24#[syntax(" <length-percentage>{2} <length-percentage [0,∞]>{2} [ round <'border-radius'> ]? ")]
25#[derive(Parse, Peek, ToSpan, ToCursors, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
26#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
27#[derive(csskit_derives::NodeWithMetadata)]
28pub struct XywhFunctionParams<'a>;
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use crate::CssAtomSet;
34 use css_parse::{assert_parse, assert_parse_error, assert_peek_false};
35
36 #[test]
37 fn test_parses() {
38 assert_parse!(CssAtomSet::ATOMS, XywhFunction, "xywh(10px 20px 30px 40px)");
39 assert_parse!(CssAtomSet::ATOMS, XywhFunction, "xywh(0 0 100% 50%)");
40 assert_parse!(CssAtomSet::ATOMS, XywhFunction, "xywh(10px 20px 30px 40px round 5px)");
41 }
42
43 #[test]
44 fn test_errors() {
45 assert_peek_false!(CssAtomSet::ATOMS, XywhFunction, "inset(10px)");
46 assert_parse_error!(CssAtomSet::ATOMS, XywhFunction, "xywh(10px 20px 30px)");
47 assert_parse_error!(CssAtomSet::ATOMS, XywhFunction, "xywh(10px 20px -30px 40px)");
48 }
49}