mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 05:45:30 +03:00
Add tests checking for invalid function calls
This commit is contained in:
parent
c0c5e58011
commit
6ce64f8a78
@ -0,0 +1,21 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file: inputs/dummy.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, y: bool) -> u32 {
|
||||
if y {
|
||||
return adder(a, b);
|
||||
} else {
|
||||
return subber(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
function adder(a: u32, b: u32) -> u32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function subber(a: u32, b: u32) -> u32 {
|
||||
return a - b;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file: inputs/dummy.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, y: bool) -> u32 {
|
||||
if y {
|
||||
return adder(a, b);
|
||||
} else {
|
||||
return subber(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
transition adder(a: u32, b: u32) -> u32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
transition subber(a: u32, b: u32) -> u32 {
|
||||
return a - b;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file: inputs/dummy.in
|
||||
*/
|
||||
|
||||
transition main(a: u32, b: u32, y: bool) -> u32 {
|
||||
if y {
|
||||
return adder(a, b);
|
||||
} else {
|
||||
return subber(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
transition adder(a: u32, b: u32) -> u32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
transition subber(a: u32, b: u32) -> u32 {
|
||||
return a - b;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:5:15\n |\n 5 | return adder(a, b);\n | ^^^^^^^^^^^\nError [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:7:16\n |\n 7 | return subber(a, b);\n | ^^^^^^^^^^^^\n"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:5:15\n |\n 5 | return adder(a, b);\n | ^^^^^^^^^^^\nError [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:7:16\n |\n 7 | return subber(a, b);\n | ^^^^^^^^^^^^\n"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372048]: Cannot call a local transition function from a transition function.\n --> compiler-test:5:15\n |\n 5 | return adder(a, b);\n | ^^^^^^^^^^^\nError [ETYC0372048]: Cannot call a local transition function from a transition function.\n --> compiler-test:7:16\n |\n 7 | return subber(a, b);\n | ^^^^^^^^^^^^\n"
|
@ -2,4 +2,4 @@
|
||||
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"
|
||||
- "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 | ^^\nError [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:22:20\n |\n 22 | let t: Token = mint(x, c);\n | ^^^^^^^^^^\n"
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372013]: Struct 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"
|
||||
- "Error [ETYC0372013]: Struct 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 | ^^^^^^\nError [ETYC0372047]: Cannot call another function from a standard function.\n --> compiler-test:22:20\n |\n 22 | let t: Token = mint(x, c);\n | ^^^^^^^^^^\n"
|
||||
|
Loading…
Reference in New Issue
Block a user