MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_rule_parser

Function test_rule_parser

src/cosql/rule.rs:80–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78
79 #[test]
80 fn test_rule_parser() {
81 // the `parse_rule` function assumes the `define rule` part is already consumed
82 let values = [
83 (
84 "reachable_direct as
85 match
86 (from: $city1, to: $city2) forms direct_flight
87 infer
88 materialize (from: $city1, to: $city2) forms reachable;",
89 Rule {
90 name: "reachable_direct".to_string(),
91 patterns: vec![Pattern::RelationshipPattern(RelationshipPattern {
92 variable: None,
93 roles: vec![
94 Role {
95 role: Some("from".to_string()),
96 entity: "city1".to_string(),
97 },
98 Role {
99 role: Some("to".to_string()),
100 entity: "city2".to_string(),
101 },
102 ],
103 relationship_type: "direct_flight".to_string(),
104 attributes: vec![],
105 })],
106 compute_clauses: None,
107 inference_type: InferenceType::Materialize,
108 inferences: vec![Inference::RelationshipInference(RelationshipInference {
109 roles: vec![
110 Role {
111 role: Some("from".to_string()),
112 entity: "city1".to_string(),
113 },
114 Role {
115 role: Some("to".to_string()),
116 entity: "city2".to_string(),
117 },
118 ],
119 relationship_type: "reachable".to_string(),
120 attributes: vec![],
121 })],
122 },
123 ),
124 (
125 "reachable_indirect as
126 match
127 (from: $city1, to: $intermediate) forms reachable,
128 (from: $intermediate, to: $city2) forms reachable,
129 $city1 != $city2
130 infer
131 materialize (from: $city1, to: $city2) forms reachable;",
132 Rule {
133 name: "reachable_indirect".to_string(),
134 patterns: vec![
135 Pattern::RelationshipPattern(RelationshipPattern {
136 variable: None,
137 roles: vec![

Callers

nothing calls this directly

Calls 1

parse_ruleFunction · 0.85

Tested by

no test coverage detected