From 6f6b3e6274f7aefe5085d8b3b564b06e94ce0638 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Sat, 1 Feb 2025 11:27:37 -0500 Subject: [PATCH] Add more tests to regex0 Signed-off-by: David A. Wheeler --- docs/labs/regex0.js | 49 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/docs/labs/regex0.js b/docs/labs/regex0.js index 4d65cebb..51d16328 100644 --- a/docs/labs/regex0.js +++ b/docs/labs/regex0.js @@ -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: [ @@ -68,7 +93,7 @@ info = preprocessing: [ [ "\\s*", - "" + "", ], ], };