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:
parent
db92daf4bf
commit
273819d2a4
@ -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");
|
||||
|
24
src/test/kc/cstyle-decl-mismatch.kc
Normal file
24
src/test/kc/cstyle-decl-mismatch.kc
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
28
src/test/kc/cstyle-decl-redefinition.kc
Normal file
28
src/test/kc/cstyle-decl-redefinition.kc
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user