test func "string?"
This commit is contained in:
parent
9db503971e
commit
2e700fc239
1 changed files with 78 additions and 0 deletions
78
main.c
78
main.c
|
@ -150,6 +150,7 @@ static void test_charQN();
|
||||||
static void test_nullQN();
|
static void test_nullQN();
|
||||||
static void test_numberQN();
|
static void test_numberQN();
|
||||||
static void test_pairQN();
|
static void test_pairQN();
|
||||||
|
static void test_stringQN();
|
||||||
// Logical operators
|
// Logical operators
|
||||||
static void test_not();
|
static void test_not();
|
||||||
|
|
||||||
|
@ -163,6 +164,7 @@ void test()
|
||||||
test_nullQN();
|
test_nullQN();
|
||||||
test_numberQN();
|
test_numberQN();
|
||||||
test_pairQN();
|
test_pairQN();
|
||||||
|
test_stringQN();
|
||||||
// Logical operators
|
// Logical operators
|
||||||
test_not();
|
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()
|
void test_not()
|
||||||
{
|
{
|
||||||
// (not '())
|
// (not '())
|
||||||
|
|
Loading…
Add table
Reference in a new issue