fixed: failing tests due to changes
This commit is contained in:
parent
472a4a623c
commit
cb8c7647bf
|
@ -170,6 +170,17 @@ TokenLocation new_location(unsigned long int line_start, unsigned long int col_s
|
|||
return location;
|
||||
}
|
||||
|
||||
TokenLocation empty_location(void) {
|
||||
TokenLocation location;
|
||||
|
||||
location.line_start = 0;
|
||||
location.line_end = 0;
|
||||
location.col_start = 0;
|
||||
location.col_end = 0;
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
void print_file_statistics(ModuleFile *file) {
|
||||
if (file->statistics.info_count + file->statistics.warning_count + file->statistics.error_count < 1) {
|
||||
return;
|
||||
|
|
|
@ -65,6 +65,8 @@ void delete_files(ModuleFileStack *stack);
|
|||
TokenLocation new_location(unsigned long int line_start, unsigned long int col_start, unsigned long int line_end,
|
||||
unsigned long int col_end);
|
||||
|
||||
TokenLocation empty_location(void);
|
||||
|
||||
[[gnu::nonnull(1), gnu::nonnull(2)]]
|
||||
void print_diagnostic(ModuleFile *file, TokenLocation *location, Message kind, const char *message);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define LOG_LEVEL_INFORMATION 1
|
||||
#define LOG_LEVEL_DEBUG 0
|
||||
|
||||
#define LOG_LEVEL LOG_LEVEL_ERROR
|
||||
#define LOG_LEVEL LOG_LEVEL_DEBUG
|
||||
|
||||
#define LOG_STRING_PANIC "Critical"
|
||||
#define LOG_STRING_FATAL "Fatal"
|
||||
|
|
|
@ -2,6 +2,14 @@ include(CTest)
|
|||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
# ------------------------------------------------ #
|
||||
# Setup Glib 2.0 #
|
||||
# ------------------------------------------------ #
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
include_directories(PRIVATE ${GLIB_INCLUDE_DIRS})
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# CTEST 1
|
||||
# test building the syntax tree
|
||||
|
@ -9,11 +17,14 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
|
|||
add_executable(ast_build_tree
|
||||
${PROJECT_SOURCE_DIR}/src/ast/ast.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/io/files.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
build_tree.c)
|
||||
set_target_properties(ast_build_tree
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "build_tree"
|
||||
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/ast)
|
||||
target_link_libraries(ast_build_tree PkgConfig::GLIB)
|
||||
add_test(NAME ast_build_tree
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMAND python ${GEMSTONE_TEST_DIR}/ast/test_ast.py check_build_tree)
|
||||
|
@ -25,11 +36,14 @@ add_test(NAME ast_build_tree
|
|||
add_executable(ast_print_node
|
||||
${PROJECT_SOURCE_DIR}/src/ast/ast.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/io/files.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
print_node.c)
|
||||
set_target_properties(ast_print_node
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "print_node"
|
||||
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/ast)
|
||||
target_link_libraries(ast_print_node PkgConfig::GLIB)
|
||||
add_test(NAME ast_print_node
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMAND python ${GEMSTONE_TEST_DIR}/ast/test_ast.py check_print_node)
|
||||
|
@ -41,11 +55,14 @@ add_test(NAME ast_print_node
|
|||
add_executable(ast_graphviz
|
||||
${PROJECT_SOURCE_DIR}/src/ast/ast.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/io/files.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
print_graphviz.c)
|
||||
set_target_properties(ast_graphviz
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "print_graphviz"
|
||||
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/ast)
|
||||
target_link_libraries(ast_graphviz PkgConfig::GLIB)
|
||||
add_test(NAME ast_graphviz
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMAND python ${GEMSTONE_TEST_DIR}/ast/test_ast.py check_print_graphviz)
|
||||
|
|
|
@ -6,22 +6,22 @@
|
|||
#include <sys/log.h>
|
||||
|
||||
void generate_statement(const AST_NODE_PTR stmt) {
|
||||
const AST_NODE_PTR add = AST_new_node(AST_Add, NULL);
|
||||
const AST_NODE_PTR add = AST_new_node(empty_location(), AST_Add, NULL);
|
||||
|
||||
AST_push_node(add, AST_new_node(AST_Int, "3"));
|
||||
AST_push_node(add, AST_new_node(AST_Int, "6"));
|
||||
AST_push_node(add, AST_new_node(empty_location(), AST_Int, "3"));
|
||||
AST_push_node(add, AST_new_node(empty_location(), AST_Int, "6"));
|
||||
|
||||
AST_push_node(stmt, add);
|
||||
}
|
||||
|
||||
void generate_branch(const AST_NODE_PTR stmt) {
|
||||
const AST_NODE_PTR branch = AST_new_node(AST_If, NULL);
|
||||
const AST_NODE_PTR gt = AST_new_node(AST_Greater, NULL);
|
||||
const AST_NODE_PTR branch = AST_new_node(empty_location(), AST_If, NULL);
|
||||
const AST_NODE_PTR gt = AST_new_node(empty_location(), AST_Greater, NULL);
|
||||
|
||||
AST_push_node(branch, gt);
|
||||
|
||||
AST_push_node(gt, AST_new_node(AST_Float, "2.3"));
|
||||
AST_push_node(gt, AST_new_node(AST_Float, "0.79"));
|
||||
AST_push_node(gt, AST_new_node(empty_location(), AST_Float, "2.3"));
|
||||
AST_push_node(gt, AST_new_node(empty_location(), AST_Float, "0.79"));
|
||||
|
||||
AST_push_node(stmt, branch);
|
||||
|
||||
|
@ -30,7 +30,7 @@ void generate_branch(const AST_NODE_PTR stmt) {
|
|||
|
||||
int main(void) {
|
||||
|
||||
const AST_NODE_PTR root = AST_new_node(AST_Stmt, NULL);
|
||||
const AST_NODE_PTR root = AST_new_node(empty_location(), AST_Stmt, NULL);
|
||||
|
||||
generate_branch(root);
|
||||
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
|
||||
int main(void) {
|
||||
|
||||
struct AST_Node_t* node = AST_new_node(AST_If, NULL);
|
||||
struct AST_Node_t* node = AST_new_node(empty_location(), AST_If, NULL);
|
||||
|
||||
struct AST_Node_t* child = AST_new_node(AST_Add, NULL);
|
||||
AST_push_node(child, AST_new_node(AST_Int, "43"));
|
||||
AST_push_node(child, AST_new_node(AST_Int, "9"));
|
||||
struct AST_Node_t* child = AST_new_node(empty_location(), AST_Add, NULL);
|
||||
AST_push_node(child, AST_new_node(empty_location(), AST_Int, "43"));
|
||||
AST_push_node(child, AST_new_node(empty_location(), AST_Int, "9"));
|
||||
|
||||
AST_push_node(node, child);
|
||||
AST_push_node(node, AST_new_node(AST_Expr, NULL));
|
||||
AST_push_node(node, AST_new_node(AST_Expr, NULL));
|
||||
AST_push_node(node, AST_new_node(empty_location(), AST_Expr, NULL));
|
||||
AST_push_node(node, AST_new_node(empty_location(), AST_Expr, NULL));
|
||||
|
||||
FILE* out = fopen("ast.gv", "w+");
|
||||
// convert this file ^^^^^^
|
||||
|
|
|
@ -6,22 +6,22 @@
|
|||
#include <sys/log.h>
|
||||
|
||||
void generate_statement(const AST_NODE_PTR stmt) {
|
||||
const AST_NODE_PTR add = AST_new_node(AST_Add, NULL);
|
||||
const AST_NODE_PTR add = AST_new_node(empty_location(), AST_Add, NULL);
|
||||
|
||||
AST_push_node(add, AST_new_node(AST_Int, "3"));
|
||||
AST_push_node(add, AST_new_node(AST_Int, "6"));
|
||||
AST_push_node(add, AST_new_node(empty_location(), AST_Int, "3"));
|
||||
AST_push_node(add, AST_new_node(empty_location(), AST_Int, "6"));
|
||||
|
||||
AST_push_node(stmt, add);
|
||||
}
|
||||
|
||||
void generate_branch(const AST_NODE_PTR stmt) {
|
||||
const AST_NODE_PTR branch = AST_new_node(AST_If, NULL);
|
||||
const AST_NODE_PTR gt = AST_new_node(AST_Greater, NULL);
|
||||
const AST_NODE_PTR branch = AST_new_node(empty_location(), AST_If, NULL);
|
||||
const AST_NODE_PTR gt = AST_new_node(empty_location(), AST_Greater, NULL);
|
||||
|
||||
AST_push_node(branch, gt);
|
||||
|
||||
AST_push_node(gt, AST_new_node(AST_Float, "2.3"));
|
||||
AST_push_node(gt, AST_new_node(AST_Float, "0.79"));
|
||||
AST_push_node(gt, AST_new_node(empty_location(), AST_Float, "2.3"));
|
||||
AST_push_node(gt, AST_new_node(empty_location(), AST_Float, "0.79"));
|
||||
|
||||
AST_push_node(stmt, branch);
|
||||
|
||||
|
@ -32,7 +32,7 @@ int main(void) {
|
|||
|
||||
AST_init();
|
||||
|
||||
const AST_NODE_PTR root = AST_new_node(AST_Stmt, NULL);
|
||||
const AST_NODE_PTR root = AST_new_node(empty_location(), AST_Stmt, NULL);
|
||||
|
||||
generate_branch(root);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ int main(void) {
|
|||
|
||||
AST_init();
|
||||
|
||||
const AST_NODE_PTR node = AST_new_node(0, "value");
|
||||
const AST_NODE_PTR node = AST_new_node(empty_location(), 0, "value");
|
||||
|
||||
for (size_t i = 0; i < AST_ELEMENT_COUNT; i++) {
|
||||
// set kind
|
||||
|
|
|
@ -2,12 +2,20 @@ include(CTest)
|
|||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
# ------------------------------------------------ #
|
||||
# Setup Glib 2.0 #
|
||||
# ------------------------------------------------ #
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# CTEST 1
|
||||
# test the default output of the logger
|
||||
|
||||
add_executable(logging_output
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
output.c)
|
||||
set_target_properties(logging_output
|
||||
PROPERTIES
|
||||
|
@ -23,6 +31,7 @@ add_test(NAME logging_output
|
|||
|
||||
add_executable(logging_panic
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
panic.c)
|
||||
set_target_properties(logging_panic
|
||||
PROPERTIES
|
||||
|
@ -38,6 +47,7 @@ add_test(NAME logging_panic
|
|||
|
||||
add_executable(logging_streams
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
streams.c)
|
||||
set_target_properties(logging_streams
|
||||
PROPERTIES
|
||||
|
@ -53,6 +63,7 @@ add_test(NAME logging_streams
|
|||
|
||||
add_executable(logging_level
|
||||
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
||||
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
||||
level.c)
|
||||
set_target_properties(logging_level
|
||||
PROPERTIES
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
//
|
||||
|
||||
#include "sys/log.h"
|
||||
#include <sys/col.h>
|
||||
|
||||
#define LOG_LEVEL LOG_LEVEL_WARNING
|
||||
|
||||
int main(void) {
|
||||
log_init();
|
||||
col_init();
|
||||
|
||||
DEBUG("logging some debug...");
|
||||
INFO("logging some info...");
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
//
|
||||
|
||||
#include "sys/log.h"
|
||||
#include <sys/col.h>
|
||||
|
||||
int main(void) {
|
||||
log_init();
|
||||
col_init();
|
||||
|
||||
DEBUG("logging some debug...");
|
||||
INFO("logging some info...");
|
||||
|
|
Loading…
Reference in New Issue