Handle NULL result from read_expression() in REPL
This commit is contained in:
@@ -20,6 +20,13 @@ static bool print_called;
|
||||
static const char *print_output;
|
||||
static int print_len;
|
||||
|
||||
static void reset_fixtures(void)
|
||||
{
|
||||
read_called = false;
|
||||
evaluate_called = false;
|
||||
print_called = false;
|
||||
}
|
||||
|
||||
static int test_get_byte(void)
|
||||
{
|
||||
if (0 == input_len)
|
||||
@@ -72,6 +79,7 @@ static void set_up_valid_state(void)
|
||||
|
||||
static void read_is_called_on_first_line_line_in_input(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
step_repl(&repl);
|
||||
ASSERT_TRUE(read_called);
|
||||
@@ -81,6 +89,7 @@ static void read_is_called_on_first_line_line_in_input(void)
|
||||
|
||||
static void read_result_is_passed_to_evaluate(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
step_repl(&repl);
|
||||
ASSERT_TRUE(evaluate_called);
|
||||
@@ -90,6 +99,7 @@ static void read_result_is_passed_to_evaluate(void)
|
||||
|
||||
static void result_of_evaluation_is_printed_with_a_newline(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
step_repl(&repl);
|
||||
ASSERT_TRUE(print_called);
|
||||
@@ -99,6 +109,7 @@ static void result_of_evaluation_is_printed_with_a_newline(void)
|
||||
|
||||
static void true_is_returned_on_successful_step(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
const bool result = step_repl(&repl);
|
||||
ASSERT_TRUE(result);
|
||||
@@ -106,12 +117,22 @@ static void true_is_returned_on_successful_step(void)
|
||||
|
||||
static void false_is_returned_on_end_of_input(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
input_len = 0;
|
||||
const bool result = step_repl(&repl);
|
||||
ASSERT_FALSE(result);
|
||||
}
|
||||
|
||||
static void evaluate_is_not_called_if_read_returns_null(void)
|
||||
{
|
||||
reset_fixtures();
|
||||
set_up_valid_state();
|
||||
read_result = NULL;
|
||||
step_repl(&repl);
|
||||
ASSERT_FALSE(evaluate_called);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TESTING_BEGIN();
|
||||
@@ -120,5 +141,6 @@ int main(void)
|
||||
RUN_TEST(result_of_evaluation_is_printed_with_a_newline);
|
||||
RUN_TEST(true_is_returned_on_successful_step);
|
||||
RUN_TEST(false_is_returned_on_end_of_input);
|
||||
RUN_TEST(evaluate_is_not_called_if_read_returns_null);
|
||||
TESTING_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user