Refactor with new name uclisp
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
#include <unity.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nihilispm.h"
|
||||
#include "nihilispm_internal.h"
|
||||
#include "nihilispm_utility.h"
|
||||
#include "uclisp.h"
|
||||
#include "internal.h"
|
||||
#include "utility.h"
|
||||
#include "testing_helpers.h"
|
||||
|
||||
static struct nl_object *input;
|
||||
static struct nl_object *response;
|
||||
static struct ucl_object *input;
|
||||
static struct ucl_object *response;
|
||||
|
||||
void setUp(void) {
|
||||
input = NULL;
|
||||
@@ -17,99 +17,99 @@ void setUp(void) {
|
||||
|
||||
void tearDown(void) {
|
||||
// TODO: Implement GC so we can clean these both up
|
||||
//nl_object_delete(input);
|
||||
//ucl_object_delete(input);
|
||||
input = NULL;
|
||||
nl_object_delete(response);
|
||||
ucl_object_delete(response);
|
||||
response = NULL;
|
||||
}
|
||||
|
||||
static void test_nil_create(void) {
|
||||
response = nl_nil_create();
|
||||
response = ucl_nil_create();
|
||||
|
||||
TEST_ASSERT_NIL(response);
|
||||
}
|
||||
|
||||
static void test_t_create(void) {
|
||||
response = nl_t_create();
|
||||
response = ucl_t_create();
|
||||
|
||||
TEST_ASSERT_T(response);
|
||||
}
|
||||
|
||||
static void test_predicate_true(void) {
|
||||
response = nl_predicate(true);
|
||||
response = ucl_predicate(true);
|
||||
|
||||
TEST_ASSERT_T(response);
|
||||
}
|
||||
|
||||
static void test_predicate_false(void) {
|
||||
response = nl_predicate(false);
|
||||
response = ucl_predicate(false);
|
||||
|
||||
TEST_ASSERT_NIL(response);
|
||||
}
|
||||
|
||||
static void test_car_nil(void) {
|
||||
response = nl_car(nl_nil_create());
|
||||
response = ucl_car(ucl_nil_create());
|
||||
|
||||
TEST_ASSERT_NIL(response);
|
||||
}
|
||||
|
||||
static void test_cdr_nil(void) {
|
||||
response = nl_cdr(nl_nil_create());
|
||||
response = ucl_cdr(ucl_nil_create());
|
||||
|
||||
TEST_ASSERT_NIL(response);
|
||||
}
|
||||
|
||||
static void test_car_t(void) {
|
||||
response = nl_car(nl_t_create());
|
||||
response = ucl_car(ucl_t_create());
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_cdr_t(void) {
|
||||
response = nl_car(nl_t_create());
|
||||
response = ucl_car(ucl_t_create());
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_car_list(void) {
|
||||
input = nl_tuple_create(
|
||||
nl_string_create(strdup("foo")),
|
||||
nl_t_create());
|
||||
response = nl_car(input);
|
||||
input = ucl_tuple_create(
|
||||
ucl_string_create(strdup("foo")),
|
||||
ucl_t_create());
|
||||
response = ucl_car(input);
|
||||
|
||||
TEST_ASSERT_OBJ_STRING(response);
|
||||
}
|
||||
|
||||
static void test_cdr_list(void) {
|
||||
input = nl_tuple_create(
|
||||
nl_t_create(),
|
||||
nl_string_create(strdup("foo")));
|
||||
response = nl_cdr(input);
|
||||
input = ucl_tuple_create(
|
||||
ucl_t_create(),
|
||||
ucl_string_create(strdup("foo")));
|
||||
response = ucl_cdr(input);
|
||||
|
||||
TEST_ASSERT_OBJ_STRING(nl_car(response));
|
||||
TEST_ASSERT_OBJ_STRING(ucl_car(response));
|
||||
}
|
||||
|
||||
static void test_list_length_nil() {
|
||||
response = nl_list_length(nl_nil_create());
|
||||
response = ucl_list_length(ucl_nil_create());
|
||||
|
||||
TEST_ASSERT_OBJ_INT(response);
|
||||
TEST_ASSERT_EQUAL(response->integer, 0);
|
||||
}
|
||||
|
||||
static void test_list_length_1() {
|
||||
response = nl_list_length(
|
||||
nl_cell_create(
|
||||
nl_t_create(), NULL));
|
||||
response = ucl_list_length(
|
||||
ucl_cell_create(
|
||||
ucl_t_create(), NULL));
|
||||
|
||||
TEST_ASSERT_OBJ_INT(response);
|
||||
TEST_ASSERT_EQUAL(response->integer, 1);
|
||||
}
|
||||
|
||||
static void test_list_length_2() {
|
||||
response = nl_list_length(
|
||||
nl_tuple_create(
|
||||
nl_t_create(),
|
||||
nl_t_create()));
|
||||
response = ucl_list_length(
|
||||
ucl_tuple_create(
|
||||
ucl_t_create(),
|
||||
ucl_t_create()));
|
||||
|
||||
TEST_ASSERT_OBJ_INT(response);
|
||||
TEST_ASSERT_EQUAL(response->integer, 2);
|
||||
@@ -117,67 +117,67 @@ static void test_list_length_2() {
|
||||
|
||||
|
||||
static void test_list_append_nil() {
|
||||
input = nl_nil_create();
|
||||
nl_list_append(input, nl_t_create());
|
||||
input = ucl_nil_create();
|
||||
ucl_list_append(input, ucl_t_create());
|
||||
|
||||
TEST_ASSERT_EQUAL(nl_list_length(input)->integer, 1);
|
||||
TEST_ASSERT_EQUAL(ucl_list_length(input)->integer, 1);
|
||||
}
|
||||
|
||||
static void test_list_append_list() {
|
||||
input = nl_tuple_create(nl_t_create(), nl_t_create());
|
||||
nl_list_append(input, nl_t_create());
|
||||
input = ucl_tuple_create(ucl_t_create(), ucl_t_create());
|
||||
ucl_list_append(input, ucl_t_create());
|
||||
|
||||
TEST_ASSERT_EQUAL(nl_list_length(input)->integer, 3);
|
||||
TEST_ASSERT_EQUAL(ucl_list_length(input)->integer, 3);
|
||||
}
|
||||
|
||||
static void test_list_nth_nil_0() {
|
||||
response = nl_list_nth(nl_nil_create(), 0);
|
||||
response = ucl_list_nth(ucl_nil_create(), 0);
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_nil_1() {
|
||||
response = nl_list_nth(nl_nil_create(), 1);
|
||||
response = ucl_list_nth(ucl_nil_create(), 1);
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_list_0() {
|
||||
response = nl_list_nth(
|
||||
nl_tuple_create(
|
||||
nl_t_create(),
|
||||
nl_string_create(strdup("foo"))),
|
||||
response = ucl_list_nth(
|
||||
ucl_tuple_create(
|
||||
ucl_t_create(),
|
||||
ucl_string_create(strdup("foo"))),
|
||||
0);
|
||||
|
||||
TEST_ASSERT_T(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_list_1() {
|
||||
response = nl_list_nth(
|
||||
nl_tuple_create(
|
||||
nl_t_create(),
|
||||
nl_string_create(strdup("foo"))),
|
||||
response = ucl_list_nth(
|
||||
ucl_tuple_create(
|
||||
ucl_t_create(),
|
||||
ucl_string_create(strdup("foo"))),
|
||||
1);
|
||||
|
||||
TEST_ASSERT_OBJ_STRING(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_t_0() {
|
||||
response = nl_list_nth(nl_t_create(), 1);
|
||||
response = ucl_list_nth(ucl_t_create(), 1);
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_bounds_0() {
|
||||
response = nl_list_nth(nl_nil_create(), 0);
|
||||
response = ucl_list_nth(ucl_nil_create(), 0);
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
}
|
||||
|
||||
static void test_list_nth_bounds_1() {
|
||||
response = nl_list_nth(
|
||||
nl_cell_create(
|
||||
nl_nil_create(),
|
||||
response = ucl_list_nth(
|
||||
ucl_cell_create(
|
||||
ucl_nil_create(),
|
||||
NULL),
|
||||
1);
|
||||
|
||||
@@ -185,10 +185,10 @@ static void test_list_nth_bounds_1() {
|
||||
}
|
||||
|
||||
static void test_list_nth_bounds_2() {
|
||||
response = nl_list_nth(
|
||||
nl_tuple_create(
|
||||
nl_nil_create(),
|
||||
nl_nil_create()),
|
||||
response = ucl_list_nth(
|
||||
ucl_tuple_create(
|
||||
ucl_nil_create(),
|
||||
ucl_nil_create()),
|
||||
2);
|
||||
|
||||
TEST_ASSERT_OBJ_ERROR(response);
|
||||
|
||||
Reference in New Issue
Block a user