gqlite 1.2.0 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gqliterb/.cargo/config.toml +2 -0
  3. data/ext/gqliterb/Cargo.lock +152 -135
  4. data/ext/gqliterb/Cargo.toml +4 -6
  5. data/ext/gqliterb/src/lib.rs +8 -2
  6. data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +2115 -0
  7. data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +138 -0
  8. data/ext/gqliterb/vendor/gqlitedb/askama.toml +3 -0
  9. data/ext/gqliterb/vendor/gqlitedb/benches/common/mod.rs +25 -0
  10. data/ext/gqliterb/vendor/gqlitedb/benches/common/pokec.rs +185 -0
  11. data/ext/gqliterb/vendor/gqlitedb/benches/pokec_divan.rs +137 -0
  12. data/ext/gqliterb/vendor/gqlitedb/benches/pokec_iai.rs +122 -0
  13. data/ext/gqliterb/vendor/gqlitedb/release.toml +7 -0
  14. data/ext/gqliterb/vendor/gqlitedb/src/aggregators/arithmetic.rs +96 -0
  15. data/ext/gqliterb/vendor/gqlitedb/src/aggregators/containers.rs +33 -0
  16. data/ext/gqliterb/vendor/gqlitedb/src/aggregators/count.rs +35 -0
  17. data/ext/gqliterb/vendor/gqlitedb/src/aggregators/stats.rs +168 -0
  18. data/ext/gqliterb/vendor/gqlitedb/src/aggregators.rs +74 -0
  19. data/ext/gqliterb/vendor/gqlitedb/src/capi.rs +259 -0
  20. data/ext/gqliterb/vendor/gqlitedb/src/compiler/expression_analyser.rs +431 -0
  21. data/ext/gqliterb/vendor/gqlitedb/src/compiler/variables_manager.rs +621 -0
  22. data/ext/gqliterb/vendor/gqlitedb/src/compiler.rs +1115 -0
  23. data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +342 -0
  24. data/ext/gqliterb/vendor/gqlitedb/src/consts.rs +10 -0
  25. data/ext/gqliterb/vendor/gqlitedb/src/error.rs +613 -0
  26. data/ext/gqliterb/vendor/gqlitedb/src/functions/containers.rs +115 -0
  27. data/ext/gqliterb/vendor/gqlitedb/src/functions/edge.rs +20 -0
  28. data/ext/gqliterb/vendor/gqlitedb/src/functions/math.rs +44 -0
  29. data/ext/gqliterb/vendor/gqlitedb/src/functions/node.rs +16 -0
  30. data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +80 -0
  31. data/ext/gqliterb/vendor/gqlitedb/src/functions/scalar.rs +86 -0
  32. data/ext/gqliterb/vendor/gqlitedb/src/functions/string.rs +28 -0
  33. data/ext/gqliterb/vendor/gqlitedb/src/functions/value.rs +99 -0
  34. data/ext/gqliterb/vendor/gqlitedb/src/functions.rs +410 -0
  35. data/ext/gqliterb/vendor/gqlitedb/src/graph.rs +283 -0
  36. data/ext/gqliterb/vendor/gqlitedb/src/interpreter/evaluators.rs +1776 -0
  37. data/ext/gqliterb/vendor/gqlitedb/src/interpreter/instructions.rs +267 -0
  38. data/ext/gqliterb/vendor/gqlitedb/src/interpreter/mod.rs +4 -0
  39. data/ext/gqliterb/vendor/gqlitedb/src/lib.rs +41 -0
  40. data/ext/gqliterb/vendor/gqlitedb/src/parser/ast.rs +611 -0
  41. data/ext/gqliterb/vendor/gqlitedb/src/parser/gql.pest +196 -0
  42. data/ext/gqliterb/vendor/gqlitedb/src/parser/parser.rs +1183 -0
  43. data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +4 -0
  44. data/ext/gqliterb/vendor/gqlitedb/src/prelude.rs +8 -0
  45. data/ext/gqliterb/vendor/gqlitedb/src/serialize_with.rs +94 -0
  46. data/ext/gqliterb/vendor/gqlitedb/src/store/pgql.rs +121 -0
  47. data/ext/gqliterb/vendor/gqlitedb/src/store/redb.rs +1262 -0
  48. data/ext/gqliterb/vendor/gqlitedb/src/store/sqlite.rs +1026 -0
  49. data/ext/gqliterb/vendor/gqlitedb/src/store.rs +439 -0
  50. data/ext/gqliterb/vendor/gqlitedb/src/tests/compiler.rs +92 -0
  51. data/ext/gqliterb/vendor/gqlitedb/src/tests/evaluators.rs +227 -0
  52. data/ext/gqliterb/vendor/gqlitedb/src/tests/parser.rs +81 -0
  53. data/ext/gqliterb/vendor/gqlitedb/src/tests/store/redb.rs +46 -0
  54. data/ext/gqliterb/vendor/gqlitedb/src/tests/store/sqlite.rs +46 -0
  55. data/ext/gqliterb/vendor/gqlitedb/src/tests/store.rs +470 -0
  56. data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/ast.rs +356 -0
  57. data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/programs.rs +455 -0
  58. data/ext/gqliterb/vendor/gqlitedb/src/tests/templates.rs +2 -0
  59. data/ext/gqliterb/vendor/gqlitedb/src/tests.rs +39 -0
  60. data/ext/gqliterb/vendor/gqlitedb/src/utils.rs +28 -0
  61. data/ext/gqliterb/vendor/gqlitedb/src/value/compare.rs +212 -0
  62. data/ext/gqliterb/vendor/gqlitedb/src/value/contains.rs +47 -0
  63. data/ext/gqliterb/vendor/gqlitedb/src/value/value_map.rs +298 -0
  64. data/ext/gqliterb/vendor/gqlitedb/src/value.rs +609 -0
  65. data/ext/gqliterb/vendor/gqlitedb/src/value_table.rs +610 -0
  66. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/call_stats.sql +22 -0
  67. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_count_for_node.sql +3 -0
  68. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_create.sql +6 -0
  69. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete.sql +1 -0
  70. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete_by_nodes.sql +2 -0
  71. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_select.sql +139 -0
  72. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_update.sql +4 -0
  73. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_create.sql +16 -0
  74. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_delete.sql +3 -0
  75. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_create_table.sql +1 -0
  76. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_get.sql +1 -0
  77. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_set.sql +1 -0
  78. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_create.sql +1 -0
  79. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_delete.sql +1 -0
  80. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_select.sql +42 -0
  81. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_update.sql +4 -0
  82. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/table_exists.sql +5 -0
  83. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_from_1_01.sql +2 -0
  84. data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_graph_from_1_01.sql +65 -0
  85. metadata +82 -2
