@@ -67,7 +67,6 @@ ps_ast_block *ps_ast_test_create_block_program(const char *name)
6767 ASSERT_GOTO_CLEANUP (block_program -> column == 1 );
6868 ASSERT_GOTO_CLEANUP (strcmp (block_program -> name , name ) == 0 );
6969 ASSERT_GOTO_CLEANUP (block_program -> n_vars == 0 );
70- ASSERT_GOTO_CLEANUP (block_program -> symbols != NULL );
7170 ASSERT_GOTO_CLEANUP (block_program -> n_executables == 0 );
7271 ASSERT_GOTO_CLEANUP (block_program -> executables == NULL );
7372 ASSERT_GOTO_CLEANUP (block_program -> statement_list == NULL );
@@ -82,9 +81,18 @@ ps_ast_block *ps_ast_test_create_block_program(const char *name)
8281
8382bool ps_ast_test_delete_block_program (ps_ast_block * block_program )
8483{
84+ if (block_program -> symbols != NULL )
85+ {
86+ ps_ast_debug_line (0 , "Free symbol table for program %s" , block_program -> name );
87+ ps_memory_free (PS_MEMORY_SYMBOL , block_program -> symbols -> symbols );
88+ ps_memory_free (PS_MEMORY_AST , block_program -> symbols );
89+ block_program -> symbols = NULL ;
90+ }
91+
8592 ps_ast_debug_line (0 , "Free the PROGRAM block node" );
8693 block_program = (ps_ast_block * )ps_ast_free_block (block_program );
8794 ASSERT_RETURN_FALSE (block_program == NULL );
95+
8896 return true;
8997}
9098
@@ -253,13 +261,9 @@ bool ps_ast_test_assignment()
253261 ps_memory_free (PS_MEMORY_AST , block_program -> symbols );
254262 block_program -> symbols = NULL ;
255263
256- ps_ast_debug_line (0 , "Free program %s" , block_program -> name );
257- block_program = (ps_ast_block * )ps_ast_free_block (block_program );
258- ASSERT_RETURN_FALSE (block_program == NULL );
264+ ps_ast_test_delete_interpreter (interpreter , block_program );
259265
260- ps_ast_debug_line (0 , "Free interpreter" );
261- interpreter = ps_interpreter_free (interpreter );
262- ASSERT_RETURN_FALSE (interpreter == NULL );
266+ ps_ast_test_delete_block_program (block_program );
263267
264268 return true;
265269}
@@ -303,7 +307,7 @@ bool ps_ast_test_hello()
303307 ps_ast_debug_line (0 , "Create the argument list for the procedure call" );
304308 ps_ast_node * * args1 = ps_memory_calloc (PS_MEMORY_AST , 1 , sizeof (ps_ast_node * ));
305309 ASSERT_RETURN_FALSE (args1 != NULL );
306- args1 [0 ] = argument_hello ;
310+ args1 [0 ] = ( ps_ast_node * ) argument_hello ;
307311
308312 ps_ast_debug_line (0 , "Create the first PROCEDURE CALL statement" );
309313 ps_ast_call * statement1 = ps_ast_create_call (3 , 5 , PS_AST_PROCEDURE_CALL , & ps_system_procedure_writeln , 1 , args1 );
@@ -312,7 +316,7 @@ bool ps_ast_test_hello()
312316 ps_ast_debug_line (0 , "Create the argument list for the second procedure call" );
313317 ps_ast_node * * args2 = ps_memory_calloc (PS_MEMORY_AST , 1 , sizeof (ps_ast_node * ));
314318 ASSERT_RETURN_FALSE (args2 != NULL );
315- args2 [0 ] = argument_i_42 ;
319+ args2 [0 ] = ( ps_ast_node * ) argument_i_42 ;
316320
317321 ps_ast_debug_line (0 , "Create the second PROCEDURE CALL statement" );
318322 ps_ast_call * statement2 = ps_ast_create_call (3 , 5 , PS_AST_PROCEDURE_CALL , & ps_system_procedure_writeln , 1 , args2 );
@@ -336,17 +340,9 @@ bool ps_ast_test_hello()
336340 ps_error_get_message (interpreter -> error ));
337341 }
338342
339- ps_ast_debug_line (0 , "Free symbol table for the program %s" , block_program -> name );
340- ps_memory_free (PS_MEMORY_AST , block_program -> symbols );
341- block_program -> symbols = NULL ;
342-
343- ps_ast_debug_line (0 , "Free program %s" , block_program -> name );
344- block_program = (ps_ast_block * )ps_ast_free_block (block_program );
345- ASSERT_RETURN_FALSE (block_program == NULL );
343+ ps_ast_test_delete_interpreter (interpreter , block_program );
346344
347- ps_ast_debug_line (0 , "Free interpreter" );
348- interpreter = ps_interpreter_free (interpreter );
349- ASSERT_RETURN_FALSE (interpreter == NULL );
345+ ps_ast_test_delete_block_program (block_program );
350346
351347 return true;
352348}
0 commit comments