test func "boolean?"
This commit is contained in:
parent
f45261214f
commit
23fbcd8877
2 changed files with 80 additions and 1 deletions
79
main.c
79
main.c
|
@ -59,8 +59,12 @@ void run()
|
||||||
Object_print(result, 0);
|
Object_print(result, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_booleanQN();
|
||||||
|
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
|
test_booleanQN();
|
||||||
|
|
||||||
struct Object *const sym_foo = Object_new_symbol("foo");
|
struct Object *const sym_foo = Object_new_symbol("foo");
|
||||||
struct Object *const sharp_true = Object_new_boolean(true);
|
struct Object *const sharp_true = Object_new_boolean(true);
|
||||||
struct Object *const num_123 = Object_new_number(123);
|
struct Object *const num_123 = Object_new_number(123);
|
||||||
|
@ -344,3 +348,78 @@ void test()
|
||||||
assert(IS_FALSE(result));
|
assert(IS_FALSE(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_booleanQN()
|
||||||
|
{
|
||||||
|
struct Object *result = NULL;
|
||||||
|
|
||||||
|
// (boolean? #t)
|
||||||
|
// #t
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_boolean(true)
|
||||||
|
));
|
||||||
|
assert(IS_TRUE(result));
|
||||||
|
|
||||||
|
// (boolean? #f)
|
||||||
|
// #t
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_boolean(false)
|
||||||
|
));
|
||||||
|
assert(IS_TRUE(result));
|
||||||
|
|
||||||
|
// (boolean? #\n)
|
||||||
|
// #f
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_char('\n')
|
||||||
|
));
|
||||||
|
assert(IS_FALSE(result));
|
||||||
|
|
||||||
|
// (boolean? 'foo)
|
||||||
|
// #f
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("quote"),
|
||||||
|
Object_new_symbol("foo")
|
||||||
|
)
|
||||||
|
));
|
||||||
|
assert(IS_FALSE(result));
|
||||||
|
|
||||||
|
// (boolean? "foo")
|
||||||
|
// #f
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_string("foo")
|
||||||
|
));
|
||||||
|
assert(IS_FALSE(result));
|
||||||
|
|
||||||
|
// (boolean? 123)
|
||||||
|
// #f
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_number(123)
|
||||||
|
));
|
||||||
|
assert(IS_FALSE(result));
|
||||||
|
|
||||||
|
// (boolean? (cons 123 456))
|
||||||
|
// #f
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
|
result = builtins_eval(Object_build_list(
|
||||||
|
2,
|
||||||
|
Object_new_symbol("boolean?"),
|
||||||
|
Object_new_pair(Object_new_number(123), Object_new_number(456))
|
||||||
|
));
|
||||||
|
assert(IS_FALSE(result));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
2
object.c
2
object.c
|
@ -33,7 +33,7 @@ struct Object *Object_new_boolean(const bool boolean)
|
||||||
|
|
||||||
struct Object *Object_new_char(const char chr)
|
struct Object *Object_new_char(const char chr)
|
||||||
{
|
{
|
||||||
struct Object *const object = new(TYPE_BOOLEAN);
|
struct Object *const object = new(TYPE_CHAR);
|
||||||
object->chr = chr;
|
object->chr = chr;
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue