Bytecode and Routine working, Routine tests incomplete

There may be a build issue on windows
This commit is contained in:
2024-09-20 16:15:27 +10:00
parent e35af3d84b
commit ad6f1c3067
9 changed files with 391 additions and 46 deletions

View File

@@ -38,8 +38,6 @@ int test_bytecode_header(Toy_Bucket* bucket) {
}
int main() {
fprintf(stderr, TOY_CC_WARN "WARNING: Bytecode implementation incomplete\n" TOY_CC_RESET);
//run each test set, returning the total errors given
int total = 0, res = 0;

View File

@@ -0,0 +1,47 @@
#include "toy_routine.h"
#include "toy_console_colors.h"
#include <stdio.h>
#include <string.h>
//tests
int test_routine_header(Toy_Bucket* bucket) {
//simple test to ensure the header looks right
{
//setup
Toy_Ast* ast = NULL;
Toy_private_emitAstPass(&bucket, &ast);
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check
//TODO
//cleanup
TOY_FREE_ARRAY(unsigned char, buffer, len);
}
return 0;
}
int main() {
fprintf(stderr, TOY_CC_WARN "WARNING: Routine tests incomplete\n" TOY_CC_RESET);
//run each test set, returning the total errors given
int total = 0, res = 0;
{
Toy_Bucket* bucket = NULL;
TOY_BUCKET_INIT(Toy_Ast, bucket, 32);
res = test_routine_header(bucket);
TOY_BUCKET_FREE(bucket);
if (res == 0) {
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
}
total += res;
}
return total;
}