1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-06 00:33:42 +00:00

Added test for two error cases. #196

This commit is contained in:
jespergravgaard 2020-04-08 23:44:40 +02:00
parent db92daf4bf
commit 273819d2a4
3 changed files with 62 additions and 0 deletions

View File

@ -37,6 +37,16 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testCStyleDeclRedefinition() throws IOException, URISyntaxException {
assertError("cstyle-decl-redefinition", "Error! Redefinition of function sum");
}
@Test
public void testCStyleDeclMismatch() throws IOException, URISyntaxException {
assertError("cstyle-decl-mismatch", "Error! Conflicting declarations for sum");
}
@Test
public void testCStyleDecl0() throws IOException, URISyntaxException {
compileAndCompare("cstyle-decl-0");

View File

@ -0,0 +1,24 @@
// Test function declarations
// Declaration type mismatch
// Declaration of a sum-function
char sum(char a, int b);
char * const SCREEN = 0x0400;
// Definition of main()
void main() {
SCREEN[0] = sum('a', 2);
SCREEN[1] = sum('a', 12);
}
// Definition of sum()
char sum(char a, char b) {
return a+b;
}

View File

@ -0,0 +1,28 @@
// Test function declarations
// Redefinition (two implementations)
// Declaration of a sum-function
char sum(char a, char b);
char * const SCREEN = 0x0400;
// Definition of main()
void main() {
SCREEN[0] = sum('a', 2);
SCREEN[1] = sum('a', 12);
}
// Definition of sum()
char sum(char a, char b) {
return a+b;
}
// Second definition of sum()
char sum(char a, char b) {
return a+b;
}