From e7f217d45840f98e962c0af88b1ad3942261c127 Mon Sep 17 00:00:00 2001 From: grasshopper47 Date: Thu, 30 Nov 2023 21:44:44 +0100 Subject: [PATCH] Add a print statement alongisde println in tests --- .../execution_success/strings/src/main.nr | 14 ++++++++++++-- tooling/nargo_fmt/tests/expected/print.nr | 1 + tooling/nargo_fmt/tests/expected/print2.nr | 3 ++- tooling/nargo_fmt/tests/input/print.nr | 5 ++++- tooling/nargo_fmt/tests/input/print2.nr | 5 +++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/test_programs/execution_success/strings/src/main.nr b/test_programs/execution_success/strings/src/main.nr index cb2218837f3..0ba13b13724 100644 --- a/test_programs/execution_success/strings/src/main.nr +++ b/test_programs/execution_success/strings/src/main.nr @@ -10,20 +10,26 @@ fn main(message: pub str<11>, y: Field, hex_as_string: str<4>, hex_as_field: Fie let x = 10; let z = x * 5; std::println(10); + std::print(10); std::println(z); // x * 5 in println not yet supported + std::print(z); std::println(x); + std::print(x); let array = [1, 2, 3, 5, 8]; assert(y == 5); // Change to y != 5 to see how the later print statements are not called std::println(array); + std::print(array); bad_message = "hell\0\"world"; std::println(bad_message); + std::print(bad_message); assert(message != bad_message); let hash = std::hash::pedersen_commitment([x]); std::println(hash); + std::print(hash); assert(hex_as_string == "0x41"); // assert(hex_as_string != 0x41); This will fail with a type mismatch between str[4] and Field @@ -36,6 +42,10 @@ fn test_prints_strings() { std::println(message); std::println("goodbye world"); + + std::print(message); + std::print("\n"); + std::print("goodbye world\n"); } #[test] @@ -52,8 +62,8 @@ fn test_prints_array() { } fn failed_constraint(hex_as_field: Field) { - // TODO(#2116): Note that `println` will not work if a failed constraint can be - // evaluated at compile time. + // TODO(#2116): Note that `println` will not work if a failed constraint can be + // evaluated at compile time. // When this method is called from a test method or with constant values // a `Failed constraint` compile error will be caught before this `println` // is executed as the input will be a constant. diff --git a/tooling/nargo_fmt/tests/expected/print.nr b/tooling/nargo_fmt/tests/expected/print.nr index e169f565455..3bce0941da2 100644 --- a/tooling/nargo_fmt/tests/expected/print.nr +++ b/tooling/nargo_fmt/tests/expected/print.nr @@ -1,5 +1,6 @@ use dep::std; fn main() { + std::print("Hello world"); std::println("Hello world"); } diff --git a/tooling/nargo_fmt/tests/expected/print2.nr b/tooling/nargo_fmt/tests/expected/print2.nr index 80284444af8..3bce0941da2 100644 --- a/tooling/nargo_fmt/tests/expected/print2.nr +++ b/tooling/nargo_fmt/tests/expected/print2.nr @@ -1,5 +1,6 @@ use dep::std; -fn main( ) { +fn main() { + std::print("Hello world"); std::println("Hello world"); } diff --git a/tooling/nargo_fmt/tests/input/print.nr b/tooling/nargo_fmt/tests/input/print.nr index 8afa562dada..3bce0941da2 100644 --- a/tooling/nargo_fmt/tests/input/print.nr +++ b/tooling/nargo_fmt/tests/input/print.nr @@ -1,3 +1,6 @@ use dep::std; -fn main() { std::println("Hello world"); } +fn main() { + std::print("Hello world"); + std::println("Hello world"); +} diff --git a/tooling/nargo_fmt/tests/input/print2.nr b/tooling/nargo_fmt/tests/input/print2.nr index 07ef9dd0386..3bce0941da2 100644 --- a/tooling/nargo_fmt/tests/input/print2.nr +++ b/tooling/nargo_fmt/tests/input/print2.nr @@ -1,5 +1,6 @@ use dep::std; -fn main( ) { -std::println("Hello world"); +fn main() { + std::print("Hello world"); + std::println("Hello world"); }