Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: format integration tests #3002

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// ---

fn new_concrete_c_over_d() -> C<D> {
fn new_concrete_c_over_d() -> C<D> {
let d_method_interface = get_d_method_interface();
C::new(d_method_interface)
}
C::new(d_method_interface)
}

// ---

Expand Down Expand Up @@ -54,25 +53,24 @@
d: Field,
}

fn d_method(input: D) -> Field {
input.d * input.d
}
fn d_method(input: D) -> Field {
input.d * input.d
}

fn get_d_method_interface() -> MethodInterface<D> {
MethodInterface {
fn get_d_method_interface() -> MethodInterface<D> {
MethodInterface {
some_method_on_t_d: d_method,
}
}
}

// ---

fn main(input: Field) -> pub Field {
// ---
fn main(input: Field) -> pub Field {
let b: B<C<D>> = B::new(new_concrete_c_over_d);
let c: C<D> = b.get_t_c(); // Singleton<Note>
let d: D = D { d: input }; // Note
let output = c.call_method_of_t_d(d);

output
}
output
}

// ---
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Test 6" in this file panics. Looks to be something to do with nested for-loops

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::std;
//Basic tests for arrays
//Basic tests for arrays
fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
let mut c = 2301;
z = y[4];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//Tests for function calling
//Tests for function calling
fn f1(mut x: Field) -> Field {
x = x + 1;
x = f2(x);
x
}

fn f2(mut x: Field) -> Field{
fn f2(mut x: Field) -> Field {
x += 2;
x
}
Expand Down Expand Up @@ -78,15 +78,12 @@ fn test_multiple5(a: (u32, u32)) {
assert(a.0 == a.1+2);
}


fn test_multiple6(a: my2, b: my_struct, c: (my2, my_struct)) {
test_multiple4(a.aa);
test_multiple5((b.a, b.b));
assert(c.0.aa.a == c.1.a);
}



fn foo<N>(a: [Field; N]) -> [Field; N] {
a
}
Expand All @@ -112,7 +109,7 @@ fn main(x: u32 , y: u32 , a: Field, arr1: [u32; 9], arr2: [u32; 9]) {
(x,ab)
};
assert(my_block.1 == 4);

test0(a);
test1(a);
test2(x as Field, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fn main(x : Field, y : Field, z : Field) -> pub Field {
let c = b * z; // 2 * 5 = 10
let d = c / a; // 10 / 6 (This uses field inversion, so we test it by multiplying by `a`)
d * a
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

fn main(x: [u32; 5], mut z: u32, t: u32, index: [Field;5], index2: [Field;5], offset: Field, sublen: Field) {
let idx = (z - 5*t - 5) as Field;
//dynamic array test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is assertion
fn main(x : Field, y : pub Field) {
fn main(x : Field, y : pub Field) {
assert(x == y, "x and y are not equal");
assert_eq(x, y, "x and y are not equal");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ fn main(x : Field, y : Field) {
let y_as_u11 = y as u11;
assert((x_as_u11 & y_as_u11) == x_as_u11);
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main(x: u64) {
assert(x << 1 == 128);
assert(x >> 2 == 16);

regression_2250();
regression_2250();
}

fn regression_2250() {
Expand All @@ -20,4 +20,4 @@ fn regression_2250() {

let b: u32 = 1 >> 32;
assert(b == 0);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main(x: u1) {
assert(!x == 0);
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn main(x: u1, y: u1) {

assert(x | y | x == 1);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

fn main(x: u32) {
fn main(x: u32) {
assert(entry_point(x) == 2);
swap_entry_point(x, x + 1);
assert(deep_entry_point(x) == 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Tests a very simple program.
//
// The features being tested are array reads and writes

fn main(x: [Field; 3]) {
fn main(x: [Field; 3]) {
read_array(x);
read_write_array(x);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is using assert on brillig
fn main(x: Field) {
fn main(x: Field) {
assert(1 == conditional(x as bool));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls
fn main(x: u32) {
fn main(x: u32) {
assert(entry_point(x) == 2);
swap_entry_point(x, x + 1);
assert(deep_entry_point(x) == 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls passing arrays around
fn main(x: [u32; 3]) {
fn main(x: [u32; 3]) {
assert(entry_point(x) == 9);
another_entry_point(x);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls with conditionals
fn main(x: [u32; 3]) {
fn main(x: [u32; 3]) {
assert(entry_point(x[0]) == 7);
assert(entry_point(x[1]) == 8);
assert(entry_point(x[2]) == 9);
Expand Down Expand Up @@ -29,7 +29,7 @@ unconstrained fn entry_point(x: u32) -> u32 {
result = inner_2();
} else if x == 3 {
result = inner_3();
}
}

result
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is basic conditonal on brillig
fn main(x: Field) {
fn main(x: Field) {
assert(4 == conditional(x == 1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct MyStruct {
operation: fn (u32) -> u32,
}

fn main(x: u32) {
fn main(x: u32) {
assert(wrapper(increment, x) == x + 1);
assert(wrapper(increment_acir, x) == x + 1);
assert(wrapper(decrement, x) == x - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct myStruct {
// Tests a very simple program.
//
// The features being tested is the identity function in Brillig
fn main(x : Field) {
fn main(x : Field) {
assert(x == identity(x));
// TODO: add support for array comparison
let arr = identity_array([x, x]);
Expand All @@ -21,13 +21,13 @@ fn main(x : Field) {
}

unconstrained fn identity(x : Field) -> Field {
x
x
}

unconstrained fn identity_array(arr : [Field; 2]) -> [Field; 2] {
arr
arr
}

unconstrained fn identity_struct(s : myStruct) -> myStruct {
s
s
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is basic looping on brillig
fn main(sum: u32){
fn main(sum: u32) {
assert(loop(4) == sum);
assert(plain_loop() == sum);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple Brillig function.
//
// The features being tested is not instruction on brillig
fn main(x: Field, y : Field) {
fn main(x: Field, y : Field) {
assert(false == not_operator(x as bool));
assert(true == not_operator(y as bool));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::std::slice;

// Tests oracle usage in brillig/unconstrained functions
fn main(x: Field) {
fn main(x: Field) {
get_number_sequence_wrapper(20);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Fiel
let hash = std::hash::pedersen_with_separator([state], 0);
assert(std::hash::pedersen_with_separator([43], 0)[0] == hash[0]);
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The feature being tested is brillig recursion
fn main(x: u32) {
fn main(x: u32) {
assert(fibonacci(x) == 55);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unconstrained fn main(
let mut priv_key = a;
let mut pub_x: Field = a_pub_x;
let mut pub_y: Field = a_pub_y;
if a != 1 { // Change `a` in Prover.toml to test input `b`
if a != 1 { // Change `a` in Prover.toml to test input `b`
priv_key = b;
pub_x = b_pub_x;
pub_y = b_pub_y;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::std;

unconstrained fn main(x : Field, _y: Field) {
unconstrained fn main(x : Field, _y: Field) {
// The result of this byte array will be big-endian
let y: Field = 2040124;
let be_byte_array = y.to_be_bytes(31);
Expand All @@ -23,5 +23,5 @@ unconstrained fn main(x : Field, _y: Field) {
assert(z_bits[0] == 0);
assert(p_bits[100] == z_bits[100]);

_y.to_le_bits(std::field::modulus_num_bits() as u32);
_y.to_le_bits(std::field::modulus_num_bits() as u32);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Tests a very simple program.
//
// The feature being tested is brillig as the entry point.

unconstrained fn main(array: [Field; 3], x: pub Field) -> pub [Field; 2] {
[array[x], array[x + 1]]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

fn main(x: Field, y: Field) -> pub Field {
fn main(x: Field, y: Field) -> pub Field {
let notes = create_notes(x, y);
sum_x(notes, x, y)
}
Expand All @@ -10,4 +9,4 @@ fn sum_x(notes: [Field; 2], x: Field, y: Field) -> Field {

unconstrained fn create_notes(x: Field, y: Field) -> [Field; 2] {
[x,y]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn main(x: Field, y: Field) {
let t = z as u8;
assert(t == 1);
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ fn issue_2120() {
assert(*x1 == 44);
set_x1(*x1);
assert(*x1 == 44);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ fn sort(mut a: [u32; 4]) -> [u32; 4] {
a
}


fn must_be_zero(x: u8) {
assert(x == 0);
}

fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]){
fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]) {

//Test case for short-circuit
let mut data = [0 as u32; 32];
Expand Down Expand Up @@ -96,5 +95,4 @@ fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]){
}
}
assert(x == 0);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::std;


fn must_be_zero(x: u8) {
assert(x == 0);
}
Expand All @@ -17,7 +16,7 @@ fn test4() -> [u32; 4] {
}

fn main(a: u32, mut c: [u32; 4]) {

test3(1);

if a == 0 {
Expand Down
Loading
Loading