added tests and equal operator on floats

This commit is contained in:
cozis
2022-03-06 17:04:20 +01:00
parent 4394d95829
commit cb18c6ff91
2 changed files with 64 additions and 0 deletions
+17
View File
@@ -3,6 +3,7 @@
static double to_float(Object *obj, Error *err);
static void print(Object *obj, FILE *fp);
static _Bool op_eql(Object *self, Object *other);
typedef struct {
Object base;
@@ -16,8 +17,24 @@ static TypeObject t_float = {
.atomic = ATMTP_FLOAT,
.to_float = to_float,
.print = print,
.op_eql = op_eql
};
static _Bool op_eql(Object *self, Object *other)
{
assert(self != NULL);
assert(self->type == &t_float);
assert(other != NULL);
assert(other->type == &t_float);
FloatObject *i1, *i2;
i1 = (FloatObject*) self;
i2 = (FloatObject*) other;
return i1->val == i2->val;
}
static double to_float(Object *obj, Error *err)
{
assert(obj);