-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add integration tests for bitshift operators (#1272)
* chore: add test for bitshift operators * chore: update error message to flag up that runtime shifts are not implemented yet * chore: split runtime and comptime bitshift tests * chore: replace `constrain` with `assert()`
- Loading branch information
1 parent
62b7496
commit 4422bed
Showing
8 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
crates/nargo_cli/tests/test_data/bit_shifts_comptime/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
crates/nargo_cli/tests/test_data/bit_shifts_comptime/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x = 64 |
13 changes: 13 additions & 0 deletions
13
crates/nargo_cli/tests/test_data/bit_shifts_comptime/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
assert(two << 2 == 8); | ||
assert((two << 3) / 8 == two); | ||
assert((three >> 1) == 1); | ||
|
||
// comptime shifts on runtime values | ||
assert(x << 1 == 128); | ||
assert(x >> 2 == 16); | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/nargo_cli/tests/test_data/bit_shifts_runtime/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
crates/nargo_cli/tests/test_data/bit_shifts_runtime/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x = 64 | ||
y = 1 |
12 changes: 12 additions & 0 deletions
12
crates/nargo_cli/tests/test_data/bit_shifts_runtime/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
assert(64 << y == 128); | ||
assert(64 >> y == 32); | ||
|
||
// runtime shifts on runtime values | ||
assert(x << y == 128); | ||
assert(x >> y == 32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters