Skip to content

Commit

Permalink
Tests for run_query_iter()
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaq committed Aug 14, 2024
1 parent a09c779 commit 0bf29dd
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/machine/lib_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,45 @@ mod tests {

assert_eq!(output, Ok(QueryResolution::False));
}

#[test]
#[cfg_attr(miri, ignore)]
fn query_iterator_determinism() {
let mut machine = Machine::new_lib();

{
let mut iterator = machine.run_query_iter("X = 1.".into());

iterator.next();
assert_eq!(iterator.next(), None);
}

{
let mut iterator = machine.run_query_iter("X = 1 ; false.".into());

iterator.next();

assert_eq!(iterator.next(), Some(Ok(QueryResolutionLine::False)));
assert_eq!(iterator.next(), None);
}

{
let mut iterator = machine.run_query_iter("false.".into());

assert_eq!(iterator.next(), Some(Ok(QueryResolutionLine::False)));
assert_eq!(iterator.next(), None);
}
}

#[test]
#[cfg_attr(miri, ignore)]
fn query_iterator_backtracking_when_no_variables() {
let mut machine = Machine::new_lib();

let mut iterator = machine.run_query_iter("true;false.".into());

assert_eq!(iterator.next(), Some(Ok(QueryResolutionLine::True)));
assert_eq!(iterator.next(), Some(Ok(QueryResolutionLine::False)));
assert_eq!(iterator.next(), None);
}
}

0 comments on commit 0bf29dd

Please sign in to comment.