From 3e0be0faf5bc00e5d140e50140e6bdd1d19ff987 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 10 Dec 2014 15:28:37 +0100 Subject: mds-kbdc: compile-layout: m bug fix + more test cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/builtin-functions.c | 4 ++-- src/mds-kbdc/compile-layout.c | 1 - test-files/mds-kbdc/compile-layout/valid/get | 8 ++++++++ test-files/mds-kbdc/compile-layout/valid/set | 8 ++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 test-files/mds-kbdc/compile-layout/valid/get create mode 100644 test-files/mds-kbdc/compile-layout/valid/set diff --git a/src/mds-kbdc/builtin-functions.c b/src/mds-kbdc/builtin-functions.c index 7cd13b7..3ad4e83 100644 --- a/src/mds-kbdc/builtin-functions.c +++ b/src/mds-kbdc/builtin-functions.c @@ -282,7 +282,7 @@ static char32_t* builtin_function_get_2(const char32_t** restrict args) const char32_t* restrict b = *args++; char32_t* restrict rc; size_t n = (size_t)*b; - mds_kbdc_tree_t* value = variables_get((size_t)*a); + mds_kbdc_tree_t* value = variables_get((size_t)*a)->array.elements; while (n--) value = value->next; fail_if (rc = string_dup(value->compiled_string.string), rc == NULL); @@ -303,7 +303,7 @@ static char32_t* builtin_function_set_3(const char32_t** restrict args) const char32_t* restrict c = *args++; char32_t* restrict rc; size_t n = (size_t)*b; - mds_kbdc_tree_t* value = variables_get((size_t)*a); + mds_kbdc_tree_t* value = variables_get((size_t)*a)->array.elements; while (n--) value = value->next; free(value->compiled_string.string); diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index e15e7e4..db2680d 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -18,7 +18,6 @@ #include "compile-layout.h" /* TODO add call stack */ /* TODO fix so that for-loops do not generate the same errors/warnings in all iterations [loopy_error]. */ -/* TODO test set/3 and get/2 */ #include "include-stack.h" #include "builtin-functions.h" diff --git a/test-files/mds-kbdc/compile-layout/valid/get b/test-files/mds-kbdc/compile-layout/valid/get new file mode 100644 index 0000000..89dfc37 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/get @@ -0,0 +1,8 @@ +let \1 : { 1 2 3 0 5} +if \get(1 3) + "" : 0 +end if +if \not(\equals(\get(1 4) 5)) + 0 : "" +end if + diff --git a/test-files/mds-kbdc/compile-layout/valid/set b/test-files/mds-kbdc/compile-layout/valid/set new file mode 100644 index 0000000..13d9551 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/set @@ -0,0 +1,8 @@ +let \1 : { 0 } +if \get(1 0) + "" : 0 +end if +\set(1 0 1) +if \not(\get(1 0)) + "" : 0 +end if \ No newline at end of file -- cgit v1.2.3-70-g09d2