1
0
Fork 0

test func "pair?"

This commit is contained in:
Alex Kotov 2023-05-04 23:20:37 +04:00
parent 807c3d69ae
commit 9db503971e
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

78
main.c
View file

@ -149,6 +149,7 @@ static void test_booleanQN();
static void test_charQN();
static void test_nullQN();
static void test_numberQN();
static void test_pairQN();
// Logical operators
static void test_not();
@ -161,6 +162,7 @@ void test()
test_charQN();
test_nullQN();
test_numberQN();
test_pairQN();
// Logical operators
test_not();
@ -546,6 +548,82 @@ void test_numberQN()
))));
}
void test_pairQN()
{
// (pair? '())
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
NULL
))));
// (pair? #t)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_new_boolean(true)
))));
// (pair? #f)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_new_boolean(false)
))));
// (pair? #\n)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_new_char('\n')
))));
// (pair? 'foo)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_build_list(
2,
Object_new_symbol("quote"),
Object_new_symbol("foo")
)
))));
// (pair? "foo")
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_new_string("foo")
))));
// (pair? 123)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_new_number(123)
))));
// (pair? (cons 123 456))
// #t
assert(Object_is_true(eval(Object_build_list(
2,
Object_new_symbol("pair?"),
Object_build_list(
3,
Object_new_symbol("cons"),
Object_new_number(123),
Object_new_number(456)
)
))));
}
void test_not()
{
// (not '())