-
Notifications
You must be signed in to change notification settings - Fork 9
Adding support for Reals
#50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| use easy_smt::{ContextBuilder, Response}; | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_real_numbers() { | ||||||
| let mut ctx = ContextBuilder::new() | ||||||
| .solver("z3") | ||||||
| .solver_args(["-smt2", "-in"]) | ||||||
| .build() | ||||||
| .unwrap(); | ||||||
|
|
||||||
| let x = ctx.declare_const("x", ctx.real_sort()).unwrap(); | ||||||
| // x == 2.0 | ||||||
| ctx.assert(ctx.eq(x, ctx.decimal(2.0))).unwrap(); | ||||||
| assert_eq!(ctx.check().unwrap(), Response::Sat); | ||||||
| let solution = ctx.get_value(vec![x]).unwrap(); | ||||||
| let sol = ctx.get_f64(solution[0].1).unwrap(); | ||||||
| // Z3 returns `2.0` | ||||||
| assert!(sol == 2.0, "Expected solution to be 2.5, got {}", sol); | ||||||
|
||||||
| assert!(sol == 2.0, "Expected solution to be 2.5, got {}", sol); | |
| assert!(sol == 2.0, "Expected solution to be 2.0, got {}", sol); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that you caught that, I never properly updated the messages after using them for debugging.
Since I already used assert_eq! for checking the response, I changed all assertions assert_eq! in 4390749
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert!(sol == -2.0, "Expected solution to be 2.5, got {}", sol); | |
| assert!(sol == -2.0, "Expected solution to be -2.0, got {}", sol); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that you caught that, I never properly updated the messages after using them for debugging.
Since I already used assert_eq! for checking the response, I changed all assertions assert_eq! in 4390749
Uh oh!
There was an error while loading. Please reload this page.