Slightly broken.
This commit is contained in:
parent
1a2249a0da
commit
4dd1f2b5f1
3
Makefile
3
Makefile
@ -35,6 +35,7 @@ TEST_VAL_DIR = $(TEST_DIR)/validation
|
|||||||
RESETCOLOR = \033[0m
|
RESETCOLOR = \033[0m
|
||||||
WHITE = $(RESETCOLOR)\033[37m
|
WHITE = $(RESETCOLOR)\033[37m
|
||||||
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
|
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
|
||||||
|
RED_BOLD = $(RESETCOLOR)\033[31;1m
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ $(TEST_BUILD_DIR)/test_%.out: $(TEST_OBJ_DIR)/test_%.o $(OBJ_DIR)/grammar.o $(OB
|
|||||||
# Run the test files.
|
# Run the test files.
|
||||||
test: $(TARGET) $(TEST_BIN_FILES)
|
test: $(TARGET) $(TEST_BIN_FILES)
|
||||||
@ $(PRINT) "$(WHITE_BOLD)Running unit tests...$(RESETCOLOR)"
|
@ $(PRINT) "$(WHITE_BOLD)Running unit tests...$(RESETCOLOR)"
|
||||||
for test in $(TEST_BIN_FILES); do ./$${test}; done
|
for test in $(TEST_BIN_FILES); do ./$${test} || echo -e "$(RED_BOLD) BAD EXIT ON $${test} $(RESETCOLOR)"; done
|
||||||
@ $(PRINT) "$(WHITE_BOLD)Running validation tests...$(RESETCOLOR)"
|
@ $(PRINT) "$(WHITE_BOLD)Running validation tests...$(RESETCOLOR)"
|
||||||
$(BATS) $(TEST_VAL_DIR)
|
$(BATS) $(TEST_VAL_DIR)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "../src/include/ast.h"
|
#include "../src/include/ast.h"
|
||||||
#include "Unity/src/unity.h"
|
#include "Unity/src/unity.h"
|
||||||
#include "Unity/src/unity_internals.h"
|
#include "Unity/src/unity_internals.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
void setUp() {}
|
void setUp() {}
|
||||||
void tearDown() {}
|
void tearDown() {}
|
||||||
@ -11,11 +12,45 @@ void test_ast_num() {
|
|||||||
|
|
||||||
TEST_ASSERT_EQUAL(AST_TYPE_NUM, ast->type);
|
TEST_ASSERT_EQUAL(AST_TYPE_NUM, ast->type);
|
||||||
TEST_ASSERT_EQUAL(12.0, *(ASTNumData*)ast->data);
|
TEST_ASSERT_EQUAL(12.0, *(ASTNumData*)ast->data);
|
||||||
|
|
||||||
|
ast_destroy(ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_ast_vref() {
|
||||||
|
char* s = malloc(2);
|
||||||
|
strcpy(s, "x");
|
||||||
|
ASTVrefData* vref = ast_vref_data_init(s);
|
||||||
|
AST* ast = ast_init(AST_TYPE_VREF, vref);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(AST_TYPE_VREF, ast->type);
|
||||||
|
ASTVrefData data = *(ASTVrefData*)ast->data;
|
||||||
|
TEST_ASSERT_EQUAL_STRING("x", data.to);
|
||||||
|
|
||||||
|
//ast_destroy(ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_ast_call() {
|
||||||
|
AST** argv = malloc(2*sizeof(AST*));
|
||||||
|
argv[0] = ast_init(AST_TYPE_NUM, ast_num_data_init(1.0));
|
||||||
|
argv[1] = ast_init(AST_TYPE_NUM, ast_num_data_init(2.0));
|
||||||
|
|
||||||
|
ASTCallData* call = ast_call_data_init("f", 2, argv);
|
||||||
|
|
||||||
|
AST* ast = ast_init(AST_TYPE_CALL, call);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(AST_TYPE_CALL, ast->type);
|
||||||
|
TEST_ASSERT_EQUAL("f", ((ASTCallData*)ast->data)->to);
|
||||||
|
TEST_ASSERT_EQUAL(2, ((ASTCallData*)ast->data)->argc);
|
||||||
|
TEST_ASSERT_EQUAL(1.0, ((ASTCallData*)ast->data)->argv[0]);
|
||||||
|
TEST_ASSERT_EQUAL(2.0, ((ASTCallData*)ast->data)->argv[1]);
|
||||||
|
|
||||||
|
ast_destroy(ast);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
RUN_TEST(test_ast_num);
|
RUN_TEST(test_ast_num);
|
||||||
|
RUN_TEST(test_ast_vref);
|
||||||
|
RUN_TEST(test_ast_call);
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user