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

Function test_pattern_parser

src/cosql/pattern/mod.rs:54–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52
53 #[test]
54 fn test_pattern_parser() {
55 let values = [
56 (
57 r#"$person1 isa person (
58 name: $name,
59 age: 18,
60 gender: "M"
61 )"#,
62 Pattern::EntityPattern(EntityPattern {
63 variable: "person1".to_string(),
64 entity_type: "person".to_string(),
65 attributes: vec![
66 Attribute {
67 name: "name".to_string(),
68 value: Value::Variable("name".to_string()),
69 },
70 Attribute {
71 name: "age".to_string(),
72 value: Value::Int(18),
73 },
74 Attribute {
75 name: "gender".to_string(),
76 value: Value::String("M".to_string()),
77 },
78 ],
79 }),
80 ),
81 (
82 r#"$city1 isa city (
83 name: "New York"
84 )"#,
85 Pattern::EntityPattern(EntityPattern {
86 variable: "city1".to_string(),
87 entity_type: "city".to_string(),
88 attributes: vec![Attribute {
89 name: "name".to_string(),
90 value: Value::String("New York".to_string()),
91 }],
92 }),
93 ),
94 (
95 "(
96 $person1,
97 $company1
98 ) forms works_in (
99 since: 2-10-1999
100 )",
101 Pattern::RelationshipPattern(RelationshipPattern {
102 variable: None,
103 roles: vec![
104 Role {
105 role: None,
106 entity: "person1".to_string(),
107 },
108 Role {
109 role: None,
110 entity: "company1".to_string(),
111 },

Callers

nothing calls this directly

Calls 4

EntityPatternClass · 0.85
RelationshipPatternClass · 0.85
ConditionEnum · 0.85
parse_patternFunction · 0.85

Tested by

no test coverage detected