adding print and branch

This commit is contained in:
Josh 2024-10-31 09:05:35 -07:00
parent bf1248b078
commit ac108c6bc8
1 changed files with 28 additions and 1 deletions

View File

@ -55,4 +55,31 @@ UTEST(parser, hello) {
// Assert the result to test correctness // Assert the result to test correctness
ASSERT_EQ(result, 0); ASSERT_EQ(result, 0);
} }
UTEST(parser, print) {
// Must include the null character to terminate input
char string[] = "DISPLAY 'Hello World!'\0";
YY_BUFFER_STATE buffer = yy_scan_buffer(string, sizeof(string));
yylineno = 1;
int result = yyparse();
yy_delete_buffer(buffer);
// Assert the result to test correctness
ASSERT_EQ(result, 0);
}
UTEST(parser, branching) {
// Must include the null character to terminate input
char string[] = "IF A > B THEN DISPLAY 'A is greater than B' ELSE DISPLAY 'B is greater than A'\0";
YY_BUFFER_STATE buffer = yy_scan_buffer(string, sizeof(string));
yylineno = 1;
int result = yyparse();
yy_delete_buffer(buffer);
// Assert the result to test correctness
ASSERT_EQ(result, 0);
}