From 0cd60ee857ffbc89422ca85127c901f8c7540b82 Mon Sep 17 00:00:00 2001 From: jcmdln Date: Sat, 23 Sep 2023 13:04:17 -0400 Subject: [PATCH] Simplify tests --- test/core/car.c | 2 +- test/core/cdr.c | 2 +- test/core/read.c | 2 +- test/core/reverse.c | 2 +- test/math/add.c | 7 +------ test/math/divide.c | 7 +------ test/math/multiply.c | 7 +------ test/math/subtract.c | 7 +------ 8 files changed, 8 insertions(+), 28 deletions(-) diff --git a/test/core/car.c b/test/core/car.c index ffc442a..269cfb8 100644 --- a/test/core/car.c +++ b/test/core/car.c @@ -18,7 +18,7 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_ERROR); - Object const *car = Car(Read("42 \"wew\"")); + Object const *car = Car(Cons(Number(42), Cons(String("wew"), &NIL))); assert(car != NULL); assert(car->type == TYPE_NUMBER); diff --git a/test/core/cdr.c b/test/core/cdr.c index 5210fb2..c352804 100644 --- a/test/core/cdr.c +++ b/test/core/cdr.c @@ -18,7 +18,7 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_ERROR); - Object const *cdr = Cdr(Read("42 \"wew\"")); + Object const *cdr = Cdr(Cons(Number(42), Cons(String("wew"), &NIL))); assert(cdr != NULL); assert(cdr->type == TYPE_LIST); diff --git a/test/core/read.c b/test/core/read.c index 96a2607..557f5cb 100644 --- a/test/core/read.c +++ b/test/core/read.c @@ -18,7 +18,7 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_NIL); - Object const *list = Read("42 \"wew\""); + Object const *list = Cons(Number(42), Cons(String("wew"), &NIL)); assert(list != NULL); assert(list->type == TYPE_LIST); diff --git a/test/core/reverse.c b/test/core/reverse.c index 85e857d..1e17636 100644 --- a/test/core/reverse.c +++ b/test/core/reverse.c @@ -18,7 +18,7 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_NIL); - Object const *list = Reverse(Read("42 \"wew\"")); + Object const *list = Reverse(Cons(Number(42), Cons(String("wew"), &NIL))); assert(list != NULL); assert(list->type == TYPE_LIST); diff --git a/test/math/add.c b/test/math/add.c index 5f96487..634cccd 100644 --- a/test/math/add.c +++ b/test/math/add.c @@ -27,15 +27,10 @@ main(void) assert(underflow != NULL); assert(underflow->type == TYPE_ERROR); - Object const *add = Add(Read("30 10 2")); + Object const *add = Add(Cons(Number(30), Cons(Number(10), Cons(Number(2), &NIL)))); assert(add != NULL); assert(add->type == TYPE_NUMBER); assert(add->number == 42); - Object const *add_alt = Add(Cons(Number(30), Cons(Number(10), Cons(Number(2), &NIL)))); - assert(add_alt != NULL); - assert(add_alt->type == TYPE_NUMBER); - assert(add->number == add_alt->number); - return EXIT_SUCCESS; } diff --git a/test/math/divide.c b/test/math/divide.c index e0451de..107b128 100644 --- a/test/math/divide.c +++ b/test/math/divide.c @@ -19,15 +19,10 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_ERROR); - Object const *divide = Divide(Read("42 7 3")); + Object const *divide = Divide(Cons(Number(42), Cons(Number(7), Cons(Number(3), &NIL)))); assert(divide != NULL); assert(divide->type == TYPE_NUMBER); assert(divide->number == 2); - Object const *divide_alt = Divide(Cons(Number(42), Cons(Number(7), Cons(Number(3), &NIL)))); - assert(divide_alt != NULL); - assert(divide_alt->type == TYPE_NUMBER); - assert(divide->number == divide_alt->number); - return EXIT_SUCCESS; } diff --git a/test/math/multiply.c b/test/math/multiply.c index a1746a7..36c0d89 100644 --- a/test/math/multiply.c +++ b/test/math/multiply.c @@ -19,15 +19,10 @@ main(void) assert(nil != NULL); assert(nil->type == TYPE_ERROR); - Object const *multiply = Multiply(Read("2 3 7")); + Object const *multiply = Multiply(Cons(Number(2), Cons(Number(3), Cons(Number(7), &NIL)))); assert(multiply != NULL); assert(multiply->type == TYPE_NUMBER); assert(multiply->number == 42); - Object const *multiply_alt = Multiply(Cons(Number(2), Cons(Number(3), Cons(Number(7), &NIL)))); - assert(multiply_alt != NULL); - assert(multiply_alt->type == TYPE_NUMBER); - assert(multiply->number == multiply_alt->number); - return EXIT_SUCCESS; } diff --git a/test/math/subtract.c b/test/math/subtract.c index 3bde7c2..82d64f8 100644 --- a/test/math/subtract.c +++ b/test/math/subtract.c @@ -27,15 +27,10 @@ main(void) assert(underflow != NULL); assert(underflow->type == TYPE_ERROR); - Object const *subtract = Subtract(Read("100 58")); + Object const *subtract = Subtract(Cons(Number(100), Cons(Number(58), &NIL))); assert(subtract != NULL); assert(subtract->type == TYPE_NUMBER); assert(subtract->number == 42); - Object const *subtract_alt = Subtract(Cons(Number(100), Cons(Number(58), &NIL))); - assert(subtract_alt != NULL); - assert(subtract_alt->type == TYPE_NUMBER); - assert(subtract->number == subtract_alt->number); - return EXIT_SUCCESS; }