Skip to content

Commit 9c96cde

Browse files
committed
Convert trait predicate tests to Rust syntax
Now that named struct-field resolution is on main (#118), flip the trait predicate tests (annot_preds_trait, annot_preds_trait_multi; pass and fail) from raw SMT-LIB2 bodies to Rust-expression bodies using `self.x`. https://claude.ai/code/session_01WdLyxyy4ieAxrexj83X5MX
1 parent bd0881c commit 9c96cde

4 files changed

Lines changed: 9 additions & 46 deletions

File tree

tests/ui/fail/annot_preds_trait.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ trait Double {
2525

2626
#[thrust_macros::context]
2727
impl Double for A {
28-
// Write concrete definitions for predicates in `impl` blocks
28+
// self.x * 3 (this isn't actually doubled!) does not comply with the trait.
2929
#[thrust_macros::predicate]
3030
fn is_double(self, doubled: Self) -> bool {
31-
// (tuple_proj<Int>.0 self) is equivalent to self.x
32-
// self.x * 3 == doubled.x (this isn't actually doubled!) is written as following:
33-
"(=
34-
(* (tuple_proj<Int>.0 self_) 3)
35-
(tuple_proj<Int>.0 doubled)
36-
)"; true // This definition does not comply with annotations in trait!
31+
self.x * 3 == doubled.x
3732
}
3833

3934
// Check if this method complies with annotations in

tests/ui/fail/annot_preds_trait_multi.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ impl thrust_models::Model for A {
2626
impl Double for A {
2727
#[thrust_macros::predicate]
2828
fn is_double(self, doubled: Self) -> bool {
29-
// self.x * 2 == doubled.x
30-
"(=
31-
(* (tuple_proj<Int>.0 self_) 2)
32-
(tuple_proj<Int>.0 doubled)
33-
)"; true
29+
self.x * 2 == doubled.x
3430
}
3531

3632
fn double(&mut self) {
@@ -50,19 +46,10 @@ impl thrust_models::Model for B {
5046

5147
#[thrust_macros::context]
5248
impl Double for B {
49+
// self.x * 3 (this isn't actually doubled!) does not comply with the trait.
5350
#[thrust_macros::predicate]
5451
fn is_double(self, doubled: Self) -> bool {
55-
// self.x * 3 == doubled.x && self.y * 2 == doubled.y (this isn't actually doubled!)
56-
"(and
57-
(=
58-
(* (tuple_proj<Int-Int>.0 self_) 3)
59-
(tuple_proj<Int-Int>.0 doubled)
60-
)
61-
(=
62-
(* (tuple_proj<Int-Int>.1 self_) 2)
63-
(tuple_proj<Int-Int>.1 doubled)
64-
)
65-
)"; true // This definition does not comply with annotations in trait!
52+
self.x * 3 == doubled.x && self.y * 2 == doubled.y
6653
}
6754

6855
fn double(&mut self) {

tests/ui/pass/annot_preds_trait.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ trait Double {
2525

2626
#[thrust_macros::context]
2727
impl Double for A {
28-
// Write concrete definitions for predicates in `impl` blocks
28+
// Write concrete definitions for predicates in `impl` blocks, in Rust syntax.
2929
#[thrust_macros::predicate]
3030
fn is_double(self, doubled: Self) -> bool {
31-
// (tuple_proj<Int>.0 self) is equivalent to self.x
32-
// self.x * 2 == doubled.x is written as following:
33-
"(=
34-
(* (tuple_proj<Int>.0 self_) 2)
35-
(tuple_proj<Int>.0 doubled)
36-
)"; true
31+
self.x * 2 == doubled.x
3732
}
3833

3934
// Check if this method complies with annotations in

tests/ui/pass/annot_preds_trait_multi.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ impl thrust_models::Model for A {
2626
impl Double for A {
2727
#[thrust_macros::predicate]
2828
fn is_double(self, doubled: Self) -> bool {
29-
// self.x * 2 == doubled.x
30-
"(=
31-
(* (tuple_proj<Int>.0 self_) 2)
32-
(tuple_proj<Int>.0 doubled)
33-
)"; true
29+
self.x * 2 == doubled.x
3430
}
3531

3632
fn double(&mut self) {
@@ -52,17 +48,7 @@ impl thrust_models::Model for B {
5248
impl Double for B {
5349
#[thrust_macros::predicate]
5450
fn is_double(self, doubled: Self) -> bool {
55-
// self.x * 2 == doubled.x && self.y * 2 == doubled.y
56-
"(and
57-
(=
58-
(* (tuple_proj<Int-Int>.0 self_) 2)
59-
(tuple_proj<Int-Int>.0 doubled)
60-
)
61-
(=
62-
(* (tuple_proj<Int-Int>.1 self_) 2)
63-
(tuple_proj<Int-Int>.1 doubled)
64-
)
65-
)"; true
51+
self.x * 2 == doubled.x && self.y * 2 == doubled.y
6652
}
6753

6854
fn double(&mut self) {

0 commit comments

Comments
 (0)