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

turn string tags to regexes #30

Merged
merged 4 commits into from
Sep 13, 2015
Merged

turn string tags to regexes #30

merged 4 commits into from
Sep 13, 2015

Conversation

DarthKipsu
Copy link
Contributor

This will fix #25

private static final String END_SOLUTION_TAG = "// END SOLUTION";
private static final String STUB_TAG = "// STUB:";
private static final String SOLUTION_FILE_TAG = "// SOLUTION FILE";
private static final String BEGIN_SOLUTION_REGEX = ".*\\/\\/[ \\t]?BEGIN[ \\t]SOLUTION.*";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ \\t] seems like a smart choice since \s contains \n, \r etc. and we don't really want to match those. Is there a specific reason to match for ? instead of * occurrences?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?'s were relics from my first version of the regex. Changed them and added + to the spaces between words, to make sure there always is a space but not take stand on how many.

@ljleppan
Copy link
Member

Should probably add some new test cases to ExerciseBuilderTest (or modify existing test resources) so that we don't only test against lines that match the old tags, but a wider range of the now allowed range of tag formats.

Other than that (and the single note above), LGTM.

@DarthKipsu
Copy link
Contributor Author

I updated the regexes a bit and added test cases for them.

private static final String BEGIN_SOLUTION_REGEX = ".*\\/\\/[ \\t]*BEGIN[ \\t]+SOLUTION.*";
private static final String END_SOLUTION_REGEX = ".*\\/\\/[ \\t]*END[ \\t]+SOLUTION.*";
private static final String SOLUTION_FILE_REGEX = ".*\\/\\/[ \\t]*SOLUTION[ \\t]+FILE.*";
private static final String STUB_REGEX = "(.*)\\/\\/[ \\t]*STUB:[ \\t]*(.*)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we want to have the .* in the beginning, maybe we want just to allow having whitespace before these tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just changed it.

@@ -81,7 +81,12 @@ public void solutionFilesAreIgnoredFromStub() throws IOException {
temp.toFile().deleteOnExit();
exerciseBuilder.prepareStub(temp);
Path solutionFile = temp.resolve(Paths.get("src", "SolutionFile.java"));
Path solutionFile2 = temp.resolve(Paths.get("src", "SolutionFileWithNoSpace.java"));
Path solutionFile3 = temp.resolve(Paths.get("src", "SolutionFileWithExtraSpaces.java"));

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty row

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because it makes the test more readable.

jamo added a commit that referenced this pull request Sep 13, 2015
Use regex for detecting BEGIN/END SOLUTION and STUBs
@jamo jamo merged commit 50f7914 into testmycode:master Sep 13, 2015
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.

Make exercise template parser consistent with TMC-server
4 participants