diff options
author | Son Ho | 2024-06-04 13:52:44 +0200 |
---|---|---|
committer | Son Ho | 2024-06-04 13:52:44 +0200 |
commit | 3ad6c4712fd41efec55f29af5ccc31f68a0e12cf (patch) | |
tree | 89f3b6999e1697595f1c3fbb2d9c4d8c60a69e49 /tests/src/hashmap.rs | |
parent | 2a7a18d6a07ea4967ba9ec0763e6b7d04849dc7e (diff) | |
parent | 4a31acdff7a5dfdc26bf25ad25bb8266b790f891 (diff) |
Merge branch 'main' into son/loops2
Diffstat (limited to '')
-rw-r--r-- | tests/src/hashmap.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/src/hashmap.rs b/tests/src/hashmap.rs index 58d22acd..19832a84 100644 --- a/tests/src/hashmap.rs +++ b/tests/src/hashmap.rs @@ -1,3 +1,13 @@ +//@ charon-args=--opaque=utils +//@ aeneas-args=-state -split-files +//@ [coq] aeneas-args=-use-fuel +//@ [fstar] aeneas-args=-decreases-clauses -template-clauses +//@ [lean] aeneas-args=-no-gen-lib-entry +// ^ the `-no-gen-lib-entry` is because we add a custom import in the Hashmap.lean file: we do not +// want to overwrite it. +// Possible to add `--no-code-duplication` if we use the optimized MIR +// TODO: reactivate -test-trans-units + //! A hashmap implementation. //! //! Current limitations: @@ -306,6 +316,31 @@ impl<T> HashMap<T> { } } +// This is a module so we can tell charon to leave it opaque +mod utils { + use crate::*; + + /// Serialize a hash map - we don't have traits, so we fix the type of the + /// values (this is not the interesting part anyway) + pub(crate) fn serialize(_hm: HashMap<u64>) { + unimplemented!(); + } + /// Deserialize a hash map - we don't have traits, so we fix the type of the + /// values (this is not the interesting part anyway) + pub(crate) fn deserialize() -> HashMap<u64> { + unimplemented!(); + } +} + +pub fn insert_on_disk(key: Key, value: u64) { + // Deserialize + let mut hm = utils::deserialize(); + // Update + hm.insert(key, value); + // Serialize + utils::serialize(hm); +} + /// I currently can't retrieve functions marked with the attribute #[test], /// while I want to extract the unit tests and use the normalize on them, /// so I have to define the test functions somewhere and call them from |