diff --git a/repl/bytecode_inspector.c b/repl/bytecode_inspector.c index c772d2a..38aa886 100644 --- a/repl/bytecode_inspector.c +++ b/repl/bytecode_inspector.c @@ -16,7 +16,12 @@ int inspect_read(unsigned char* bytecode, unsigned int pc, unsigned int jumps_ad #define MARKER_VALUE(pc, type) \ (pc * sizeof(type)) -#define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %lu\t" TOY_CC_RESET +#if TOY_BITNESS == 64 + #define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %lu\t" TOY_CC_RESET +#else + #define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %llu\t" TOY_CC_RESET +#endif + #define FONT_BLACK "\033[" TOY_CC_FONT_BLACK "m" //exposed functions diff --git a/tests/scripts/test_first_class_functions.toy b/tests/scripts/test_first_class_functions.toy new file mode 100644 index 0000000..4471b18 --- /dev/null +++ b/tests/scripts/test_first_class_functions.toy @@ -0,0 +1,10 @@ +//check functions are first class citizens +fn hello() { + print "Hello world"; +} + +fn identity(x) { + return x; +} + +assert identity(hello) == hello, "First class function check failed"; \ No newline at end of file diff --git a/tests/units/test_parser.c b/tests/units/test_parser.c index 57a2cea..4d92b1b 100644 --- a/tests/units/test_parser.c +++ b/tests/units/test_parser.c @@ -331,7 +331,12 @@ int test_values(Toy_Bucket** bucketHandle) { ast->block.child->stackPop.child->type != TOY_AST_VALUE || TOY_VALUE_IS_STRING(ast->block.child->stackPop.child->value.value) == false || TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->info.type != TOY_STRING_LEAF || - strncmp(TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->leaf.data, "Hello world!", TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value) != 0)) + strncmp( + TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->leaf.data, + "Hello world!", + TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->info.length) != 0 || + + false) { fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser with string value 'Hello world!'\n" TOY_CC_RESET); return -1; @@ -655,7 +660,8 @@ int test_keywords(Toy_Bucket** bucketHandle) { ast->block.child->assert.message->type != TOY_AST_VALUE || TOY_VALUE_IS_STRING(ast->block.child->assert.message->value.value) == false || TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->info.type != TOY_STRING_LEAF || - strncmp(TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->leaf.data, "foo", 3) != 0) + strncmp(TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->leaf.data, "foo", 3) != 0 + ) { fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source); return -1; @@ -678,7 +684,8 @@ int test_keywords(Toy_Bucket** bucketHandle) { ast->block.child->print.child->type != TOY_AST_VALUE || TOY_VALUE_IS_STRING(ast->block.child->print.child->value.value) == false || TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->info.type != TOY_STRING_LEAF || - strncmp(TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->leaf.data, "foo", 3) != 0) + strncmp(TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->leaf.data, "foo", 3) != 0 + ) { fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source); return -1;