Skip to content

Commit

Permalink
Merge pull request #123 from moormaster/fix-fail-if-line-matches-inco…
Browse files Browse the repository at this point in the history
…mpletely-that-should-not-match-at-all

fix: make challenge fail when lines match incompletely but should not match at all
  • Loading branch information
niccokunzmann authored May 2, 2024
2 parents ca83c21 + 21faa6c commit d045118
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions _layouts/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
content: "{{ site.data.localization.match.matchedIncompletely[page.lang] }}";
}

.playfield.verbose .incompletematch.fail:after {
content: "{{ site.data.localization.match.shouldNotMatch[page.lang] }}";
}

.playfield.verbose .match.ok:after {
content: "{{ site.data.localization.match.matched[page.lang] }}";
}
Expand Down
3 changes: 3 additions & 0 deletions css/playfield.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
.playfield .incompletematch.ok {
background-color: {{ site.data.colors.fails }};
}
.playfield .incompletematch.fail {
background-color: {{ site.data.colors.fails }};
}
.playfield .nomatch.ok {
background-color: {{ site.data.colors.fails }};
}
Expand Down
5 changes: 3 additions & 2 deletions js/playfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ function watchExpression(playfield, examples, regex, message) {

matchExample(match, isIncomplete, text, example);

// enforce overall result to fail if any match is incomplete
match = !isIncomplete;
// enforce overall result to fail if any expected match is incomplete
if (referenceInfo.shouldMatchWholeLine && !shouldNotMatch)
match = match && !isIncomplete;
} else {
unmatchExample(example);
}
Expand Down

0 comments on commit d045118

Please sign in to comment.