Compare commits
2 commits
master
...
rnewman/ty
Author | SHA1 | Date | |
---|---|---|---|
|
53951ff44c | ||
|
340b613de6 |
1 changed files with 51 additions and 0 deletions
|
@ -85,11 +85,13 @@ impl ConjoiningClauses {
|
|||
bail!(ErrorKind::InvalidArgument(predicate.operator.clone(), "numeric or instant", 0));
|
||||
}
|
||||
|
||||
println!("Left types: {:?}.", left_types);
|
||||
let mut right_types = self.potential_types(schema, &right)?
|
||||
.intersection(&supported_types);
|
||||
if right_types.is_empty() {
|
||||
bail!(ErrorKind::InvalidArgument(predicate.operator.clone(), "numeric or instant", 1));
|
||||
}
|
||||
println!("Right types: {:?}.", right_types);
|
||||
|
||||
// We would like to allow longs to compare to doubles.
|
||||
// Do this by expanding the type sets. `resolve_numeric_argument` will
|
||||
|
@ -233,6 +235,55 @@ mod testing {
|
|||
}.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Apply two patterns: an unconstrained pattern to establish a value var,
|
||||
/// and a predicate to constrain the val to numeric types.
|
||||
/// The purpose of this test is to make sure that we also _constrain_ the var to its
|
||||
/// required types, not only _deduce_ the types it must be.
|
||||
fn test_apply_numeric_range_unconstrained_var() {
|
||||
let mut cc = ConjoiningClauses::default();
|
||||
let mut schema = Schema::default();
|
||||
|
||||
associate_ident(&mut schema, NamespacedKeyword::new("foo", "bar"), 99);
|
||||
associate_ident(&mut schema, NamespacedKeyword::new("foo", "roz"), 98);
|
||||
add_attribute(&mut schema, 99, Attribute {
|
||||
value_type: ValueType::Long,
|
||||
..Default::default()
|
||||
});
|
||||
add_attribute(&mut schema, 98, Attribute {
|
||||
value_type: ValueType::String,
|
||||
unique: Some(Unique::Identity),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let x = Variable::from_valid_name("?x");
|
||||
let y = Variable::from_valid_name("?y");
|
||||
cc.apply_pattern(&schema, Pattern {
|
||||
source: None,
|
||||
entity: PatternNonValuePlace::Variable(x.clone()),
|
||||
attribute: PatternNonValuePlace::Placeholder,
|
||||
value: PatternValuePlace::Variable(y.clone()),
|
||||
tx: PatternNonValuePlace::Placeholder,
|
||||
});
|
||||
assert!(!cc.is_known_empty());
|
||||
|
||||
let op = PlainSymbol::new(">=");
|
||||
let comp = Inequality::from_datalog_operator(op.plain_name()).unwrap();
|
||||
assert!(cc.apply_inequality(&schema, comp, Predicate {
|
||||
operator: op,
|
||||
args: vec![
|
||||
FnArg::Variable(Variable::from_valid_name("?y")), FnArg::EntidOrInteger(10),
|
||||
]}).is_ok());
|
||||
|
||||
assert!(!cc.is_known_empty());
|
||||
|
||||
// Finally, expand column bindings to get the overlaps for ?x.
|
||||
cc.expand_column_bindings();
|
||||
|
||||
assert!(!cc.is_known_empty());
|
||||
println!("CC: {:?}", cc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Apply three patterns: an unbound pattern to establish a value var,
|
||||
/// a predicate to constrain the val to numeric types, and a third pattern to conflict with the
|
||||
|
|
Loading…
Reference in a new issue