test func "pair?"
This commit is contained in:
parent
807c3d69ae
commit
9db503971e
1 changed files with 78 additions and 0 deletions
78
main.c
78
main.c
|
@ -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 '())
|
||||
|
|
Loading…
Add table
Reference in a new issue