diff options
Diffstat (limited to 'tests/src/hashmap.rs')
-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 |