Skip to content

Commit

Permalink
Add more tests to regex0
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
  • Loading branch information
david-a-wheeler committed Feb 1, 2025
1 parent 7226302 commit 6f6b3e6
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions docs/labs/regex0.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,76 @@
info =
{
// Note: Regular expressions are preprocessed specially in this lab.
// We simply remove whitespace in them.
hints: [
{
present: "^$",
text: "You need to enter a pattern."
text: "You need to enter a pattern.",
examples: [
[ "" ]
],
},
{
present: String.raw`^\^`,
text: "We are looking for 'cat' anywhere, not just the beginning, in this exercise."
text: "We are looking for 'cat' anywhere, not just the beginning, in this exercise.",
examples: [
[ "^cat" ],
],
},
{
present: "C",
text: "Regexes are normally case-sensitive. Use a lowercase c.",
examples: [
[ "C" ]
[ "C" ],
],
},
{
absent: "c",
text: "If you are searching for \"cat\" you need to look for a \"c\"",
examples: [
[ "x" ]
[ "x" ],
],
},
{
absent: "cat",
text: "The pattern \"cat\" is needed to search for \"cat\"."
text: "The pattern \"cat\" is needed to search for \"cat\".",
examples: [
[ "c" ],
],
},
{
absent: "A",
index: 1,
text: "You need to mention A."
text: "You need to mention A.",
examples: [
[ "cat", "B" ],
],
},
{
absent: "B",
absent: String.raw`A(\+|A\*)`,
index: 1,
text: "You need to mention B."
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\".",
examples: [
[ "cat", "A" ],
[ "cat", "AA" ],
],
},
{
absent: String.raw`A(\+|A\*)`,
absent: "B",
index: 1,
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\"."
text: "You need to mention B.",
examples: [
[ "cat", "A+" ],
],
},
{
absent: String.raw`B(\+|B\*)`,
present: 'A',
index: 1,
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\"."
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\".",
examples: [
[ "cat", "A+B" ],
],
},
],
expected: [
Expand All @@ -68,7 +93,7 @@ info =
preprocessing: [
[
"\\s*",
""
"",
],
],
};

0 comments on commit 6f6b3e6

Please sign in to comment.