diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 2e12ca797..2f0d403e1 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -35,6 +35,13 @@ public class TestPrograms { public TestPrograms() { } + /* + @Test + public void testProblemArrayStructParam() throws IOException, URISyntaxException { + compileAndCompare("problem-array-struct-param"); + } + */ + /* @Test public void testProblemArrayStructInit() throws IOException, URISyntaxException { diff --git a/src/test/kc/problem-array-struct-param.kc b/src/test/kc/problem-array-struct-param.kc new file mode 100644 index 000000000..b215aa27a --- /dev/null +++ b/src/test/kc/problem-array-struct-param.kc @@ -0,0 +1,24 @@ +// Demonstrates problem with passing struct array element as parameter to call + +const char* SCREEN = 0x0400; +char idx = 0; + +struct Point { + char x; + char y; +}; + +struct Point[2] points; + +void main() { + points[0] = { 1, 2 }; + points[1] = { 3, 4 }; + for ( char i: 0..1) { + print(points[i]); + } +} + +void print(struct Point p) { + SCREEN[idx++] = p.x; + SCREEN[idx++] = p.y; +} \ No newline at end of file