Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parser tests using multi-words #9

Merged
merged 4 commits into from
Jun 15, 2024

Conversation

mausimus
Copy link
Contributor

I've added a range of tests for using multi-words in the parser; apologies if it looks a bit overkill but I think the issues around the parsing function we've recently found warrant a comprehensive approach. These tests need current master to fully pass.

@ericoporto
Copy link
Member

ericoporto commented Jun 15, 2024

Thanks, this looks alright, I just noticed that for some reason some unrelated graphics rendering tests are failing so I will just give a check on that.

Specifically on this pr

These tests need current master to fully pass.

So it doesn't need adventuregamestudio/ags#2443 to pass here?

@mausimus
Copy link
Contributor Author

Thanks, no it doesn't need that new PR at the moment; I have written some extra tests after I found that bug though, should I add them here now or wait until the fix PR gets merged to ags master?

@ivan-mogilko
Copy link
Contributor

I have written some extra tests after I found that bug though, should I add them here now or wait until the fix PR gets merged to ags master?

It makes sense to add new tests right away, if they fail that would be also useful, that's what tests are for :).

@mausimus
Copy link
Contributor Author

Ok no problem, I added the test that adventuregamestudio/ags#2443 fixes.

@ericoporto ericoporto merged commit c414743 into adventuregamestudio:main Jun 15, 2024
2 checks passed
@ericoporto
Copy link
Member

@mausimus I merged mostly because I was curious to see this running in you PR, but now I notice I don't understand a specific "please" wording in this function. Can you explain me what this function is doing?

void TestParserSaid(const string saidWords, const string inputText, int expectedResult)
{
    Parser.ParseText(inputText);
    String testName = String.Format("TestParserSaid: Said() '%s' with ParseText() '%s' should be %d", saidWords, inputText, expectedResult);

    if(expectedResult)
      tap.ok(Parser.Said(saidWords), testName);
    else
      tap.nok(Parser.Said(saidWords), testName);

    // test with extra content at the end
    String extendedWords = String.Format("%s rol", saidWords);
    String extendedText = String.Format("%s please", inputText);
    Parser.ParseText(extendedText);
    testName = String.Format("TestParserSaid: Said() '%s' with ParseText() '%s' should be %d", extendedWords, extendedText, expectedResult);

    if(expectedResult)
      tap.ok(Parser.Said(extendedWords), testName);
    else
      tap.nok(Parser.Said(extendedWords), testName);
}

@mausimus
Copy link
Contributor Author

Sure, I added this "extended" pass to make sure there's no difference if the words are at the end of the input or not (I've found some issues relating to parsing at the very end of the input earlier on), so it just adds "rol" to the pattern and "please" ignored word to the input, which shouldn't have any impact on the parsing result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants