Add test cases

This commit is contained in:
Pranav Gaddamadugu 2023-10-07 20:38:36 -04:00 committed by Pranav Gaddamadugu
parent c3b92d1a4d
commit 0792191dde
15 changed files with 234 additions and 0 deletions

View File

@ -0,0 +1,13 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 4]) {
for i in 0u32..4u32 {
assert(a[i]);
}
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 8]) -> bool {
return a[0];
}
}

View File

@ -0,0 +1,19 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
struct bar {
data: [u8; 8],
}
record floo {
owner: address,
data: [u8; 8],
}
transition foo(a: [[bool; 8]; 8]) -> bool {
return a[0][0];
}
}

View File

@ -0,0 +1,14 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 8]) {
return then finalize a;
}
finalize foo(a: [bool; 8]) {
assert_eq(true, true);
}
}

View File

@ -0,0 +1,22 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 8]) -> bool {
return true;
}
transition bar(a: [bool; 8]) -> [bool; 8] {
return a;
}
function baz(a: [bool; 8]) -> bool {
return true;
}
function qux(a: [bool; 8]) -> [bool; 8] {
return a;
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition bar(a: bool) -> [bool; 8] {
return [a, a, a, a, a, a, a, a];
}
}

View File

@ -0,0 +1,14 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition bar(a: bool) -> [bool; 8] {
return [a, a, a, a, a, a, a];
}
transition foo() -> [u8; 8] {
return [1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u32];
}
}

View File

@ -0,0 +1,15 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
record bar {
owner: address,
data: u8,
}
transition foo(a: [bar; 8]) -> u8 {
return a[0].data;
}
}

View File

@ -0,0 +1,14 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
struct bar {
data: u8,
}
transition foo(a: [bar; 8]) -> u8 {
return a[0].data;
}
}

View File

@ -0,0 +1,14 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 1]) -> bool {
return true;
}
transition bar(a: [bool; 32]) -> bool {
return true;
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 33]) -> bool {
return true;
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 0]) -> bool {
return true;
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition foo(a: [bool; 8], index: u32) -> bool {
return a[index];
}
}

View File

@ -0,0 +1,35 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
struct Foo {
foo: [Foo; 1],
}
struct Bar {
baz: [Baz, 2],
}
struct Baz {
bar: [Bar, 3],
}
struct One {
two: [Two, 2],
}
struct Two {
three: [Three, 3],
four: [Four, 4],
}
struct Three {
one: [One, 1],
}
struct Four {
one: [One, 1],
}
}

View File

@ -0,0 +1,24 @@
/*
namespace: Execute
expectation: Pass
cases:
sum_manually:
- input: ["[1u64, 2u64, 3u64, 4u64]"]
sum_with_loop:
- input: ["[1u64, 2u64, 3u64, 4u64]"]
*/
program test.aleo {
transition sum_manually(a: [u64; 4]) -> u64 {
return a[0] + a[1] + a[2] + a[3];
}
transition sum_with_loop(a: [u64; 4]) -> u64 {
let sum: u64 = 0u64;
for i in 0u8..4u8 {
sum += a[i];
}
return sum;
}
}