()
| 330 | |
| 331 | #[test] |
| 332 | fn avg() { |
| 333 | let (e, amount) = (1, 2); |
| 334 | let data = vec![ |
| 335 | TxData::add(1, ":amount", Number(5)), |
| 336 | TxData::add(2, ":amount", Number(10)), |
| 337 | TxData::add(2, ":amount", Number(10)), |
| 338 | TxData::add(1, ":amount", Number(2)), |
| 339 | TxData::add(1, ":amount", Number(4)), |
| 340 | TxData::add(1, ":amount", Number(6)), |
| 341 | ]; |
| 342 | |
| 343 | run_cases(vec![ |
| 344 | Case { |
| 345 | description: "[:find (avg ?amount) :where [?e :amount ?amount]]", |
| 346 | plan: Plan::Aggregate(Aggregate { |
| 347 | variables: vec![amount], |
| 348 | plan: Box::new(Plan::Project(Project { |
| 349 | variables: vec![amount], |
| 350 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 351 | })), |
| 352 | aggregation_fns: vec![AggregationFn::AVG], |
| 353 | key_variables: vec![], |
| 354 | aggregation_variables: vec![amount], |
| 355 | with_variables: vec![], |
| 356 | }), |
| 357 | transactions: vec![data.clone()], |
| 358 | expectations: vec![vec![(vec![Rational32(Ratio::new(37, 6))], 0, 1)]], |
| 359 | // set-semantics |
| 360 | // expectations: vec![ |
| 361 | // vec![(vec![Rational32(Ratio::new(27, 5))], 0, 1)], |
| 362 | // ], |
| 363 | }, |
| 364 | Case { |
| 365 | description: "[:find ?e (avg ?amount) :where [?e :amount ?amount]]", |
| 366 | plan: Plan::Aggregate(Aggregate { |
| 367 | variables: vec![e, amount], |
| 368 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 369 | aggregation_fns: vec![AggregationFn::AVG], |
| 370 | key_variables: vec![e], |
| 371 | aggregation_variables: vec![amount], |
| 372 | with_variables: vec![], |
| 373 | }), |
| 374 | transactions: vec![data.clone()], |
| 375 | expectations: vec![vec![ |
| 376 | (vec![Eid(1), Rational32(Ratio::new(17, 4))], 0, 1), |
| 377 | (vec![Eid(2), Rational32(Ratio::new(20, 2))], 0, 1), |
| 378 | ]], |
| 379 | // set-semantics |
| 380 | // expectations: vec![ |
| 381 | // vec![ |
| 382 | // (vec![Eid(1), Rational32(Ratio::new(17, 4))], 0, 1), |
| 383 | // (vec![Eid(2), Rational32(Ratio::new(10, 1))], 0, 1), |
| 384 | // ], |
| 385 | // ], |
| 386 | }, |
| 387 | ]); |
| 388 | } |
| 389 |
nothing calls this directly
no test coverage detected