From 855434afa91f35ef0c75d72cbeb7e7c207398933 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sat, 18 May 2019 08:51:22 +0200 Subject: [PATCH] Added missing fragment and ternary type inference test --- src/main/fragment/vwsz1=vbsaa_plus_vwsc1.asm | 11 +++++++++++ .../java/dk/camelot64/kickc/test/TestPrograms.java | 5 +++++ src/test/kc/ternary-inference.kc | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/main/fragment/vwsz1=vbsaa_plus_vwsc1.asm create mode 100644 src/test/kc/ternary-inference.kc diff --git a/src/main/fragment/vwsz1=vbsaa_plus_vwsc1.asm b/src/main/fragment/vwsz1=vbsaa_plus_vwsc1.asm new file mode 100644 index 000000000..1d0b489df --- /dev/null +++ b/src/main/fragment/vwsz1=vbsaa_plus_vwsc1.asm @@ -0,0 +1,11 @@ +tax +clc +adc #<{c1} +sta {z1} +txa +ora #$7f +bmi !+ +lda #0 +!: +adc #>{c1} +sta {z1}+1 diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index d7455e9d6..e7a351b6a 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -63,6 +63,11 @@ public class TestPrograms { */ + @Test + public void testTernaryInference() throws IOException, URISyntaxException { + compileAndCompare("ternary-inference"); + } + @Test public void testFragmentVariations() throws IOException, URISyntaxException { compileAndCompare("fragment-variations"); diff --git a/src/test/kc/ternary-inference.kc b/src/test/kc/ternary-inference.kc new file mode 100644 index 000000000..47e22265d --- /dev/null +++ b/src/test/kc/ternary-inference.kc @@ -0,0 +1,10 @@ +// Type inference into the ternary operator + +void main() { + + const byte* screen = 0x400; + for(byte i: 0..10) { + screen[i] = (i<5?0x57:'0')+i; + } + +} \ No newline at end of file