()
| 271 | |
| 272 | #[test] |
| 273 | fn sum() { |
| 274 | let (e, amount) = (1, 2); |
| 275 | let data = vec![ |
| 276 | TxData::add(1, ":amount", Number(5)), |
| 277 | TxData::add(2, ":amount", Number(10)), |
| 278 | TxData::add(2, ":amount", Number(10)), |
| 279 | TxData::add(1, ":amount", Number(2)), |
| 280 | TxData::add(1, ":amount", Number(4)), |
| 281 | TxData::add(1, ":amount", Number(6)), |
| 282 | ]; |
| 283 | |
| 284 | run_cases(vec![ |
| 285 | Case { |
| 286 | description: "[:find (sum ?amount) :with ?e :where [?e :amount ?amount]]", |
| 287 | plan: Plan::Aggregate(Aggregate { |
| 288 | variables: vec![amount], |
| 289 | plan: Box::new(Plan::Project(Project { |
| 290 | variables: vec![amount], |
| 291 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 292 | })), |
| 293 | aggregation_fns: vec![AggregationFn::SUM], |
| 294 | key_variables: vec![], |
| 295 | aggregation_variables: vec![amount], |
| 296 | with_variables: vec![], |
| 297 | }), |
| 298 | transactions: vec![data.clone()], |
| 299 | expectations: vec![vec![(vec![Number(37)], 0, 1)]], |
| 300 | // set-semantics |
| 301 | // expectations: vec![ |
| 302 | // vec![(vec![Number(27)], 0, 1)], |
| 303 | // ], |
| 304 | }, |
| 305 | Case { |
| 306 | description: "[:find ?e (sum ?amount) :where [?e :amount ?amount]]", |
| 307 | plan: Plan::Aggregate(Aggregate { |
| 308 | variables: vec![e, amount], |
| 309 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 310 | aggregation_fns: vec![AggregationFn::SUM], |
| 311 | key_variables: vec![e], |
| 312 | aggregation_variables: vec![amount], |
| 313 | with_variables: vec![], |
| 314 | }), |
| 315 | transactions: vec![data.clone()], |
| 316 | expectations: vec![vec![ |
| 317 | (vec![Eid(1), Number(17)], 0, 1), |
| 318 | (vec![Eid(2), Number(20)], 0, 1), |
| 319 | ]], |
| 320 | // set-semantics |
| 321 | // expectations: vec![ |
| 322 | // vec![ |
| 323 | // (vec![Eid(1), Number(17)], 0, 1), |
| 324 | // (vec![Eid(2), Number(10)], 0, 1), |
| 325 | // ], |
| 326 | // ], |
| 327 | }, |
| 328 | ]); |
| 329 | } |
| 330 |
nothing calls this directly
no test coverage detected