aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Lockwood2021-06-27 11:15:30 -0400
committerAlexis Lockwood2021-06-27 11:15:30 -0400
commitea50b4a64986806bd290d8c0fa999b4b0e016519 (patch)
treec7947278c82d79ee346441a74b054e6ebae2199f
parentf7ad143dd092a298b401d868d2ee88e51ef0dbb3 (diff)
Fix test build
-rw-r--r--test/test_internal.c53
-rw-r--r--test/tsupport.c4
2 files changed, 29 insertions, 28 deletions
diff --git a/test/test_internal.c b/test/test_internal.c
index 4319db4..738ae1a 100644
--- a/test/test_internal.c
+++ b/test/test_internal.c
@@ -5,6 +5,7 @@
#include "tsupport.h"
#include "ls_internal.h"
#include "ls_expr.h"
+#include "ls_lex.h"
#include <stdbool.h>
#include <stddef.h>
@@ -36,22 +37,22 @@ DECLTEST(_ls_lex)
{
ls_test_setup(&ctx, operstrings[i]);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_LT);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_LEQ);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_EQ);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_NEQ);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_GEQ);
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_OPERATOR);
+ munit_assert_int(tok.ty, ==, LS_TOK_OPERATOR);
munit_assert_int(tok.body.oper_val, ==, OPER_GT);
}
@@ -59,35 +60,35 @@ DECLTEST(_ls_lex)
ls_test_setup(&ctx, "foo");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "foo");
ls_test_setup(&ctx, "foo bar");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "foo");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "bar");
ls_test_setup(&ctx, "abittoolong foo");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "abittoolo");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "foo");
ls_test_setup(&ctx, " hasspace");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "hasspace");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_NONE);
+ munit_assert_int(tok.ty, ==, LS_TOK_NONE);
ls_test_setup(&ctx, "_foo_");
ls_lex(&ctx, &tok);
- munit_assert_int(tok.kind, ==, LS_TOK_WORD);
+ munit_assert_int(tok.ty, ==, LS_TOK_WORD);
munit_assert_string_equal(tok.body.word_val, "_foo_");
ls_test_setup(&ctx, "\x7F");
@@ -126,23 +127,23 @@ DECLTEST(_ls_parse_num)
ls_test_setup(&ctx, "42, &H42, &o42, &42, &b101010");
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.body.integer.value, ==, 42);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.body.integer.value, ==, 0x42);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.body.integer.value, ==, 042);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.body.integer.value, ==, 042);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.body.integer.value, ==, 42);
ls_test_setup(&ctx, "0e42");
- LS_EXPECT_ERR(ctx, LS_SYNTAX_ERROR, ls_eval_expr(&ctx, &val));
+ LS_EXPECT_ERR(ctx, LS_SYNTAX_ERROR, ls_eval_expr(&ctx, &val, NULL));
return MUNIT_OK;
}
@@ -164,7 +165,7 @@ static void _check_expr(char const * s, int expected)
ls_value_t val;
ls_test_setup(&ctx, s);
size_t sz_pool = ls_mem_avail(&ctx);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.ty, ==, LS_TY_INT);
munit_assert_int(val.body.integer.value, ==, expected);
munit_assert_size(sz_pool, ==, ls_mem_avail(&ctx));
@@ -226,8 +227,8 @@ DECLTEST(_ls_lookup_var)
ctx.callstack->ty = LS_TY_SCTX_CALL;
ctx.callstack->prev = NULL;
ctx.callstack->next = NULL;
- ctx.callstack->body.sctx_call.pc = -1;
- ctx.callstack->body.sctx_call.readptr = -1;
+ ctx.callstack->body.sctx_call.pc = LS_ADDR_NULL;
+ ctx.callstack->body.sctx_call.readptr = LS_ADDR_NULL;
ls_value_t * var_foo = ls_new_var(&ctx, "foo");
ls_write_int_var(&ctx, var_foo, 20);
@@ -237,7 +238,7 @@ DECLTEST(_ls_lookup_var)
ls_value_t val;
size_t sz_pool = ls_mem_avail(&ctx);
- ls_eval_expr(&ctx, &val);
+ ls_eval_expr(&ctx, &val, NULL);
munit_assert_int(val.ty, ==, LS_TY_INT);
munit_assert_int(val.body.integer.value, ==, 42);
munit_assert_size(sz_pool, ==, ls_mem_avail(&ctx));
@@ -266,8 +267,8 @@ DECLTEST(_ls_let)
ctx.callstack->ty = LS_TY_SCTX_CALL;
ctx.callstack->prev = NULL;
ctx.callstack->next = NULL;
- ctx.callstack->body.sctx_call.pc = -1;
- ctx.callstack->body.sctx_call.readptr = -1;
+ ctx.callstack->body.sctx_call.pc = LS_ADDR_NULL;
+ ctx.callstack->body.sctx_call.readptr = LS_ADDR_NULL;
ls_exec_line(&ctx);
ls_exec_line(&ctx);
diff --git a/test/tsupport.c b/test/tsupport.c
index e4bfdae..07a9a8a 100644
--- a/test/tsupport.c
+++ b/test/tsupport.c
@@ -69,8 +69,8 @@ static void _setup_label_cache(ls_label_cache_t * label_cache)
{
for (size_t i = 0; i < LS_LABEL_CACHE_SIZE; i++)
{
- label_cache[i].pc = -1;
- label_cache[i].name[0] = '\0';
+ label_cache[i].pc = LS_ADDR_NULL;
+ label_cache[i].num = 0;
}
}