summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorNadrieril2024-05-27 14:59:10 +0200
committerNadrieril2024-05-27 17:22:56 +0200
commit2b40c5c3de1ee2caca2c0072f812fea04b5a0238 (patch)
tree687a640232f17269ad33f1a841817491962d4de9 /tests/src
parent4f26c7f6f1e554d8ec2f46e868d5dc66c4160d16 (diff)
tests: Merge the hashmap test files
Diffstat (limited to '')
-rw-r--r--tests/src/hashmap.rs29
-rw-r--r--tests/src/hashmap_main.rs22
-rw-r--r--tests/src/hashmap_utils.rs13
3 files changed, 28 insertions, 36 deletions
diff --git a/tests/src/hashmap.rs b/tests/src/hashmap.rs
index 4552e4f2..ccb96e1e 100644
--- a/tests/src/hashmap.rs
+++ b/tests/src/hashmap.rs
@@ -1,9 +1,11 @@
+//@ charon-args=--opaque=hashmap_utils
+//@ aeneas-args=-state -split-files
//@ [coq] aeneas-args=-use-fuel
-//@ aeneas-args=-split-files
//@ [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.
@@ -314,6 +316,31 @@ impl<T> HashMap<T> {
}
}
+// This is a module so we can tell charon to leave it opaque
+mod hashmap_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 = hashmap_utils::deserialize();
+ // Update
+ hm.insert(key, value);
+ // Serialize
+ hashmap_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
diff --git a/tests/src/hashmap_main.rs b/tests/src/hashmap_main.rs
deleted file mode 100644
index 0c827844..00000000
--- a/tests/src/hashmap_main.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-//@ charon-args=--opaque=hashmap_utils
-//@ aeneas-args=-state -split-files
-//@ [coq] aeneas-args=-use-fuel
-//@ [fstar] aeneas-args=-decreases-clauses -template-clauses
-// Possible to add `--no-code-duplication` if we use the optimized MIR
-// TODO: reactivate -test-trans-units
-mod hashmap;
-mod hashmap_utils;
-
-use crate::hashmap::*;
-use crate::hashmap_utils::*;
-
-pub fn insert_on_disk(key: Key, value: u64) {
- // Deserialize
- let mut hm = deserialize();
- // Update
- hm.insert(key, value);
- // Serialize
- serialize(hm);
-}
-
-pub fn main() {}
diff --git a/tests/src/hashmap_utils.rs b/tests/src/hashmap_utils.rs
deleted file mode 100644
index 33de49e1..00000000
--- a/tests/src/hashmap_utils.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-//@ skip
-use crate::hashmap::*;
-
-/// 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!();
-}