@@ -318,7 +318,7 @@ fn parse_test_function_definition_statement(input: &str) -> IResult<&str, Statem
318318 |( _, name, _, block) | {
319319 Statement :: TestDef ( Function {
320320 name : name. to_string ( ) ,
321- kind : Type :: TBool , // Sempre bool (mesmo se não declarou)
321+ kind : Type :: TVoid , // Sempre void
322322 params : Vec :: new ( ) , // Nenhum argumento
323323 body : Some ( Box :: new ( block) ) ,
324324 } )
@@ -494,7 +494,7 @@ mod tests {
494494 let input = "test test_example(): x = 1; end" ;
495495 let expected = Statement :: TestDef ( Function {
496496 name : "test_example" . to_string ( ) ,
497- kind : Type :: TBool ,
497+ kind : Type :: TVoid ,
498498 params : vec ! [ ] ,
499499 body : Some ( Box :: new ( Statement :: Block ( vec ! [ Statement :: Assignment (
500500 "x" . to_string( ) ,
@@ -510,7 +510,7 @@ mod tests {
510510 let input = "test test_spaces( ): x = 2; end" ;
511511 let expected = Statement :: TestDef ( Function {
512512 name : "test_spaces" . to_string ( ) ,
513- kind : Type :: TBool ,
513+ kind : Type :: TVoid ,
514514 params : vec ! [ ] ,
515515 body : Some ( Box :: new ( Statement :: Block ( vec ! [ Statement :: Assignment (
516516 "x" . to_string( ) ,
@@ -558,4 +558,50 @@ mod tests {
558558 ) ;
559559 }
560560 //TODO: Implementar testes para os ASSERTS
561+
562+ #[ test]
563+ fn test_parse_asserteq_statement ( ) {
564+ let input = "asserteq(1, 2, \" msg\" )" ;
565+ let expected = Statement :: AssertEQ (
566+ Box :: new ( Expression :: CInt ( 1 ) ) ,
567+ Box :: new ( Expression :: CInt ( 2 ) ) ,
568+ Box :: new ( Expression :: CString ( "msg" . to_string ( ) ) ) ,
569+ ) ;
570+ let parsed = parse_asserteq_statement ( input) . unwrap ( ) . 1 ;
571+ assert_eq ! ( parsed, expected) ;
572+ }
573+
574+ #[ test]
575+ fn test_parse_assertneq_statement ( ) {
576+ let input = "assertneq(3, 4, \" fail\" )" ;
577+ let expected = Statement :: AssertNEQ (
578+ Box :: new ( Expression :: CInt ( 3 ) ) ,
579+ Box :: new ( Expression :: CInt ( 4 ) ) ,
580+ Box :: new ( Expression :: CString ( "fail" . to_string ( ) ) ) ,
581+ ) ;
582+ let parsed = parse_assertneq_statement ( input) . unwrap ( ) . 1 ;
583+ assert_eq ! ( parsed, expected) ;
584+ }
585+
586+ #[ test]
587+ fn test_parse_asserttrue_statement ( ) {
588+ let input = "asserttrue(True, \" should be true\" )" ;
589+ let expected = Statement :: AssertTrue (
590+ Box :: new ( Expression :: CTrue ) ,
591+ Box :: new ( Expression :: CString ( "should be true" . to_string ( ) ) ) ,
592+ ) ;
593+ let parsed = parse_asserttrue_statement ( input) . unwrap ( ) . 1 ;
594+ assert_eq ! ( parsed, expected) ;
595+ }
596+
597+ #[ test]
598+ fn test_parse_assertfalse_statement ( ) {
599+ let input = "assertfalse(False, \" should be false\" )" ;
600+ let expected = Statement :: AssertFalse (
601+ Box :: new ( Expression :: CFalse ) ,
602+ Box :: new ( Expression :: CString ( "should be false" . to_string ( ) ) ) ,
603+ ) ;
604+ let parsed = parse_assertfalse_statement ( input) . unwrap ( ) . 1 ;
605+ assert_eq ! ( parsed, expected) ;
606+ }
561607}
0 commit comments