Skip to content

Commit

Permalink
add test that only compiles with pr#324
Browse files Browse the repository at this point in the history
  • Loading branch information
sgpthomas committed Nov 26, 2024
1 parent 7f38037 commit beae746
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions z3/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1973,3 +1973,32 @@ fn test_atleast() {
assert!(matches!(solver.check(), SatResult::Unsat));
solver.pop(1);
}

#[test]
fn test_model_iter() {
let cfg = Config::new();
let ctx = Context::new(&cfg);
let solver = Solver::new(&ctx);

let a = ast::Int::new_const(&ctx, "a");
let two = ast::Int::from_u64(&ctx, 2);
solver.assert(&a._eq(&two));
solver.check();

let model = solver.get_model().unwrap();

// consume a model and return some asts constructed from it
// this didn't compile before pr#324
fn consume_model(model: Model) -> Vec<ast::Dynamic> {
let mut asts = vec![];
for func in &model {
asts.push(func.apply(&[]));
}
asts
}

assert_eq!(
consume_model(model),
vec![ast::Dynamic::new_const(&ctx, "a", &Sort::int(&ctx))]
);
}

0 comments on commit beae746

Please sign in to comment.