Skip to content

Commit

Permalink
chore: split runtime and comptime bitshift tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 2, 2023
1 parent 01be5d5 commit f5e5dd1
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
26 changes: 0 additions & 26 deletions crates/nargo_cli/tests/test_data/bit_shifts/src/main.nr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = 64
13 changes: 13 additions & 0 deletions crates/nargo_cli/tests/test_data/bit_shifts_comptime/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main(x: u64) {
let two: u64 = 2;
let three: u64 = 3;

// comptime shifts on comptime values
constrain two << 2 == 8;
constrain (two << 3) / 8 == two;
constrain (three >> 1) == 1;

// comptime shifts on runtime values
constrain x << 1 == 128;
constrain x >> 2 == 16;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
12 changes: 12 additions & 0 deletions crates/nargo_cli/tests/test_data/bit_shifts_runtime/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main(x: u64, y: u64) {
// These are currently unimplemented and panic with "ShiftLeft and ShiftRight operations with shifts which are only known at runtime are not yet implemented."
// See: https://github.com/noir-lang/noir/issues/1265

// runtime shifts on comptime values
constrain 64 << y == 128;
constrain 64 >> y == 32;

// runtime shifts on runtime values
constrain x << y == 128;
constrain x >> y == 32;
}
2 changes: 1 addition & 1 deletion crates/nargo_cli/tests/test_data/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# "1_mul", "2_div","3_add","4_sub","5_over", "6","6_array", "7_function","7","8_integration", "9_conditional", "10_slices", "assign_ex", "bool_not", "bool_or", "pedersen_check", "poseidonperm_x5_254", "poseidonsponge_x5_254", "pred_eq", "schnorr", "sha256", "tuples",
# "array_len", "array_neq", "bit_and", "cast_bool", "comptime_array_access", "generics", "global_comptime", "main_bool_arg", "main_return", "merkle_insert", "modules", "modules_more", "scalar_mul", "simple_shield", "struct", "submodules",
# Exclude "poseidonsponge_x5_254" and "sha2_byte" due to relatively long computation time and "sha2_blocks" due to very long computation time.
exclude = ["comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte"]
exclude = ["bit_shifts_runtime", "comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte"]


# List of tests (as their directory name in test_data) expecting to fail: if the test pass, we report an error.
Expand Down

0 comments on commit f5e5dd1

Please sign in to comment.