@@ -0,0 +1,439 @@
1
+ #[cfg(feature = "_pgql")]
2
+ pub(crate) mod pgql;
3
+ #[cfg(feature = "redb")]
4
+ pub(crate) mod redb;
5
+ #[cfg(feature = "sqlite")]
6
+ pub(crate) mod sqlite;
7
+
8
+ #[cfg(feature = "_pgql")]
9
+ pub(crate) use pgql::Store;
10
+
11
+ use crate::prelude::*;
12
+
13
+ // ____ _ _ _ _ _
14
+ // / ___|| |_ __ _| |_(_)___| |_(_) ___ ___
15
+ // \___ \| __/ _` | __| / __| __| |/ __/ __|
16
+ // ___) | || (_| | |_| \__ \ |_| | (__\__ \
17
+ // |____/ \__\__,_|\__|_|___/\__|_|\___|___/
18
+
19
+ pub(crate) struct Statistics
20
+ {
21
+ pub nodes_count: usize,
22
+ pub edges_count: usize,
23
+ pub labels_nodes_count: usize,
24
+ pub properties_count: usize,
25
+ }
26
+
27
+ pub(crate) trait ReadTransaction
28
+ {
29
+ fn discard(self) -> Result<()>;
30
+ }
31
+
32
+ pub(crate) trait WriteTransaction: ReadTransaction
33
+ {
34
+ // Commit.
35
+ fn commit(self) -> Result<()>;
36
+ }
37
+
38
+ /// Box that holds a Read or a Write transaction for a store.
39
+ pub(crate) enum TransactionBox<TRead, TWrite>
40
+ where
41
+ TRead: ReadTransaction,
42
+ TWrite: WriteTransaction,
43
+ {
44
+ Read(TRead),
45
+ Write(TWrite),
46
+ }
47
+
48
+ impl<TRead, TWrite> TransactionBox<TRead, TWrite>
49
+ where
50
+ TRead: ReadTransaction,
51
+ TWrite: WriteTransaction,
52
+ {
53
+ pub(crate) fn from_read(read: TRead) -> Self
54
+ {
55
+ Self::Read(read)
56
+ }
57
+ pub(crate) fn from_write(write: TWrite) -> Self
58
+ {
59
+ Self::Write(write)
60
+ }
61
+ pub(crate) fn try_into_write(&mut self) -> Result<&mut TWrite>
62
+ {
63
+ match self
64
+ {
65
+ Self::Read(_) => Err(InternalError::NotWriteTransaction.into()),
66
+ Self::Write(write) => Ok(write),
67
+ }
68
+ }
69
+ }
70
+
71
+ /// Trait that represent a box that can contain a read or write transaction for a store.
72
+ pub(crate) trait TransactionBoxable
73
+ {
74
+ type ReadTransaction: ReadTransaction;
75
+ type WriteTransaction: WriteTransaction;
76
+
77
+ fn close(self) -> Result<()>;
78
+ }
79
+
80
+ impl<TRead, TWrite> TransactionBoxable for TransactionBox<TRead, TWrite>
81
+ where
82
+ TRead: ReadTransaction,
83
+ TWrite: WriteTransaction,
84
+ {
85
+ type ReadTransaction = TRead;
86
+ type WriteTransaction = TWrite;
87
+
88
+ fn close(self) -> Result<()>
89
+ {
90
+ match self
91
+ {
92
+ Self::Read(read) => read.discard(),
93
+ Self::Write(write) => write.commit(),
94
+ }
95
+ }
96
+ }
97
+
98
+ // ____ _
99
+ // / ___|| |_ ___ _ __ ___
100
+ // \___ \| __/ _ \| '__/ _ \
101
+ // ___) | || (_) | | | __/
102
+ // |____/ \__\___/|_| \___|
103
+
104
+ pub(crate) trait Store
105
+ {
106
+ type TransactionBox: TransactionBoxable;
107
+ fn begin_read(&self) -> Result<Self::TransactionBox>;
108
+ fn begin_write(&self) -> Result<Self::TransactionBox>;
109
+ /// List the graphs
110
+ fn graphs_list(&self, transaction: &mut Self::TransactionBox) -> Result<Vec<String>>;
111
+ /// Create a new graph
112
+ fn create_graph(
113
+ &self,
114
+ transaction: &mut Self::TransactionBox,
115
+ name: &String,
116
+ ignore_if_exists: bool,
117
+ ) -> Result<()>;
118
+ /// Delete a graph
119
+ fn drop_graph(
120
+ &self,
121
+ transaction: &mut Self::TransactionBox,
122
+ name: &String,
123
+ if_exists: bool,
124
+ ) -> Result<()>;
125
+ /// Create nodes and add them to a graph
126
+ fn create_nodes<'a, T: Iterator<Item = &'a crate::graph::Node>>(
127
+ &self,
128
+ transaction: &mut Self::TransactionBox,
129
+ graph_name: &String,
130
+ nodes_iter: T,
131
+ ) -> Result<()>;
132
+ /// Create nodes and add them to a graph
133
+ fn update_node(
134
+ &self,
135
+ transaction: &mut Self::TransactionBox,
136
+ graph_name: &String,
137
+ node: &graph::Node,
138
+ ) -> Result<()>;
139
+ /// Delete nodes according to a given query
140
+ fn delete_nodes(
141
+ &self,
142
+ transaction: &mut Self::TransactionBox,
143
+ graph_name: &String,
144
+ query: SelectNodeQuery,
145
+ detach: bool,
146
+ ) -> Result<()>;
147
+ /// Select nodes according to a given query
148
+ fn select_nodes(
149
+ &self,
150
+ transaction: &mut Self::TransactionBox,
151
+ graph_name: &String,
152
+ query: SelectNodeQuery,
153
+ ) -> Result<Vec<crate::graph::Node>>;
154
+ /// Add edge
155
+ fn create_edges<'a, T: Iterator<Item = &'a crate::graph::Edge>>(
156
+ &self,
157
+ transaction: &mut Self::TransactionBox,
158
+ graph_name: &String,
159
+ edges_iter: T,
160
+ ) -> Result<()>;
161
+ fn update_edge(
162
+ &self,
163
+ transaction: &mut Self::TransactionBox,
164
+ graph_name: &String,
165
+ edge: &graph::Edge,
166
+ ) -> Result<()>;
167
+ /// Delete nodes according to a given query
168
+ fn delete_edges(
169
+ &self,
170
+ transaction: &mut Self::TransactionBox,
171
+ graph_name: &String,
172
+ query: SelectEdgeQuery,
173
+ directivity: graph::EdgeDirectivity,
174
+ ) -> Result<()>;
175
+ /// Select edges
176
+ fn select_edges(
177
+ &self,
178
+ transaction: &mut Self::TransactionBox,
179
+ graph_name: &String,
180
+ query: SelectEdgeQuery,
181
+ directivity: graph::EdgeDirectivity,
182
+ ) -> Result<Vec<EdgeResult>>;
183
+ /// Compute store statistics
184
+ fn compute_statistics(&self, transaction: &mut Self::TransactionBox) -> Result<Statistics>;
185
+ }
186
+
187
+ // _____ _ ____ _ _
188
+ // | ____|__| | __ _ ___| _ \ ___ ___ _ _| | |_
189
+ // | _| / _` |/ _` |/ _ \ |_) / _ \/ __| | | | | __|
190
+ // | |__| (_| | (_| | __/ _ < __/\__ \ |_| | | |_
191
+ // |_____\__,_|\__, |\___|_| \_\___||___/\__,_|_|\__|
192
+ // |___/
193
+
194
+ pub(crate) struct EdgeResult
195
+ {
196
+ pub(crate) edge: graph::Edge,
197
+ pub(crate) reversed: bool,
198
+ }
199
+
200
+ // ____ _ _ _ _ _ ___
201
+ // / ___| ___| | ___ ___| |_| \ | | ___ __| | ___ / _ \ _ _ ___ _ __ _ _
202
+ // \___ \ / _ \ |/ _ \/ __| __| \| |/ _ \ / _` |/ _ \ | | | | | |/ _ \ '__| | | |
203
+ // ___) | __/ | __/ (__| |_| |\ | (_) | (_| | __/ |_| | |_| | __/ | | |_| |
204
+ // |____/ \___|_|\___|\___|\__|_| \_|\___/ \__,_|\___|\__\_\\__,_|\___|_| \__, |
205
+ // |___/
206
+
207
+ #[derive(Debug, Clone)]
208
+ pub(crate) struct SelectNodeQuery
209
+ {
210
+ keys: Option<Vec<graph::Key>>,
211
+ labels: Option<Vec<String>>,
212
+ properties: Option<value::ValueMap>,
213
+ select_all: bool,
214
+ }
215
+
216
+ impl SelectNodeQuery
217
+ {
218
+ fn is_select_all(&self) -> bool
219
+ {
220
+ self.select_all
221
+ }
222
+ fn is_select_none(&self) -> bool
223
+ {
224
+ self.keys.is_none() && self.labels.is_none() && self.properties.is_none() && !self.select_all
225
+ }
226
+ pub(crate) fn is_select_only_keys(&self) -> bool
227
+ {
228
+ self.labels.is_none() && self.properties.is_none() && !self.select_all
229
+ }
230
+ pub(crate) fn select_all() -> Self
231
+ {
232
+ Self {
233
+ keys: None,
234
+ labels: None,
235
+ properties: None,
236
+ select_all: true,
237
+ }
238
+ }
239
+ pub(crate) fn select_none() -> Self
240
+ {
241
+ Self {
242
+ keys: None,
243
+ labels: None,
244
+ properties: None,
245
+ select_all: false,
246
+ }
247
+ }
248
+ #[allow(unused)]
249
+ pub(crate) fn select_keys(keys: impl Into<Vec<graph::Key>>) -> Self
250
+ {
251
+ Self {
252
+ keys: Some(keys.into()),
253
+ labels: None,
254
+ properties: None,
255
+ select_all: false,
256
+ }
257
+ }
258
+ #[allow(dead_code)]
259
+ pub(crate) fn select_labels(labels: impl Into<Vec<String>>) -> Self
260
+ {
261
+ Self {
262
+ keys: None,
263
+ labels: Some(labels.into()),
264
+ properties: None,
265
+ select_all: false,
266
+ }
267
+ }
268
+ pub(crate) fn select_labels_properties(
269
+ labels: impl Into<Vec<String>>,
270
+ properties: value::ValueMap,
271
+ ) -> Self
272
+ {
273
+ Self {
274
+ keys: None,
275
+ labels: Some(labels.into()),
276
+ properties: Some(properties),
277
+ select_all: false,
278
+ }
279
+ }
280
+ pub(crate) fn is_match(&self, node: &graph::Node) -> bool
281
+ {
282
+ if self.select_all
283
+ {
284
+ return true;
285
+ }
286
+ if let Some(keys) = &self.keys
287
+ {
288
+ if !keys.iter().any(|x| node.key == *x)
289
+ {
290
+ return false;
291
+ }
292
+ }
293
+ if let Some(labels) = &self.labels
294
+ {
295
+ if !labels.iter().all(|x| node.labels.contains(x))
296
+ {
297
+ return false;
298
+ }
299
+ }
300
+ if let Some(properties) = &self.properties
301
+ {
302
+ if !properties
303
+ .iter()
304
+ .all(|(k, v)| node.properties.get(k) == Some(v))
305
+ {
306
+ return false;
307
+ }
308
+ }
309
+ return true;
310
+ }
311
+ }
312
+
313
+ // ____ _ _ _____ _ ___
314
+ // / ___| ___| | ___ ___| |_| ____|__| | __ _ ___ / _ \ _ _ ___ _ __ _ _
315
+ // \___ \ / _ \ |/ _ \/ __| __| _| / _` |/ _` |/ _ \ | | | | | |/ _ \ '__| | | |
316
+ // ___) | __/ | __/ (__| |_| |__| (_| | (_| | __/ |_| | |_| | __/ | | |_| |
317
+ // |____/ \___|_|\___|\___|\__|_____\__,_|\__, |\___|\__\_\\__,_|\___|_| \__, |
318
+ // |___/ |___/
319
+
320
+ #[derive(Debug, Clone)]
321
+ pub(crate) struct SelectEdgeQuery
322
+ {
323
+ keys: Option<Vec<graph::Key>>,
324
+ labels: Option<Vec<String>>,
325
+ properties: Option<value::ValueMap>,
326
+ source: SelectNodeQuery,
327
+ destination: SelectNodeQuery,
328
+ }
329
+
330
+ impl SelectEdgeQuery
331
+ {
332
+ #[allow(dead_code)]
333
+ pub(crate) fn is_select_only_keys(&self) -> bool
334
+ {
335
+ self.keys.is_some()
336
+ && self.labels.is_none()
337
+ && self.properties.is_none()
338
+ && self.source.select_all
339
+ && self.destination.select_all
340
+ }
341
+
342
+ pub(crate) fn select_all() -> Self
343
+ {
344
+ Self {
345
+ keys: None,
346
+ labels: None,
347
+ properties: None,
348
+ source: SelectNodeQuery::select_all(),
349
+ destination: SelectNodeQuery::select_all(),
350
+ }
351
+ }
352
+ pub(crate) fn select_none() -> Self
353
+ {
354
+ Self {
355
+ keys: None,
356
+ labels: None,
357
+ properties: None,
358
+ source: SelectNodeQuery::select_none(),
359
+ destination: SelectNodeQuery::select_none(),
360
+ }
361
+ }
362
+ #[allow(unused)]
363
+ pub(crate) fn select_keys(keys: impl Into<Vec<graph::Key>>) -> Self
364
+ {
365
+ Self {
366
+ keys: Some(keys.into()),
367
+ labels: None,
368
+ properties: None,
369
+ source: SelectNodeQuery::select_all(),
370
+ destination: SelectNodeQuery::select_all(),
371
+ }
372
+ }
373
+ pub(crate) fn select_source_keys(source_query: SelectNodeQuery) -> Self
374
+ {
375
+ Self {
376
+ keys: None,
377
+ labels: None,
378
+ properties: None,
379
+ source: source_query,
380
+ destination: SelectNodeQuery::select_all(),
381
+ }
382
+ }
383
+ pub(crate) fn select_source_destination_keys(
384
+ source_query: SelectNodeQuery,
385
+ keys: impl Into<Vec<graph::Key>>,
386
+ destination_query: SelectNodeQuery,
387
+ ) -> Self
388
+ {
389
+ Self {
390
+ keys: Some(keys.into()),
391
+ labels: None,
392
+ properties: None,
393
+ source: source_query,
394
+ destination: destination_query,
395
+ }
396
+ }
397
+ pub(crate) fn select_source_destination_labels_properties(
398
+ source_query: SelectNodeQuery,
399
+ labels: impl Into<Vec<String>>,
400
+ properties: value::ValueMap,
401
+ destination_query: SelectNodeQuery,
402
+ ) -> Self
403
+ {
404
+ Self {
405
+ keys: None,
406
+ labels: Some(labels.into()),
407
+ properties: Some(properties),
408
+ source: source_query,
409
+ destination: destination_query,
410
+ }
411
+ }
412
+ pub(crate) fn is_match(&self, edge: &graph::Edge) -> bool
413
+ {
414
+ if let Some(keys) = &self.keys
415
+ {
416
+ if !keys.iter().any(|x| edge.key == *x)
417
+ {
418
+ return false;
419
+ }
420
+ }
421
+ if let Some(labels) = &self.labels
422
+ {
423
+ if !labels.iter().all(|x| edge.labels.contains(x))
424
+ {
425
+ return false;
426
+ }
427
+ }
428
+ if let Some(properties) = &self.properties
429
+ {
430
+ if !properties
431
+ .iter()
432
+ .all(|(k, v)| edge.properties.get(k) == Some(v))
433
+ {
434
+ return false;
435
+ }
436
+ }
437
+ return self.source.is_match(&edge.source) && self.destination.is_match(&edge.destination);
438
+ }
439
+ }
@@ -0,0 +1,92 @@
1
+ use crate::{
2
+ compiler::compile,
3
+ interpreter::Program,
4
+ prelude::*,
5
+ tests::templates::{ast, programs},
6
+ };
7
+
8
+ fn compare_program(actual: Program, expected: Program)
9
+ {
10
+ assert_eq!(format!("{:?}", actual), format!("{:?}", expected));
11
+ }
12
+
13
+ #[test]
14
+ fn test_compile_simple_create_node()
15
+ {
16
+ let function_manager = functions::Manager::new();
17
+
18
+ let program = compile(&function_manager, ast::simple_create_node()).unwrap();
19
+ compare_program(program, programs::simple_create())
20
+ }
21
+
22
+ #[test]
23
+ fn test_compile_create_named_node()
24
+ {
25
+ let function_manager = functions::Manager::new();
26
+
27
+ let program = compile(&function_manager, ast::create_named_node()).unwrap();
28
+ compare_program(program, programs::create_named_node())
29
+ }
30
+
31
+ #[test]
32
+ fn test_compile_create_named_node_double_return()
33
+ {
34
+ let function_manager = functions::Manager::new();
35
+
36
+ let program = compile(&function_manager, ast::create_named_node_double_return()).unwrap();
37
+ compare_program(program, programs::create_named_node_double_return())
38
+ }
39
+
40
+ #[test]
41
+ fn test_compile_double_with_return()
42
+ {
43
+ let function_manager = functions::Manager::new();
44
+
45
+ let program = compile(&function_manager, ast::double_with_return()).unwrap();
46
+ compare_program(program, programs::double_with_return())
47
+ }
48
+
49
+ #[test]
50
+ fn test_compile_unwind()
51
+ {
52
+ let function_manager = functions::Manager::new();
53
+
54
+ let program = compile(&function_manager, ast::unwind()).unwrap();
55
+ compare_program(program, programs::unwind())
56
+ }
57
+
58
+ #[test]
59
+ fn test_compile_match_loop()
60
+ {
61
+ let function_manager = functions::Manager::new();
62
+
63
+ let program = compile(&function_manager, ast::match_loop()).unwrap();
64
+ compare_program(program, programs::match_loop())
65
+ }
66
+
67
+ #[test]
68
+ fn test_compile_optional_match()
69
+ {
70
+ let function_manager = functions::Manager::new();
71
+
72
+ let program = compile(&function_manager, ast::optional_match()).unwrap();
73
+ compare_program(program, programs::optional_match())
74
+ }
75
+
76
+ #[test]
77
+ fn test_compile_match_count()
78
+ {
79
+ let function_manager = functions::Manager::new();
80
+
81
+ let program = compile(&function_manager, ast::match_count()).unwrap();
82
+ compare_program(program, programs::match_count(&function_manager))
83
+ }
84
+
85
+ #[test]
86
+ fn test_compile_aggregation()
87
+ {
88
+ let function_manager = functions::Manager::new();
89
+
90
+ let program = compile(&function_manager, ast::aggregation()).unwrap();
91
+ compare_program(program, programs::aggregation(&function_manager))
92
+ }