mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 03:04:13 +03:00
stabilize record tests
This commit is contained in:
parent
5a26eed8ca
commit
86219c0044
@ -1,10 +0,0 @@
|
|||||||
[main]
|
|
||||||
a: bool = true;
|
|
||||||
y: bool = true;
|
|
||||||
// arr: [u32; 2] = [10, 8];
|
|
||||||
|
|
||||||
[constants]
|
|
||||||
b: bool = true;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: bool = true;
|
|
@ -1,5 +0,0 @@
|
|||||||
[main]
|
|
||||||
i: u32 = 1;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: [u32; 3] = [0u32; 3];
|
|
@ -1,5 +0,0 @@
|
|||||||
[main]
|
|
||||||
i: u32 = 1;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: [(u32, u32); 3] = [(0u32, 0u32); 3];
|
|
@ -1,5 +0,0 @@
|
|||||||
[main]
|
|
||||||
i: u32 = 2;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: [u32; 3] = [0u32; 3];
|
|
@ -1,5 +0,0 @@
|
|||||||
[main]
|
|
||||||
i: u32 = 2;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: [(u32, u32); 3] = [(0u32, 0u32); 3];
|
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
namespace: Compile
|
namespace: Compile
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
|
input_files: inputs/add.in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This record does define the `gates` variable but with the wrong type.
|
// This record does define the `gates` variable but with the wrong type.
|
||||||
@ -9,6 +10,6 @@ record Token {
|
|||||||
owner: address,
|
owner: address,
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() -> bool {
|
function main(a: u8, b:u8) -> u8 {
|
||||||
return true;
|
return a + b;
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
namespace: Compile
|
namespace: Compile
|
||||||
expectation: Pass
|
expectation: Pass
|
||||||
|
input_files: inputs/add.in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
record Token {
|
record Token {
|
||||||
@ -12,6 +13,6 @@ record Token {
|
|||||||
amount: u64,
|
amount: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() -> bool {
|
function main(a: u8, b:u8) -> u8 {
|
||||||
return true;
|
return a + b;
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ function mint(r0: address, r1: u64) -> Token {
|
|||||||
|
|
||||||
function main(x: address) -> u64 {
|
function main(x: address) -> u64 {
|
||||||
const c: u64 = 1u64;
|
const c: u64 = 1u64;
|
||||||
let t: Token = mint(x, c);
|
let t: Token = Token { owner: x, gates: 0u64, amount: c};
|
||||||
|
|
||||||
return t.gates;
|
return t.gates;
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ function mint(owner: address, amount: u64) -> Token {
|
|||||||
|
|
||||||
function main(x: address) -> u64 {
|
function main(x: address) -> u64 {
|
||||||
const c: u64 = 1u64;
|
const c: u64 = 1u64;
|
||||||
let t: Token = mint(x, c);
|
let t: Token = Token { owner: x, gates: 0u64, amount: c};
|
||||||
|
|
||||||
return t.gates;
|
return t.gates;
|
||||||
}
|
}
|
3
tests/compiler/records/inputs/add.in
Normal file
3
tests/compiler/records/inputs/add.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[main]
|
||||||
|
a: u8 = 1u8;
|
||||||
|
b: u8 = 1u8;
|
15
tests/compiler/statements/assign.leo
Normal file
15
tests/compiler/statements/assign.leo
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Pass
|
||||||
|
input_file: inputs/flag.in
|
||||||
|
*/
|
||||||
|
|
||||||
|
function main(flag: u8, value: u8) -> u8 {
|
||||||
|
if (flag == 0u8) {
|
||||||
|
value += 1u8;
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
value += 2u8;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
3
tests/compiler/statements/inputs/flag.in
Normal file
3
tests/compiler/statements/inputs/flag.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[main]
|
||||||
|
flag: u8 = 1u8;
|
||||||
|
value: u8 = 1u8;
|
5
tests/expectations/compiler/records/balance_wrong_ty.out
Normal file
5
tests/expectations/compiler/records/balance_wrong_ty.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372020]: The field `gates` in a `record` must have type `u64`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: address,\n 6 | owner: address,\n 7 | }\n | ^\n"
|
9
tests/expectations/compiler/records/declaration.out
Normal file
9
tests/expectations/compiler/records/declaration.out
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Pass
|
||||||
|
outputs:
|
||||||
|
- output:
|
||||||
|
- initial_input_ast: no input
|
||||||
|
initial_ast: 821c447666f4f0e3ec05818c7e5ff8f228768ea9ea89e50cac3c9c4e2286cf83
|
||||||
|
unrolled_ast: 821c447666f4f0e3ec05818c7e5ff8f228768ea9ea89e50cac3c9c4e2286cf83
|
||||||
|
ssa_ast: f229b97b92b6e5517e0404a6ba5559c94df673c14ec8f4f10156828f05f4761f
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [EAST0372010]: record `Token` shadowed by\n --> compiler-test:12:1\n |\n 12 | circuit Token { // This circuit cannot have the same name as the record defined above it.\n 13 | x: u32,\n 14 | }\n | ^\n"
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372016]: Record Token defined with more than one variable with the same name.\n --> compiler-test:3:1\n |\n 3 | record Token {\n 4 | // The token owner.\n 5 | owner: address,\n 6 | // The token owner.\n 7 | owner: address, // Cannot define two record variables with the same name.\n 8 | // The Aleo balance (in gates).\n 9 | gates: u64,\n 10 | // The token amount.\n 11 | amount: u64,\n 12 | }\n | ^\n"
|
9
tests/expectations/compiler/records/init_expression.out
Normal file
9
tests/expectations/compiler/records/init_expression.out
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Pass
|
||||||
|
outputs:
|
||||||
|
- output:
|
||||||
|
- initial_input_ast: no input
|
||||||
|
initial_ast: 91a94b43e7599be7a8d284d8ed68af60521bf2f586c081c46571e6877d42423f
|
||||||
|
unrolled_ast: 91a94b43e7599be7a8d284d8ed68af60521bf2f586c081c46571e6877d42423f
|
||||||
|
ssa_ast: f8dd2e6a50e15fc6e503645342f37c1da08ce3a7c90e70f91ff0e9aeb3e20ef9
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Pass
|
||||||
|
outputs:
|
||||||
|
- output:
|
||||||
|
- initial_input_ast: no input
|
||||||
|
initial_ast: 1381798c7151d829ababe68636c8f60caa2c4ede84e0603cae658079b4ffdb89
|
||||||
|
unrolled_ast: 1381798c7151d829ababe68636c8f60caa2c4ede84e0603cae658079b4ffdb89
|
||||||
|
ssa_ast: a327e9edcf9b23898a9855c61eb03920816ee84c0ab0d71c84faa6169550e1b3
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372003]: Expected type `address` but type `u64` was found\n --> compiler-test:12:28\n |\n 12 | function mint(r0: address, r1: u64) -> Token {\n | ^^\nError [ETYC0372003]: Expected type `u64` but type `address` was found\n --> compiler-test:12:15\n |\n 12 | function mint(r0: address, r1: u64) -> Token {\n | ^^\n"
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372013]: Circuit initialization expression for `Token` is missing member `owner`.\n --> compiler-test:13:12\n |\n 13 | return Token {\n 14 | sender: r0, // This variable should be named `owner`.\n 15 | gates: 0u64,\n 16 | amount: r1,\n 17 | };\n | ^^^^^^\n"
|
5
tests/expectations/compiler/records/no_owner_fail.out
Normal file
5
tests/expectations/compiler/records/no_owner_fail.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372019]: The `record` type requires the variable `owner: address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | // The Aleo balance (in gates).\n 6 | gates: u64,\n 7 | // The token amount.\n 8 | amount: u64,\n 9 | }\n | ^\n"
|
5
tests/expectations/compiler/records/owner_wrong_ty.out
Normal file
5
tests/expectations/compiler/records/owner_wrong_ty.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
namespace: Compile
|
||||||
|
expectation: Fail
|
||||||
|
outputs:
|
||||||
|
- "Error [ETYC0372020]: The field `owner` in a `record` must have type `address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: u64,\n 6 | owner: bool,\n 7 | }\n | ^\n"
|
Loading…
Reference in New Issue
Block a user