mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 11:45:00 +03:00
Add test cases
This commit is contained in:
parent
c3b92d1a4d
commit
0792191dde
@ -0,0 +1,13 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
|
||||
program test.aleo {
|
||||
transition foo(a: [bool; 4]) {
|
||||
for i in 0u32..4u32 {
|
||||
assert(a[i]);
|
||||
}
|
||||
}
|
||||
}
|
10
tests/tests/compiler/array/array_access.leo
Normal file
10
tests/tests/compiler/array/array_access.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition foo(a: [bool; 8]) -> bool {
|
||||
return a[0];
|
||||
}
|
||||
}
|
19
tests/tests/compiler/array/array_in_composite_data_types.leo
Normal file
19
tests/tests/compiler/array/array_in_composite_data_types.leo
Normal 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];
|
||||
}
|
||||
}
|
14
tests/tests/compiler/array/array_in_finalize.leo
Normal file
14
tests/tests/compiler/array/array_in_finalize.leo
Normal 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);
|
||||
}
|
||||
}
|
22
tests/tests/compiler/array/array_in_function_signature.leo
Normal file
22
tests/tests/compiler/array/array_in_function_signature.leo
Normal 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;
|
||||
}
|
||||
}
|
10
tests/tests/compiler/array/array_initialization.leo
Normal file
10
tests/tests/compiler/array/array_initialization.leo
Normal 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];
|
||||
}
|
||||
}
|
14
tests/tests/compiler/array/array_initialization_fail.leo
Normal file
14
tests/tests/compiler/array/array_initialization_fail.leo
Normal 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];
|
||||
}
|
||||
}
|
15
tests/tests/compiler/array/array_of_records.leo
Normal file
15
tests/tests/compiler/array/array_of_records.leo
Normal 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;
|
||||
}
|
||||
}
|
14
tests/tests/compiler/array/array_of_structs.leo
Normal file
14
tests/tests/compiler/array/array_of_structs.leo
Normal 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;
|
||||
}
|
||||
}
|
14
tests/tests/compiler/array/array_size_limits.leo
Normal file
14
tests/tests/compiler/array/array_size_limits.leo
Normal 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;
|
||||
}
|
||||
}
|
10
tests/tests/compiler/array/array_too_large_fail.leo
Normal file
10
tests/tests/compiler/array/array_too_large_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition foo(a: [bool; 33]) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
10
tests/tests/compiler/array/array_too_small_fail.leo
Normal file
10
tests/tests/compiler/array/array_too_small_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition foo(a: [bool; 0]) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
10
tests/tests/compiler/array/array_variable_access_fail.leo
Normal file
10
tests/tests/compiler/array/array_variable_access_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition foo(a: [bool; 8], index: u32) -> bool {
|
||||
return a[index];
|
||||
}
|
||||
}
|
35
tests/tests/compiler/structs/cyclic_structs_four_fail.leo
Normal file
35
tests/tests/compiler/structs/cyclic_structs_four_fail.leo
Normal 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],
|
||||
}
|
||||
}
|
24
tests/tests/execution/array_sum.leo
Normal file
24
tests/tests/execution/array_sum.leo
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user