Skip to content

Commit 4614921

Browse files
Merge pull request #771 from ossf/regex0_tests
Add more tests to regex0
2 parents 193cbfb + 6f6b3e6 commit 4614921

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

docs/labs/regex0.js

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,76 @@
11
info =
22
{
3+
// Note: Regular expressions are preprocessed specially in this lab.
4+
// We simply remove whitespace in them.
35
hints: [
46
{
57
present: "^$",
6-
text: "You need to enter a pattern."
8+
text: "You need to enter a pattern.",
9+
examples: [
10+
[ "" ]
11+
],
712
},
813
{
914
present: String.raw`^\^`,
10-
text: "We are looking for 'cat' anywhere, not just the beginning, in this exercise."
15+
text: "We are looking for 'cat' anywhere, not just the beginning, in this exercise.",
16+
examples: [
17+
[ "^cat" ],
18+
],
1119
},
1220
{
1321
present: "C",
1422
text: "Regexes are normally case-sensitive. Use a lowercase c.",
1523
examples: [
16-
[ "C" ]
24+
[ "C" ],
1725
],
1826
},
1927
{
2028
absent: "c",
2129
text: "If you are searching for \"cat\" you need to look for a \"c\"",
2230
examples: [
23-
[ "x" ]
31+
[ "x" ],
2432
],
2533
},
2634
{
2735
absent: "cat",
28-
text: "The pattern \"cat\" is needed to search for \"cat\"."
36+
text: "The pattern \"cat\" is needed to search for \"cat\".",
37+
examples: [
38+
[ "c" ],
39+
],
2940
},
3041
{
3142
absent: "A",
3243
index: 1,
33-
text: "You need to mention A."
44+
text: "You need to mention A.",
45+
examples: [
46+
[ "cat", "B" ],
47+
],
3448
},
3549
{
36-
absent: "B",
50+
absent: String.raw`A(\+|A\*)`,
3751
index: 1,
38-
text: "You need to mention B."
52+
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\".",
53+
examples: [
54+
[ "cat", "A" ],
55+
[ "cat", "AA" ],
56+
],
3957
},
4058
{
41-
absent: String.raw`A(\+|A\*)`,
59+
absent: "B",
4260
index: 1,
43-
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\"."
61+
text: "You need to mention B.",
62+
examples: [
63+
[ "cat", "A+" ],
64+
],
4465
},
4566
{
4667
absent: String.raw`B(\+|B\*)`,
68+
present: 'A',
4769
index: 1,
48-
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\"."
70+
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\".",
71+
examples: [
72+
[ "cat", "A+B" ],
73+
],
4974
},
5075
],
5176
expected: [
@@ -68,7 +93,7 @@ info =
6893
preprocessing: [
6994
[
7095
"\\s*",
71-
""
96+
"",
7297
],
7398
],
7499
};

0 commit comments

Comments
 (0)