]>
git.proxmox.com Git - rustc.git/blob - compiler/rustc_data_structures/src/snapshot_map/tests.rs
1 use super::SnapshotMap
;
5 let mut map
= SnapshotMap
::default();
6 map
.insert(22, "twenty-two");
7 let snapshot
= map
.snapshot();
8 map
.insert(22, "thirty-three");
9 assert_eq
!(map
[&22], "thirty-three");
10 map
.insert(44, "forty-four");
11 assert_eq
!(map
[&44], "forty-four");
12 assert_eq
!(map
.get(&33), None
);
13 map
.rollback_to(snapshot
);
14 assert_eq
!(map
[&22], "twenty-two");
15 assert_eq
!(map
.get(&33), None
);
16 assert_eq
!(map
.get(&44), None
);
22 let mut map
= SnapshotMap
::default();
23 map
.insert(22, "twenty-two");
24 let snapshot1
= map
.snapshot();
25 map
.insert(33, "thirty-three");
26 let snapshot2
= map
.snapshot();
27 map
.insert(44, "forty-four");
28 map
.rollback_to(snapshot1
); // bogus, but accepted
29 map
.rollback_to(snapshot2
); // asserts
33 fn nested_commit_then_rollback() {
34 let mut map
= SnapshotMap
::default();
35 map
.insert(22, "twenty-two");
36 let snapshot1
= map
.snapshot();
37 let snapshot2
= map
.snapshot();
38 map
.insert(22, "thirty-three");
39 map
.commit(snapshot2
);
40 assert_eq
!(map
[&22], "thirty-three");
41 map
.rollback_to(snapshot1
);
42 assert_eq
!(map
[&22], "twenty-two");