Add tests checking for invalid function calls

This commit is contained in:
Pranav Gaddamadugu 2022-10-03 16:33:15 -07:00
parent c0c5e58011
commit 6ce64f8a78
8 changed files with 80 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"