mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-21 07:29:14 +00:00
Added test demonstrating problem with passing struct in array as parameter #224
This commit is contained in:
parent
bef7663023
commit
cb5dc6550e
@ -35,6 +35,13 @@ public class TestPrograms {
|
|||||||
public TestPrograms() {
|
public TestPrograms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Test
|
||||||
|
public void testProblemArrayStructParam() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("problem-array-struct-param");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void testProblemArrayStructInit() throws IOException, URISyntaxException {
|
public void testProblemArrayStructInit() throws IOException, URISyntaxException {
|
||||||
|
24
src/test/kc/problem-array-struct-param.kc
Normal file
24
src/test/kc/problem-array-struct-param.kc
Normal file
@ -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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user