more tests and boolean compare

This commit is contained in:
cozis
2022-03-06 17:17:23 +01:00
parent cb18c6ff91
commit 4c779e9e8b
2 changed files with 44 additions and 0 deletions
+12
View File
@@ -4,6 +4,7 @@
static _Bool to_bool(Object *obj, Error *err);
static void print(Object *obj, FILE *fp);
static _Bool op_eql(Object *self, Object *other);
static TypeObject t_bool = {
.base = (Object) { .type = &t_type, .flags = Object_STATIC },
@@ -12,6 +13,7 @@ static TypeObject t_bool = {
.atomic = ATMTP_BOOL,
.to_bool = to_bool,
.print = print,
.op_eql = op_eql,
};
static Object the_true_object = {
@@ -24,6 +26,16 @@ static Object the_false_object = {
.flags = Object_STATIC,
};
static _Bool op_eql(Object *self, Object *other)
{
assert(self != NULL);
assert(self->type == &t_bool);
assert(other != NULL);
assert(other->type == &t_bool);
return self == other;
}
static _Bool to_bool(Object *obj, Error *err)
{
assert(obj);