From 2e700fc239f2c3408ad512991993baf9882d498a Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 4 May 2023 23:22:09 +0400 Subject: [PATCH] test func "string?" --- main.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/main.c b/main.c index b1364c2..6da3ace 100644 --- a/main.c +++ b/main.c @@ -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 '())