You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
#include "ptlisp-test.h" |
|
#include "../src/lisp.h" |
|
|
|
START_TEST(environment_get_nil_test) { |
|
ck_assert_uint_eq(environment_get(NIL, 69), UNDEFINED); |
|
} |
|
END_TEST |
|
|
|
START_TEST(environment_get_missing_test) { |
|
ck_assert_uint_eq(environment_get(cons(table(1), NIL), 69), UNDEFINED); |
|
} |
|
END_TEST |
|
|
|
START_TEST(environment_get_exist_test) { |
|
Pointer tbl = table(1); |
|
table_set(tbl, 69, 420); |
|
Pointer env = cons(tbl, NIL); |
|
tbl = table(1); |
|
env = cons(tbl, env); |
|
ck_assert_uint_eq(environment_get(env, 69), 420); |
|
} |
|
END_TEST |
|
|
|
static void setup(void) { |
|
memory_init(16); |
|
symbol_init(); |
|
environment_init(); |
|
} |
|
|
|
static void teardown(void) { |
|
memory_free(); |
|
} |
|
|
|
Suite* make_environment_test_suite(void) { |
|
Suite *s1 = suite_create("Environment"); |
|
TCase *tc1_1 = tcase_create("Environment"); |
|
suite_add_tcase(s1, tc1_1); |
|
|
|
tcase_add_checked_fixture(tc1_1, setup, teardown); |
|
tcase_add_test(tc1_1, environment_get_nil_test); |
|
tcase_add_test(tc1_1, environment_get_missing_test); |
|
tcase_add_test(tc1_1, environment_get_exist_test); |
|
|
|
return s1; |
|
}
|
|
|