From bedd2d3bb8ce76915da881a2afe8ed423d1fdaec Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 16 Sep 2024 16:32:29 +0300 Subject: [PATCH] test(plonky2_prove): Add tests for casts from lower signed type bit length to higher --- .../plonky2_prove_failure/signed_casts/Nargo.toml | 8 ++++++++ .../plonky2_prove_failure/signed_casts/Prover.toml | 3 +++ .../plonky2_prove_failure/signed_casts/src/main.nr | 10 ++++++++++ 3 files changed, 21 insertions(+) create mode 100644 test_programs/plonky2_prove_failure/signed_casts/Nargo.toml create mode 100644 test_programs/plonky2_prove_failure/signed_casts/Prover.toml create mode 100644 test_programs/plonky2_prove_failure/signed_casts/src/main.nr diff --git a/test_programs/plonky2_prove_failure/signed_casts/Nargo.toml b/test_programs/plonky2_prove_failure/signed_casts/Nargo.toml new file mode 100644 index 00000000000..04ba020c931 --- /dev/null +++ b/test_programs/plonky2_prove_failure/signed_casts/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "signed_casts" +type = "bin" +authors = [""] +compiler_version = ">=0.27.0" + +[dependencies] + diff --git a/test_programs/plonky2_prove_failure/signed_casts/Prover.toml b/test_programs/plonky2_prove_failure/signed_casts/Prover.toml new file mode 100644 index 00000000000..e00f3c569aa --- /dev/null +++ b/test_programs/plonky2_prove_failure/signed_casts/Prover.toml @@ -0,0 +1,3 @@ +x = [ -128, 127 ] +y = [ -128, 127 ] +z = [ -128, 127 ] diff --git a/test_programs/plonky2_prove_failure/signed_casts/src/main.nr b/test_programs/plonky2_prove_failure/signed_casts/src/main.nr new file mode 100644 index 00000000000..78ab171c051 --- /dev/null +++ b/test_programs/plonky2_prove_failure/signed_casts/src/main.nr @@ -0,0 +1,10 @@ +fn main(x: [i8; 2], y: [i16; 2], z: [i32; 2]) { + for i in 0..1 { + // i8 -> i16 + assert(x[i] as i16 == y[i]); + // i8 -> i32 + assert(x[i] as i32 == z[i]); + // i16 -> i32 + assert(y[i] as i32 == z[i]); + } +}