From b014e0f732d9f83ebefb29bb377d460af8cef5df Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Tue, 11 Jun 2019 21:52:21 +0200 Subject: [PATCH] Added tests for developing struct address-of --- .../java/dk/camelot64/kickc/test/TestPrograms.java | 11 +++++++++++ src/test/kc/struct-ptr-12-ref.kc | 9 +++++++++ src/test/kc/struct-ptr-12.kc | 13 +++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/test/kc/struct-ptr-12-ref.kc create mode 100644 src/test/kc/struct-ptr-12.kc diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 4fbaf26f9..b3b86ab2b 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -39,6 +39,17 @@ public class TestPrograms { public void testTextbox() throws IOException, URISyntaxException { compileAndCompare("textbox"); } +/* + @Test + public void testStructPtr12Ref() throws IOException, URISyntaxException { + compileAndCompare("struct-ptr-12-ref", log()); + } + + @Test + public void testStructPtr12() throws IOException, URISyntaxException { + compileAndCompare("struct-ptr-12"); + } + */ @Test public void testStructPtr11() throws IOException, URISyntaxException { diff --git a/src/test/kc/struct-ptr-12-ref.kc b/src/test/kc/struct-ptr-12-ref.kc new file mode 100644 index 000000000..92acc3271 --- /dev/null +++ b/src/test/kc/struct-ptr-12-ref.kc @@ -0,0 +1,9 @@ +// Reference file for Minimal struct - using address-of + +void main() { + word p = { 2, 3 }; + word *q = &p; + const byte* SCREEN = 0x0400; + SCREEN[0] = <*q; + SCREEN[1] = >*q; +} \ No newline at end of file diff --git a/src/test/kc/struct-ptr-12.kc b/src/test/kc/struct-ptr-12.kc new file mode 100644 index 000000000..b9dc1e6b2 --- /dev/null +++ b/src/test/kc/struct-ptr-12.kc @@ -0,0 +1,13 @@ +// Minimal struct - using address-of +struct Point { + byte x; + byte y; +}; + +void main() { + struct Point p = { 2, 3 }; + struct Point *q = &p; + const byte* SCREEN = 0x0400; + SCREEN[0] = q->x; + SCREEN[1] = q->y; +} \ No newline at end of file