Skip to content

Commit

Permalink
fix: update noir tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Feb 27, 2024
1 parent 8d86146 commit ba50564
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct MyStruct<S> {
impl<S> MyStruct<S> {
fn insert(mut self: Self, index: Field, elem: Field) -> Self {
// Regression test for numeric generics on impls
assert(index as u64 < S as u64);
assert(index as u32 < S as u32);

self.data[index] = elem;
self
Expand Down
6 changes: 3 additions & 3 deletions noir/test_programs/execution_success/array_len/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
fn len_plus_1<T, N>(array: [T; N]) -> u64 {
fn len_plus_1<T, N>(array: [T; N]) -> u32 {
array.len() + 1
}

fn add_lens<T, N, M>(a: [T; N], b: [Field; M]) -> u64 {
fn add_lens<T, N, M>(a: [T; N], b: [Field; M]) -> u32 {
a.len() + b.len()
}

fn nested_call<N>(b: [Field; N]) -> u64 {
fn nested_call<N>(b: [Field; N]) -> u32 {
len_plus_1(b)
}

Expand Down
8 changes: 4 additions & 4 deletions noir/test_programs/execution_success/regression/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impl Eq for U4 {
}

fn compact_decode<N>(input: [u8; N], length: Field) -> ([U4; NIBBLE_LENGTH], Field) {
assert(2 * input.len() <= NIBBLE_LENGTH as u64);
assert(length as u64 <= input.len());
assert(2 * input.len() <= NIBBLE_LENGTH as u32);
assert(length as u32 <= input.len());

let mut nibble = [U4::zero(); NIBBLE_LENGTH];

Expand All @@ -32,15 +32,15 @@ fn compact_decode<N>(input: [u8; N], length: Field) -> ([U4; NIBBLE_LENGTH], Fie
if parity == 1 {
nibble[0] = U4::from_u8(input[0] & 0x0f);
for i in 1..input.len() {
if i as u64 < length as u64 {
if i as u32 < length as u32 {
let x = input[i];
nibble[2*i - 1] = U4::from_u8(x >> 4);
nibble[2*i] = U4::from_u8(x & 0x0f);
}
}
} else {
for i in 0..2 {
if (i as u64) < length as u64 - 1 {
if (i as u32) < length as u32 - 1 {
let x = input[i + 1];
nibble[2*i] = U4::from_u8(x >> 4);
nibble[2*i + 1] = U4::from_u8(x & 0x0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ fn dynamic_slice_merge_if(mut slice: [Field], x: Field) {
assert(first_elem == 12);
assert(rest_of_slice.len() == 6);

slice = rest_of_slice.insert(x as u64 - 2, 20);
slice = rest_of_slice.insert(x as u32 - 2, 20);
assert(slice[2] == 20);
assert(slice[6] == 30);
assert(slice.len() == 7);

let (removed_slice, removed_elem) = slice.remove(x as u64 - 1);
let (removed_slice, removed_elem) = slice.remove(x as u32 - 1);
// The deconstructed tuple assigns to the slice but is not seen outside of the if statement
// without a direct assignment
slice = removed_slice;
Expand Down

0 comments on commit ba50564

Please sign in to comment.