mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-19 15:29:48 +00:00
Added tests for to few and many method parameters
This commit is contained in:
parent
87f58d8782
commit
878d3ae36b
@ -54,7 +54,7 @@ public class Pass1TypeInference extends Pass1Base {
|
||||
Procedure procedure = scopes.peek().getProcedure(procedureName);
|
||||
call.setProcedure(procedure.getRef());
|
||||
if(procedure.getParameters().size()!=call.getParameters().size()) {
|
||||
throw new RuntimeException("Wrong number of parameters in call. Expected " +procedure.getParameters().size()+". "+statement.toString());
|
||||
throw new CompileError("Wrong number of parameters in call. Expected " +procedure.getParameters().size()+". "+statement.toString());
|
||||
}
|
||||
if(lValue instanceof VariableRef) {
|
||||
Variable lValueVar = programScope.getVariable((VariableRef) lValue);
|
||||
|
@ -307,6 +307,27 @@ public class TestPrograms extends TestCase {
|
||||
fail("Expected compile error.");
|
||||
}
|
||||
|
||||
public void testToManyParams() throws IOException, URISyntaxException {
|
||||
try {
|
||||
compileAndCompare("tomanyparams");
|
||||
} catch (CompileError e) {
|
||||
// expecting error!
|
||||
return;
|
||||
}
|
||||
fail("Expected compile error.");
|
||||
}
|
||||
|
||||
public void testToFewParams() throws IOException, URISyntaxException {
|
||||
try {
|
||||
compileAndCompare("tofewparams");
|
||||
} catch (CompileError e) {
|
||||
// expecting error!
|
||||
return;
|
||||
}
|
||||
fail("Expected compile error.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void compileAndCompare(String filename) throws IOException, URISyntaxException {
|
||||
TestPrograms tester = new TestPrograms();
|
||||
|
12
src/main/java/dk/camelot64/kickc/test/tofewparams.kc
Normal file
12
src/main/java/dk/camelot64/kickc/test/tofewparams.kc
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
void main() {
|
||||
plot(5,5);
|
||||
plot(5);
|
||||
}
|
||||
|
||||
|
||||
void plot(byte x, byte y) {
|
||||
const byte* screen = $0400;
|
||||
byte* pos = screen+x+y;
|
||||
*pos = 1;
|
||||
}
|
12
src/main/java/dk/camelot64/kickc/test/tomanyparams.kc
Normal file
12
src/main/java/dk/camelot64/kickc/test/tomanyparams.kc
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
void main() {
|
||||
plot(5,5);
|
||||
plot(5,5,5);
|
||||
}
|
||||
|
||||
|
||||
void plot(byte x, byte y) {
|
||||
const byte* screen = $0400;
|
||||
byte* pos = screen+x+y;
|
||||
*pos = 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user