From 8ba337088d37825d5276d0032bd8d71c46474c89 Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Tue, 27 Aug 2019 12:01:20 +0200 Subject: [PATCH] Added tests for #199 #295. Updated version number to 0.7.9 --- src/main/java/dk/camelot64/kickc/KickC.java | 2 +- .../dk/camelot64/kickc/test/TestPrograms.java | 18 ++++++++++++++++++ src/test/kc/bool-not-operator-1.kc | 13 +++++++++++++ src/test/kc/bool-not-operator-2.kc | 13 +++++++++++++ src/test/kc/bool-not-operator-3.kc | 12 ++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/test/kc/bool-not-operator-1.kc create mode 100644 src/test/kc/bool-not-operator-2.kc create mode 100644 src/test/kc/bool-not-operator-3.kc diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index cdff30c6a..c8e769d27 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -32,7 +32,7 @@ import java.util.concurrent.Callable; descriptionHeading = "%nDescription:%n%n", parameterListHeading = "%nParameters:%n", optionListHeading = "%nOptions:%n", - version = "KickC 0.7.8 BETA (master)" + version = "KickC 0.7.9 BETA (master)" ) public class KickC implements Callable { diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 997fd77b8..2dcb6727e 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -1390,12 +1390,30 @@ public class TestPrograms { compileAndCompare("examples/plasma/plasma"); } + // TODO: Fix bool auto-conversion type conversion https://gitlab.com/camelot/kickc/issues/199 + /* + @Test + public void testBoolNotOperator3() throws IOException, URISyntaxException { + compileAndCompare("bool-not-operator-3"); + } + */ + // TODO: Fix number type conversion https://gitlab.com/camelot/kickc/issues/199 /* @Test public void testTernary4() throws IOException, URISyntaxException { compileAndCompare("ternary-4"); } + + @Test + public void testBoolNotOperator1() throws IOException, URISyntaxException { + compileAndCompare("bool-not-operator-1"); + } + + @Test + public void testBoolNotOperator2() throws IOException, URISyntaxException { + compileAndCompare("bool-not-operator-2"); + } */ @Test diff --git a/src/test/kc/bool-not-operator-1.kc b/src/test/kc/bool-not-operator-1.kc new file mode 100644 index 000000000..2e23bc351 --- /dev/null +++ b/src/test/kc/bool-not-operator-1.kc @@ -0,0 +1,13 @@ +// Test the boolean NOT operator +// Bool not operator used in ternary operator +// Fails due to "Number integer type not resolved to fixed size integer type" +// https://gitlab.com/camelot/kickc/issues/199 + +void main() { + const char* screen = 0x0400; + for(char i: 0..7) { + bool b = (i&1)==1; + char c = !b ? 1 : 0 ; + screen[i] = c; + } +} \ No newline at end of file diff --git a/src/test/kc/bool-not-operator-2.kc b/src/test/kc/bool-not-operator-2.kc new file mode 100644 index 000000000..b056c649a --- /dev/null +++ b/src/test/kc/bool-not-operator-2.kc @@ -0,0 +1,13 @@ +// Test the boolean NOT operator +// Bool not operator used on char in ternary operator +// Fails due to "Number integer type not resolved to fixed size integer type" +// https://gitlab.com/camelot/kickc/issues/199 + +void main() { + const char* screen = 0x0400; + for(char i: 0..7) { + char b = i&1; + char c = !b ? 1 : 0 ; + screen[i] = c; + } +} \ No newline at end of file diff --git a/src/test/kc/bool-not-operator-3.kc b/src/test/kc/bool-not-operator-3.kc new file mode 100644 index 000000000..e53497cbf --- /dev/null +++ b/src/test/kc/bool-not-operator-3.kc @@ -0,0 +1,12 @@ +// Test the boolean NOT operator +// Bool not operator used directly on char +// Causes a Type mismatch - should instead add conversion cast. +// https://gitlab.com/camelot/kickc/issues/295 + +void main() { + const char* screen = 0x0400; + for(char i: 0..7) { + char b = (i&1); + screen[i] = !b; + } +} \ No newline at end of file