Files
Toy/source/toy_value.c
Kayne Ruse e6ad46f1ff Wrote value, chunk, memory sections, tested value
chunk and memory remain untested for now
2024-08-13 23:42:14 +10:00

21 lines
430 B
C

#include "toy_value.h"
#include "toy_console_colors.h"
#include <stdio.h>
bool Toy_private_isTruthy(Toy_Value value) {
//null is an error
if (TOY_VALUE_IS_NULL(value)) {
fprintf(stderr, TOY_CC_ERROR "ERROR: 'null' is neither true nor false\n" TOY_CC_RESET);
return false;
}
//only 'false' is falsy
if (TOY_VALUE_IS_BOOLEAN(value)) {
return TOY_VALUE_AS_BOOLEAN(value);
}
//anything else is truthy
return true;
}