summaryrefslogtreecommitdiff
path: root/rust-tests
diff options
context:
space:
mode:
authorSon Ho2021-11-23 21:35:20 +0100
committerSon Ho2021-11-23 21:35:20 +0100
commite607decbe559070c7fc76e70739161e1a083dc7c (patch)
tree2fde01e0bc70fb7009d9aa414d1c4b04042e354d /rust-tests
parentce5bbb12a1f568050957fa3d1d34d761729d0880 (diff)
Write utilities for the scalars
Diffstat (limited to 'rust-tests')
-rw-r--r--rust-tests/Cargo.toml9
-rw-r--r--rust-tests/src/main.rs45
2 files changed, 54 insertions, 0 deletions
diff --git a/rust-tests/Cargo.toml b/rust-tests/Cargo.toml
new file mode 100644
index 00000000..e384da1d
--- /dev/null
+++ b/rust-tests/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "rust-tests"
+version = "0.1.0"
+authors = ["Son Ho <hosonmarc@gmail.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/rust-tests/src/main.rs b/rust-tests/src/main.rs
new file mode 100644
index 00000000..f87fa40f
--- /dev/null
+++ b/rust-tests/src/main.rs
@@ -0,0 +1,45 @@
+/// The following code generates the limits for the scalar types
+
+fn main() {
+ let ints = &[
+ "isize", "i8", "i16", "i32", "i64", "i128", "usize", "u8", "u16", "u32", "u64", "u128",
+ ];
+ // Generate the code to print the limits
+ for s in ints {
+ println!(
+ "println!(\"let {}_min = Z.of_string \\\"{{}}\\\"\", {}::MIN);",
+ s, s
+ );
+ println!(
+ "println!(\"let {}_max = Z.of_string \\\"{{}}\\\"\", {}::MAX);",
+ s, s
+ );
+ }
+ println!("\n");
+
+ // Generate the OCaml definitions - this code is generated (comes from the above)
+ println!("let isize_min = Z.of_string \"{}\"", isize::MIN);
+ println!("let isize_max = Z.of_string \"{}\"", isize::MAX);
+ println!("let i8_min = Z.of_string \"{}\"", i8::MIN);
+ println!("let i8_max = Z.of_string \"{}\"", i8::MAX);
+ println!("let i16_min = Z.of_string \"{}\"", i16::MIN);
+ println!("let i16_max = Z.of_string \"{}\"", i16::MAX);
+ println!("let i32_min = Z.of_string \"{}\"", i32::MIN);
+ println!("let i32_max = Z.of_string \"{}\"", i32::MAX);
+ println!("let i64_min = Z.of_string \"{}\"", i64::MIN);
+ println!("let i64_max = Z.of_string \"{}\"", i64::MAX);
+ println!("let i128_min = Z.of_string \"{}\"", i128::MIN);
+ println!("let i128_max = Z.of_string \"{}\"", i128::MAX);
+ println!("let usize_min = Z.of_string \"{}\"", usize::MIN);
+ println!("let usize_max = Z.of_string \"{}\"", usize::MAX);
+ println!("let u8_min = Z.of_string \"{}\"", u8::MIN);
+ println!("let u8_max = Z.of_string \"{}\"", u8::MAX);
+ println!("let u16_min = Z.of_string \"{}\"", u16::MIN);
+ println!("let u16_max = Z.of_string \"{}\"", u16::MAX);
+ println!("let u32_min = Z.of_string \"{}\"", u32::MIN);
+ println!("let u32_max = Z.of_string \"{}\"", u32::MAX);
+ println!("let u64_min = Z.of_string \"{}\"", u64::MIN);
+ println!("let u64_max = Z.of_string \"{}\"", u64::MAX);
+ println!("let u128_min = Z.of_string \"{}\"", u128::MIN);
+ println!("let u128_max = Z.of_string \"{}\"", u128::MAX);
+}