Skip to content

Commit

Permalink
Split tests for field and var assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbolliger committed Mar 4, 2021
1 parent 8001ffd commit 8c46cbe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions stainless_frontend/tests/extraction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ define_tests!(
pass: let_type,
pass: list_binary_search,
pass: monoid,
pass: mut_local_fields,
pass: mut_local_lets,
pass: mut_local_params,
pass: mut_ref_immut_borrow,
Expand Down
15 changes: 15 additions & 0 deletions stainless_frontend/tests/pass/mut_local_fields.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extern crate stainless;
use stainless::*;

#[var(field)]
struct S {
field: i32,
}

pub fn main() {
// field assignment
let mut s = S { field: 123 };
assert!(s.field == 123);
s.field = 456;
assert!(s.field == 456);
}
10 changes: 0 additions & 10 deletions stainless_frontend/tests/pass/mut_local_lets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ pub enum IntOption {
Some(i32),
}

struct S {
field: i32,
}

pub fn main() {
// Local mutation is ok.
let mut x = 1;
Expand All @@ -24,10 +20,4 @@ pub fn main() {
let mut option = IntOption::None;
option2 = option;
option = IntOption::Some(123);

// field assignment
let mut s = S { field: 123 };
assert!(s.field == 123);
s.field = 456;
assert!(s.field == 456);
}

0 comments on commit 8c46cbe

Please sign in to comment.