1
0
Fork 0

test func "string?"

This commit is contained in:
Alex Kotov 2023-05-04 23:22:09 +04:00
parent 9db503971e
commit 2e700fc239
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

78
main.c
View file

@ -150,6 +150,7 @@ static void test_charQN();
static void test_nullQN();
static void test_numberQN();
static void test_pairQN();
static void test_stringQN();
// Logical operators
static void test_not();
@ -163,6 +164,7 @@ void test()
test_nullQN();
test_numberQN();
test_pairQN();
test_stringQN();
// Logical operators
test_not();
@ -624,6 +626,82 @@ void test_pairQN()
))));
}
void test_stringQN()
{
// (string? '())
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
NULL
))));
// (string? #t)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_new_boolean(true)
))));
// (string? #f)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_new_boolean(false)
))));
// (string? #\n)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_new_char('\n')
))));
// (string? 'foo)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_build_list(
2,
Object_new_symbol("quote"),
Object_new_symbol("foo")
)
))));
// (string? "foo")
// #t
assert(Object_is_true(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_new_string("foo")
))));
// (string? 123)
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_new_number(123)
))));
// (string? (cons 123 456))
// #f
assert(Object_is_false(eval(Object_build_list(
2,
Object_new_symbol("string?"),
Object_build_list(
3,
Object_new_symbol("cons"),
Object_new_number(123),
Object_new_number(456)
)
))));
}
void test_not()
{
// (not '())