aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/include/test.h4
-rw-r--r--test/parser.c70
-rw-r--r--test/tree.c4
3 files changed, 72 insertions, 6 deletions
diff --git a/test/include/test.h b/test/include/test.h
index 3193c52..8cde34d 100644
--- a/test/include/test.h
+++ b/test/include/test.h
@@ -12,6 +12,10 @@ extern unsigned int TESTS_PASSED;
#define TEST_INIT unsigned int TESTS_RUN = 0, TESTS_PASSED = 0;
+#ifndef __func__
+#define __func__ ""
+#endif
+
#define ASSERT(EXPR) \
TESTS_RUN++; \
(EXPR && ++TESTS_PASSED) ? \
diff --git a/test/parser.c b/test/parser.c
index feb9c70..f2fe908 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -249,7 +249,7 @@ void single_block() {
lexer_t* lexer;
parser_t* parser;
- char src[] = "{}";
+ char src[] = "{1}";
/*
@@ -257,7 +257,9 @@ void single_block() {
val:
[block]
val:
- NULL
+ [lint]
+ val:
+ 1
nxt:
NULL
nxt:
@@ -267,7 +269,8 @@ void single_block() {
tree = tree_init(TREE_TYPE_BLOCK);
tree_t* tree0block = tree->data.block.val = tree_init(TREE_TYPE_BLOCK);
- tree0block->data.block.val = NULL;
+ tree_t* tree0lint = tree0block->data.block.val = tree_init(TREE_TYPE_LINT);
+ tree0lint->data.lint.val = 1;
tree0block->data.block.nxt = NULL;
tree->data.block.nxt = NULL;
@@ -290,13 +293,72 @@ void single_block() {
parser_destroy(parser);
}
-int main(int argc, char** argv) {
+void lint_and_block() {
+ tree_t* tree;
+ pp_t* pp;
+ lexer_t* lexer;
+ parser_t* parser;
+
+ char src[] = "1;{1}";
+
+ /*
+
+ [block]
+ val:
+ [lint]
+ val:
+ 1
+ nxt:
+ [block]
+ val:
+ [block]
+ val:
+ [lint]
+ val:
+ 1
+ nxt:
+ NULL
+ nxt:
+ NULL
+
+ */
+
+ tree = tree_init(TREE_TYPE_BLOCK);
+ tree_t* tree0lint = tree->data.block.val = tree_init(TREE_TYPE_LINT);
+ tree0lint->data.lint.val = 1;
+ tree_t* tree0block = tree->data.block.nxt = tree_init(TREE_TYPE_BLOCK);
+ tree_t* tree1block = tree0block->data.block.val = tree_init(TREE_TYPE_BLOCK);
+ tree_t* tree1lint = tree1block->data.block.val = tree_init(TREE_TYPE_LINT);
+ tree1lint->data.lint.val = 1;
+ tree1block->data.block.nxt = NULL;
+ tree0block->data.block.nxt = NULL;
+
+ pp = pp_init(src);
+ pp_run(pp);
+
+ lexer = lexer_init(pp->psrc);
+ lexer_run(lexer);
+
+ parser = parser_init(lexer->tokenl);
+ parser_run(parser);
+
+ ASSERT(tree_cmp(parser->tree, tree) == 1);
+
+ token_destroy(lexer->tokenl);
+ lexer_destroy(lexer);
+ pp_destroy(pp);
+ tree_destroy(parser->tree);
+ parser_destroy(parser);
+}
+
+int main() {
empty();
single_lint();
double_lint();
single_lstr();
double_lstr();
single_block();
+ lint_and_block();
TEST_REPORT;
diff --git a/test/tree.c b/test/tree.c
index b9ef210..567daae 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -20,8 +20,6 @@ void test_things() {
tree_t* tree_lstr_1;
tree_t* tree_tag_0;
tree_t* tree_tag_1;
- tree_t* tree_def_0;
- tree_t* tree_def_1;
tree_t* tree_carg_0;
tree_t* tree_carg_1;
tree_t* tree_call_0;
@@ -245,6 +243,8 @@ void test_things() {
ASSERT(tree_cmp(tree_block_0, tree_block_0) == 1);
ASSERT(tree_cmp(tree_block_0, tree_block_1) == 0);
+
+ /* *Definitely* not cleaning up fully here. Oh, well. */
}
int main() {