1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-08 14:37:40 +00:00

Added tests for initializing array inside struct using inline string and inline array initializer.

This commit is contained in:
Jesper Gravgaard 2019-12-29 15:05:24 +01:00
parent 2cf4a3c347
commit 4af8b1a833
4 changed files with 43 additions and 3 deletions
src
main/fragment/mos6502-common
test
java/dk/camelot64/kickc/test
kc

@ -1,5 +1,5 @@
!:
lda {c2}-1,x
sta {c1}-1,x
dex
lda {c2},x
sta {c1},x
bne !-

@ -1127,9 +1127,19 @@ public class TestPrograms {
assertError("struct-err-0", "Unknown struct type");
}
@Test
public void testStruct28() throws IOException, URISyntaxException {
compileAndCompare("struct-28", log());
}
@Test
public void testStruct27() throws IOException, URISyntaxException {
compileAndCompare("struct-27", log());
}
@Test
public void testStruct26() throws IOException, URISyntaxException {
compileAndCompare("struct-26", log());
compileAndCompare("struct-26");
}
@Test

15
src/test/kc/struct-27.kc Normal file

@ -0,0 +1,15 @@
// Minimal struct with C-Standard behavior - member is array, copy assignment (not supported yet)
struct Point {
char x;
char[3] initials;
};
const char* SCREEN = 0x0400;
void main() {
__ma struct Point point1 = { 2, "jg" };
SCREEN[0] = point1.x;
SCREEN[1] = point1.initials[0];
SCREEN[2] = point1.initials[1];
}

15
src/test/kc/struct-28.kc Normal file

@ -0,0 +1,15 @@
// Minimal struct with C-Standard behavior - member is array, copy assignment (not supported yet)
struct Point {
char x;
char[2] initials;
};
const char* SCREEN = 0x0400;
void main() {
__ma struct Point point1 = { 2, { 'j', 'g' } };
SCREEN[0] = point1.x;
SCREEN[1] = point1.initials[0];
SCREEN[2] = point1.initials[1];
}