diff options
Diffstat (limited to 'src/tests')
38 files changed, 338 insertions, 0 deletions
diff --git a/src/tests/.gitignore b/src/tests/.gitignore new file mode 100644 index 0000000..e9a847e --- /dev/null +++ b/src/tests/.gitignore @@ -0,0 +1,2 @@ +*/target +target
\ No newline at end of file diff --git a/src/tests/Cargo.toml b/src/tests/Cargo.toml new file mode 100644 index 0000000..e7372e9 --- /dev/null +++ b/src/tests/Cargo.toml @@ -0,0 +1,16 @@ +[workspace] +resolver = "2" +members = [ + "b_asc_con", + "b_asc_con_ra", + "b_des_con", + "b_des_con_ra", + "b_stack_con", + "b_unique_asc_con", + "b_unique_asc_con_ra", + "b_unique_con", + "b_unique_con_ra", + "example_comp", + "example_stack", + "example_unique" +]
\ No newline at end of file diff --git a/src/tests/b_asc_con/Cargo.toml b/src/tests/b_asc_con/Cargo.toml new file mode 100644 index 0000000..654d8ab --- /dev/null +++ b/src/tests/b_asc_con/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_asc_con" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_asc_con/src/main.rs b/src/tests/b_asc_con/src/main.rs new file mode 100644 index 0000000..0d18aee --- /dev/null +++ b/src/tests/b_asc_con/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = AscendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/b_asc_con/src/types.pr.rs b/src/tests/b_asc_con/src/types.pr.rs new file mode 100644 index 0000000..12d3d02 --- /dev/null +++ b/src/tests/b_asc_con/src/types.pr.rs @@ -0,0 +1,6 @@ +/*SPEC* +property ascending<T> { + \c -> ((for-all-consecutive-pairs c) leq?) +} +type AscendingCon<T> = {c impl (Container) | (ascending c)} +*ENDSPEC*/ diff --git a/src/tests/b_asc_con_ra/Cargo.toml b/src/tests/b_asc_con_ra/Cargo.toml new file mode 100644 index 0000000..9bbe454 --- /dev/null +++ b/src/tests/b_asc_con_ra/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_asc_con_ra" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_asc_con_ra/src/main.rs b/src/tests/b_asc_con_ra/src/main.rs new file mode 100644 index 0000000..0d18aee --- /dev/null +++ b/src/tests/b_asc_con_ra/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = AscendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/b_asc_con_ra/src/types.pr.rs b/src/tests/b_asc_con_ra/src/types.pr.rs new file mode 100644 index 0000000..4d33cb9 --- /dev/null +++ b/src/tests/b_asc_con_ra/src/types.pr.rs @@ -0,0 +1,6 @@ +/*SPEC* +property ascending<T> { + \c -> ((for-all-consecutive-pairs c) leq?) +} +type AscendingCon<T> = {c impl (Container, Indexable) | (ascending c)} +*ENDSPEC*/ diff --git a/src/tests/b_des_con/Cargo.toml b/src/tests/b_des_con/Cargo.toml new file mode 100644 index 0000000..b1d0d61 --- /dev/null +++ b/src/tests/b_des_con/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_des_con" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_des_con/src/main.rs b/src/tests/b_des_con/src/main.rs new file mode 100644 index 0000000..b64347b --- /dev/null +++ b/src/tests/b_des_con/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = DescendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/b_des_con/src/types.pr.rs b/src/tests/b_des_con/src/types.pr.rs new file mode 100644 index 0000000..63f15ff --- /dev/null +++ b/src/tests/b_des_con/src/types.pr.rs @@ -0,0 +1,6 @@ +/*SPEC* +property descending<T> { + \c -> ((for-all-consecutive-pairs c) geq?) +} +type DescendingCon<T> = {c impl (Container) | (descending c)} +*ENDSPEC*/ diff --git a/src/tests/b_des_con_ra/Cargo.toml b/src/tests/b_des_con_ra/Cargo.toml new file mode 100644 index 0000000..5ea4fd4 --- /dev/null +++ b/src/tests/b_des_con_ra/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_des_con_ra" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_des_con_ra/src/main.rs b/src/tests/b_des_con_ra/src/main.rs new file mode 100644 index 0000000..b64347b --- /dev/null +++ b/src/tests/b_des_con_ra/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = DescendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/b_des_con_ra/src/types.pr.rs b/src/tests/b_des_con_ra/src/types.pr.rs new file mode 100644 index 0000000..db5adb0 --- /dev/null +++ b/src/tests/b_des_con_ra/src/types.pr.rs @@ -0,0 +1,6 @@ +/*SPEC* +property descending<T> { + \c -> ((for-all-consecutive-pairs c) geq?) +} +type DescendingCon<T> = {c impl (Container, Indexable) | (descending c)} +*ENDSPEC*/ diff --git a/src/tests/b_stack_con/Cargo.toml b/src/tests/b_stack_con/Cargo.toml new file mode 100644 index 0000000..6668e3d --- /dev/null +++ b/src/tests/b_stack_con/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_stack_con" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_stack_con/src/main.rs b/src/tests/b_stack_con/src/main.rs new file mode 100644 index 0000000..7c83f6b --- /dev/null +++ b/src/tests/b_stack_con/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = StackCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/b_stack_con/src/types.pr.rs b/src/tests/b_stack_con/src/types.pr.rs new file mode 100644 index 0000000..525fdee --- /dev/null +++ b/src/tests/b_stack_con/src/types.pr.rs @@ -0,0 +1,7 @@ +/*SPEC* +property lifo<T> { + \c <: (Stack) -> (forall \x -> ((equal? (pop ((push c) x))) x)) +} + +type StackCon<S> = {c impl (Container, Stack) | (lifo c)} +*ENDSPEC*/ diff --git a/src/tests/b_unique_asc_con/Cargo.toml b/src/tests/b_unique_asc_con/Cargo.toml new file mode 100644 index 0000000..8d4c00f --- /dev/null +++ b/src/tests/b_unique_asc_con/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_unique_asc_con" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_unique_asc_con/src/main.rs b/src/tests/b_unique_asc_con/src/main.rs new file mode 100644 index 0000000..2eac169 --- /dev/null +++ b/src/tests/b_unique_asc_con/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = StrictlyAscendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/b_unique_asc_con/src/types.pr.rs b/src/tests/b_unique_asc_con/src/types.pr.rs new file mode 100644 index 0000000..e84858e --- /dev/null +++ b/src/tests/b_unique_asc_con/src/types.pr.rs @@ -0,0 +1,10 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} +property ascending<T> { + \c -> ((for-all-consecutive-pairs c) leq?) +} + +type StrictlyAscendingCon<S> = {c impl (Container) | ((unique c) and (ascending c))} +*ENDSPEC*/ diff --git a/src/tests/b_unique_asc_con_ra/Cargo.toml b/src/tests/b_unique_asc_con_ra/Cargo.toml new file mode 100644 index 0000000..bb3fb42 --- /dev/null +++ b/src/tests/b_unique_asc_con_ra/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_unique_asc_con_ra" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_unique_asc_con_ra/src/main.rs b/src/tests/b_unique_asc_con_ra/src/main.rs new file mode 100644 index 0000000..2eac169 --- /dev/null +++ b/src/tests/b_unique_asc_con_ra/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = StrictlyAscendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/b_unique_asc_con_ra/src/types.pr.rs b/src/tests/b_unique_asc_con_ra/src/types.pr.rs new file mode 100644 index 0000000..ed64180 --- /dev/null +++ b/src/tests/b_unique_asc_con_ra/src/types.pr.rs @@ -0,0 +1,10 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} +property ascending<T> { + \c -> ((for-all-consecutive-pairs c) leq?) +} + +type StrictlyAscendingCon<S> = {c impl (Container, Indexable) | ((unique c) and (ascending c))} +*ENDSPEC*/ diff --git a/src/tests/b_unique_con/Cargo.toml b/src/tests/b_unique_con/Cargo.toml new file mode 100644 index 0000000..3ad6e18 --- /dev/null +++ b/src/tests/b_unique_con/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_unique_con" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_unique_con/src/main.rs b/src/tests/b_unique_con/src/main.rs new file mode 100644 index 0000000..a2b4246 --- /dev/null +++ b/src/tests/b_unique_con/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = UniqueCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/b_unique_con/src/types.pr.rs b/src/tests/b_unique_con/src/types.pr.rs new file mode 100644 index 0000000..7393cce --- /dev/null +++ b/src/tests/b_unique_con/src/types.pr.rs @@ -0,0 +1,7 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} + +type UniqueCon<S> = {c impl (Container) | (unique c)} +*ENDSPEC*/ diff --git a/src/tests/b_unique_con_ra/Cargo.toml b/src/tests/b_unique_con_ra/Cargo.toml new file mode 100644 index 0000000..8bc19d5 --- /dev/null +++ b/src/tests/b_unique_con_ra/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "b_unique_con_ra" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/b_unique_con_ra/src/main.rs b/src/tests/b_unique_con_ra/src/main.rs new file mode 100644 index 0000000..a2b4246 --- /dev/null +++ b/src/tests/b_unique_con_ra/src/main.rs @@ -0,0 +1,11 @@ +mod types; +use types::*; + +fn main() { + let mut c = UniqueCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/b_unique_con_ra/src/types.pr.rs b/src/tests/b_unique_con_ra/src/types.pr.rs new file mode 100644 index 0000000..7562dd7 --- /dev/null +++ b/src/tests/b_unique_con_ra/src/types.pr.rs @@ -0,0 +1,7 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} + +type UniqueCon<S> = {c impl (Container, Indexable) | (unique c)} +*ENDSPEC*/ diff --git a/src/tests/example_comp/Cargo.toml b/src/tests/example_comp/Cargo.toml new file mode 100644 index 0000000..67639f2 --- /dev/null +++ b/src/tests/example_comp/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "example_comp" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/example_comp/src/main.rs b/src/tests/example_comp/src/main.rs new file mode 100644 index 0000000..d87425b --- /dev/null +++ b/src/tests/example_comp/src/main.rs @@ -0,0 +1,12 @@ +mod types; +use types::*; + +fn main() { + let mut c = StrictlyAscendingCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + //c.first(); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/example_comp/src/types.pr.rs b/src/tests/example_comp/src/types.pr.rs new file mode 100644 index 0000000..ed64180 --- /dev/null +++ b/src/tests/example_comp/src/types.pr.rs @@ -0,0 +1,10 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} +property ascending<T> { + \c -> ((for-all-consecutive-pairs c) leq?) +} + +type StrictlyAscendingCon<S> = {c impl (Container, Indexable) | ((unique c) and (ascending c))} +*ENDSPEC*/ diff --git a/src/tests/example_stack/Cargo.toml b/src/tests/example_stack/Cargo.toml new file mode 100644 index 0000000..3010313 --- /dev/null +++ b/src/tests/example_stack/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "example_stack" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/example_stack/src/main.rs b/src/tests/example_stack/src/main.rs new file mode 100644 index 0000000..daa44d0 --- /dev/null +++ b/src/tests/example_stack/src/main.rs @@ -0,0 +1,12 @@ +mod types; +use types::*; + +fn main() { + let mut c = StackCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + //c.first(); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/example_stack/src/types.pr.rs b/src/tests/example_stack/src/types.pr.rs new file mode 100644 index 0000000..525fdee --- /dev/null +++ b/src/tests/example_stack/src/types.pr.rs @@ -0,0 +1,7 @@ +/*SPEC* +property lifo<T> { + \c <: (Stack) -> (forall \x -> ((equal? (pop ((push c) x))) x)) +} + +type StackCon<S> = {c impl (Container, Stack) | (lifo c)} +*ENDSPEC*/ diff --git a/src/tests/example_unique/Cargo.toml b/src/tests/example_unique/Cargo.toml new file mode 100644 index 0000000..732c903 --- /dev/null +++ b/src/tests/example_unique/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "example_unique" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tests/example_unique/src/main.rs b/src/tests/example_unique/src/main.rs new file mode 100644 index 0000000..0f6c143 --- /dev/null +++ b/src/tests/example_unique/src/main.rs @@ -0,0 +1,12 @@ +mod types; +use types::*; + +fn main() { + let mut c = UniqueCon::<u32>::new(); + for x in 0..10 { + c.insert(x); + c.insert(x); + //c.first(); + } + assert_eq!(c.len(), 10); +} diff --git a/src/tests/example_unique/src/types.pr.rs b/src/tests/example_unique/src/types.pr.rs new file mode 100644 index 0000000..7393cce --- /dev/null +++ b/src/tests/example_unique/src/types.pr.rs @@ -0,0 +1,7 @@ +/*SPEC* +property unique<T> { + \c <: (Container) -> ((for-all-elems c) \a -> ((unique-count? a) c)) +} + +type UniqueCon<S> = {c impl (Container) | (unique c)} +*ENDSPEC*/ |