Addressed Review comments rnewman.

* Use better grammar in comments.
* Test for which error returned from `not-join` validation.
This commit is contained in:
Emily Toop 2017-04-07 18:26:36 +01:00
parent 649eff08a5
commit daaff7074d

View file

@ -82,7 +82,7 @@ pub fn validate_not_join(not_join: &NotJoin) -> Result<()> {
Ok(()) Ok(())
}, },
UnifyVars::Explicit(ref vars) => { UnifyVars::Explicit(ref vars) => {
// The joined vars must each appear somewhere in the clauses mentioned variables. // The joined vars must each appear somewhere in the clauses' mentioned variables.
let var_set: BTreeSet<Variable> = vars.iter().cloned().collect(); let var_set: BTreeSet<Variable> = vars.iter().cloned().collect();
if !var_set.is_subset(&not_join.collect_mentioned_variables()) { if !var_set.is_subset(&not_join.collect_mentioned_variables()) {
bail!(ErrorKind::NonMatchingVariablesInNotClause); bail!(ErrorKind::NonMatchingVariablesInNotClause);
@ -114,6 +114,11 @@ mod tests {
use clauses::ident; use clauses::ident;
use errors::{
Error,
ErrorKind,
};
use super::{ use super::{
validate_not_join, validate_not_join,
validate_or_join, validate_or_join,
@ -367,7 +372,13 @@ mod tests {
assert_eq!(None, nots.next()); assert_eq!(None, nots.next());
match clause { match clause {
WhereClause::NotJoin(not_join) => assert!(validate_not_join(&not_join).is_err()), WhereClause::NotJoin(not_join) => { let result = validate_not_join(&not_join);
assert!(result.is_err());
match result.err().unwrap() {
Error(ErrorKind::NonMatchingVariablesInNotClause, _) => { assert!(true); },
x => panic!("expected NonMatchingVariablesInNotClause error, got {:?}", x),
}
},
_ => panic!(), _ => panic!(),
} }
} }