reactive_graph_std_numeric/
providers.rs

1use reactive_graph_plugin_api::prelude::providers::*;
2
3#[derive(TypeProvider, Component)]
4#[type_provider(tys = "Components", path = "types/components")]
5pub struct NumericComponentsProvider {}
6
7#[derive(TypeProvider, Component)]
8#[type_provider(tys = "EntityTypes", path = "types/entities")]
9pub struct NumericEntityTypesProvider {}
10
11#[cfg(test)]
12mod tests {
13    use reactive_graph_graph::prelude::*;
14
15    use reactive_graph_std_numeric_model::NAMESPACE_NUMERIC;
16    use reactive_graph_std_numeric_model::NAMESPACE_NUMERIC_F64;
17    use reactive_graph_std_numeric_model::NAMESPACE_NUMERIC_I64;
18    use reactive_graph_std_numeric_model::NAMESPACE_NUMERIC_U64;
19
20    use super::*;
21
22    #[test]
23    fn components_should_exist() {
24        let expected_components = ComponentTypeIds::with_namespace(NAMESPACE_NUMERIC).ty("numeric_gate").ty("numeric_operation");
25        let component_provider = NumericComponentsProvider {};
26        assert!(
27            component_provider
28                .get_types()
29                .iter()
30                .all(|component| expected_components.contains(component.key()))
31        );
32    }
33
34    #[test]
35    fn entity_types_should_exist() {
36        let entity_type_provider = NumericEntityTypesProvider {};
37        let expected_entity_types_f64 = EntityTypeIds::with_namespace(NAMESPACE_NUMERIC_F64)
38            .ty("abs")
39            .ty("acos")
40            .ty("acosh")
41            .ty("asin")
42            .ty("asinh")
43            .ty("atan")
44            .ty("atan2")
45            .ty("atanh")
46            .ty("cbrt")
47            .ty("ceil")
48            .ty("cos")
49            .ty("cosh")
50            .ty("exp")
51            .ty("exp2")
52            .ty("floor")
53            .ty("fract")
54            .ty("hypot")
55            .ty("ln")
56            .ty("log")
57            .ty("log2")
58            .ty("log10")
59            .ty("pow")
60            .ty("recip")
61            .ty("round")
62            .ty("signum")
63            .ty("sin")
64            .ty("sinh")
65            .ty("sqrt")
66            .ty("tan")
67            .ty("tanh")
68            .ty("to_degrees")
69            .ty("to_radians")
70            .ty("trunc");
71        let expected_entity_types_i64 = EntityTypeIds::with_namespace(NAMESPACE_NUMERIC_I64).ty("abs").ty("signum");
72        let expected_entity_types_u64 = EntityTypeIds::with_namespace(NAMESPACE_NUMERIC_U64);
73        assert!(entity_type_provider.get_types().iter().all(|entity_type| {
74            expected_entity_types_f64.contains(entity_type.key())
75                || expected_entity_types_i64.contains(entity_type.key())
76                || expected_entity_types_u64.contains(entity_type.key())
77        }));
78    }
79}