1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-29 18:49:42 +00:00

Added test of ranged for loop with an undeclared loop variable. Closes #333

This commit is contained in:
jespergravgaard 2020-06-28 02:00:02 +02:00
parent 802f72df99
commit d9c387665c
2 changed files with 19 additions and 0 deletions

View File

@ -3373,6 +3373,11 @@ public class TestPrograms {
compileAndCompare("examples/multiplexer/simple-multiplexer.c", 10); compileAndCompare("examples/multiplexer/simple-multiplexer.c", 10);
} }
@Test
public void testForRangedNpe() throws IOException, URISyntaxException {
assertError("forranged-npe.c", "Error! Loop variable not declared i");
}
@Test @Test
public void testForRangedWords() throws IOException, URISyntaxException { public void testForRangedWords() throws IOException, URISyntaxException {
compileAndCompare("forrangedwords.c"); compileAndCompare("forrangedwords.c");

View File

@ -0,0 +1,14 @@
// Range-loop without loop variable declaration causes NPE
// https://gitlab.com/camelot/kickc/-/issues/333
char * line = 0x0400;
void main() {
clear_line(line);
clear_line(line+40);
}
void clear_line(byte *line) {
for (i: 0..39)
line[i] = 0;
}