1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-02-17 10:30:43 +00:00

Added another test for literal number type detection in ternaries. #199

This commit is contained in:
jespergravgaard 2019-10-09 16:43:02 +02:00
parent 22139da54e
commit 08da28e976
2 changed files with 39 additions and 0 deletions

View File

@ -715,6 +715,9 @@ public class TestPrograms {
/**
* TODO: Fix error with number resolving
*
* @Test public void testNumberTernaryFail2() throws IOException, URISyntaxException {
* compileAndCompare("number-ternary-fail-2");
* }
* @Test public void testNumberTernaryFail() throws IOException, URISyntaxException {
* compileAndCompare("number-ternary-fail");
* }

View File

@ -0,0 +1,36 @@
// Failing number type resolving in ternary operator
// Currently fails in the ternary operator with number-issues if integer literal is not specified!
import "stdlib"
void SolveMaze(char *maze, word width, word height) {
word count=0;
word x=3, y=2;
word forward=0;
while(x != (width - 2) || y != (height - 2)) {
maze[y * width + x] = forward ? 2 : 3;
if ( 1 == 1 ) {
forward = 1; // <- HERE
} else {
forward = 0;
count = 0;
}
}
}
void main() {
word width=18 * 2 + 3;
word height=6 * 2 + 3;
char *maze;
maze = malloc(width * height);
SolveMaze(maze, width, height);
free(maze);
asm {loop: jmp loop }
}