cosmetics
This commit is contained in:
@@ -8,12 +8,20 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env);
|
||||
int is_truthy (Ast_Node* expression, Environment* env);
|
||||
|
||||
int list_length(Ast_Node* node) {
|
||||
if (node->type != Ast_Node_Type_Nil)
|
||||
return 0;
|
||||
|
||||
if (node->type != Ast_Node_Type_Pair) {
|
||||
create_error(Error_Type_Type_Missmatch, node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
int len = 1;
|
||||
while (1) {
|
||||
break;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void eval_operands(Ast_Node* operands, Environment* env) {
|
||||
|
||||
@@ -96,10 +96,10 @@ void print(Ast_Node* node) {
|
||||
|
||||
|
||||
void log_error() {
|
||||
printf("\t%s%s%s\n", console_red,
|
||||
printf("%s%s%s\n", console_red,
|
||||
Error_Type_to_string(error->type),
|
||||
console_normal);
|
||||
printf("\t in: %s", console_cyan);
|
||||
printf(" in: %s", console_cyan);
|
||||
print(error->location);
|
||||
printf("%s\n", console_normal);
|
||||
}
|
||||
|
||||
@@ -5,23 +5,22 @@
|
||||
#define fail 0
|
||||
|
||||
#define print_assert_equal_fail(variable, value, type, format) \
|
||||
printf("\n\tAssertion failed for '" #variable "'" \
|
||||
printf("\nAssertion failed for '" #variable "'" \
|
||||
"\n\t in %s:%d" \
|
||||
"\n\texpected: " format \
|
||||
"\n\tgot: " format "\n", \
|
||||
__FILE__, __LINE__, (type)value, (type)variable)
|
||||
|
||||
#define print_assert_not_equal_fail(variable, value, type, format) \
|
||||
printf("\n\tAssertion failed for '" #variable "'" \
|
||||
printf("\nAssertion failed for '" #variable "'" \
|
||||
"\n\t in %s:%d" \
|
||||
"\n\texpected not: " format \
|
||||
"\n\tgot anyways: " format "\n", \
|
||||
__FILE__, __LINE__, (type)value, (type)variable)
|
||||
|
||||
/* print_assert_not_equal_fail(error, 0, int, "%d"); \ */
|
||||
#define assert_no_error(error) \
|
||||
if (error) { \
|
||||
printf("\n\tExpected no error to occur," \
|
||||
printf("\nExpected no error to occur," \
|
||||
" but an error occured anyways:\n"); \
|
||||
log_error(); \
|
||||
return fail; \
|
||||
@@ -60,11 +59,14 @@
|
||||
|
||||
#define invoke_test(name) \
|
||||
printf("" #name ":"); \
|
||||
for(int i = 0; i < 45 - strlen(#name); ++i) \
|
||||
printf(" "); \
|
||||
if (name() == pass) \
|
||||
if (name() == pass) { \
|
||||
for(int i = strlen(#name); i < 70; ++i) \
|
||||
printf((i%3==1)? "." : " "); \
|
||||
printf("%spassed%s\n", console_green, console_normal); \
|
||||
} \
|
||||
else { \
|
||||
for(int i = -1; i < 70; ++i) \
|
||||
printf((i%3==1)? "." : " "); \
|
||||
printf("%sfailed%s\n", console_red, console_normal); \
|
||||
if(error) { \
|
||||
free(error); \
|
||||
|
||||
Reference in New Issue
Block a user