Drops commented tests

pull/10/head
Tpt 6 years ago
parent 257cd08846
commit b733435203
  1. 385
      src/sparql/algebra.rs

@ -1342,388 +1342,3 @@ impl fmt::Display for Query {
} }
} }
} }
/* TODO: tests
/// Implementation of https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlAlgebraExamples
#[test]
fn test_sparql_algebra_examples() {
assert_eq!(
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("o")
)).try_into(),
Ok(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("o"),
)]))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)),
]).try_into(),
Ok(GraphPattern::BGP(vec![
PathPattern::new(Variable::new("s"), Variable::new("p1"), Variable::new("v1")),
PathPattern::new(Variable::new("s"), Variable::new("p2"), Variable::new("v2")),
]))
);
assert_eq!(
ast::GraphPattern::UnionPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)),
]).try_into(),
Ok(GraphPattern::Union(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
))
);
assert_eq!(
ast::GraphPattern::UnionPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
)),
]).try_into(),
Ok(GraphPattern::Union(
Box::new(GraphPattern::Union(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
)),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
)])),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
),
))),
]).try_into(),
Ok(GraphPattern::LeftJoin(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
ast::Expression::ConstantExpression(Literal::from(true).into()),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
),
))),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
),
))),
]).try_into(),
Ok(GraphPattern::LeftJoin(
Box::new(GraphPattern::LeftJoin(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
ast::Expression::ConstantExpression(Literal::from(true).into()),
)),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
)])),
ast::Expression::ConstantExpression(Literal::from(true).into()),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)),
ast::GraphPattern::FilterPattern(ast::Expression::LowerExpression(
Box::new(ast::Expression::ConstantExpression(
Variable::new("v1").into(),
)),
Box::new(ast::Expression::ConstantExpression(Literal::from(3).into())),
)),
]))),
]).try_into(),
Ok(GraphPattern::LeftJoin(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
ast::Expression::LowerExpression(
Box::new(ast::Expression::ConstantExpression(
Variable::new("v1").into(),
)),
Box::new(ast::Expression::ConstantExpression(Literal::from(3).into())),
),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::UnionPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)),
]),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
),
))),
]).try_into(),
Ok(GraphPattern::LeftJoin(
Box::new(GraphPattern::Union(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
)),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p3"),
Variable::new("v3"),
)])),
ast::Expression::ConstantExpression(Literal::from(true).into()),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)),
ast::GraphPattern::FilterPattern(ast::Expression::LowerExpression(
Box::new(ast::Expression::ConstantExpression(
Variable::new("v1").into(),
)),
Box::new(ast::Expression::ConstantExpression(Literal::from(3).into())),
)),
ast::GraphPattern::OptionalPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
),
))),
]).try_into(),
Ok(GraphPattern::Filter(
ast::Expression::LowerExpression(
Box::new(ast::Expression::ConstantExpression(
Variable::new("v1").into(),
)),
Box::new(ast::Expression::ConstantExpression(Literal::from(3).into())),
),
Box::new(GraphPattern::LeftJoin(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v1"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p2"),
Variable::new("v2"),
)])),
ast::Expression::ConstantExpression(Literal::from(true).into()),
)),
))
);
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("v"),
)),
ast::GraphPattern::BindPattern(
ast::Expression::MulExpression(
Box::new(ast::Expression::ConstantExpression(Literal::from(2).into())),
Box::new(ast::Expression::ConstantExpression(
Variable::new("v").into(),
)),
),
Variable::new("v2"),
),
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v2"),
)),
]).try_into(),
Ok(GraphPattern::Join(
Box::new(GraphPattern::Extend(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("v"),
)])),
Variable::new("v2"),
ast::Expression::MulExpression(
Box::new(ast::Expression::ConstantExpression(Literal::from(2).into())),
Box::new(ast::Expression::ConstantExpression(
Variable::new("v").into(),
)),
),
)),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v2"),
)])),
))
);
//TODO: { ?s :p ?v . {} BIND (2*?v AS ?v2) }
assert_eq!(
ast::GraphPattern::GroupPattern(vec![
ast::GraphPattern::PathPattern(ast::PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("v"),
)),
ast::GraphPattern::MinusPattern(Box::new(ast::GraphPattern::PathPattern(
ast::PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v2"),
),
))),
]).try_into(),
Ok(GraphPattern::Minus(
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p"),
Variable::new("v"),
)])),
Box::new(GraphPattern::BGP(vec![PathPattern::new(
Variable::new("s"),
Variable::new("p1"),
Variable::new("v2"),
)])),
))
);
//TODO { ?s :p ?o . {SELECT DISTINCT ?o {?o ?p ?z} } }
}*/

Loading…
Cancel
Save