From 059f7b212c3acb028b4e11eca7f40edf5dff154c Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Fri, 6 Jun 2025 05:16:16 +0800 Subject: [PATCH 1/7] Add new test cases for complex patterns in stage alternation --- internal/stage_alternation.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index ab74d77..2a52ae4 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -11,16 +11,21 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { Input: "a cat", ExpectedExitCode: 0, }, - { - Pattern: "a (cat|dog) and (cat|dog)s", - Input: "a dog and cats", - ExpectedExitCode: 0, - }, { Pattern: "a (cat|dog)", Input: "a cow", ExpectedExitCode: 1, }, + { + Pattern: "^((Buffalo|buffalo)[ ]?)+$", + Input: "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo", + ExpectedExitCode: 0, + }, + { + Pattern: "^((W|w)ill(, | |'s )?)+$", + Input: "Will, will Will will Will Will's will", + ExpectedExitCode: 0, + }, } return RunTestCases(testCases, stageHarness) From 55145d131e5a12c1e9beb289a5aadc5dc3535e7c Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Fri, 6 Jun 2025 05:18:00 +0800 Subject: [PATCH 2/7] Add new test cases for complex patterns in stage backreferences --- internal/test_helpers/fixtures/alternation/success | 9 ++++++--- .../fixtures/backreferences_multiple/success | 9 ++++++--- .../test_helpers/fixtures/backreferences_nested/success | 9 ++++++--- .../test_helpers/fixtures/backreferences_single/success | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index e632809..0522897 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -2,11 +2,14 @@ [stage-12] $ echo -n "a cat" | ./your_grep.sh -E "a (cat|dog)" [your_program] a cat [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "a dog and cats" | ./your_grep.sh -E "a (cat|dog) and (cat|dog)s" -[your_program] a dog and cats -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. +[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[your_program] Will, will Will will Will Will's will +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index 3eecd5e..71566da 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -84,11 +84,14 @@ [stage-12] $ echo -n "a cat" | ./your_grep.sh -E "a (cat|dog)" [your_program] a cat [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "a dog and cats" | ./your_grep.sh -E "a (cat|dog) and (cat|dog)s" -[your_program] a dog and cats -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. +[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[your_program] Will, will Will will Will Will's will +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 6948816..873b1c3 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -125,11 +125,14 @@ [stage-12] $ echo -n "a cat" | ./your_grep.sh -E "a (cat|dog)" [your_program] a cat [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "a dog and cats" | ./your_grep.sh -E "a (cat|dog) and (cat|dog)s" -[your_program] a dog and cats -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. +[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[your_program] Will, will Will will Will Will's will +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index d2614ce..f368987 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -43,11 +43,14 @@ [stage-12] $ echo -n "a cat" | ./your_grep.sh -E "a (cat|dog)" [your_program] a cat [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "a dog and cats" | ./your_grep.sh -E "a (cat|dog) and (cat|dog)s" -[your_program] a dog and cats -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. +[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[your_program] Will, will Will will Will Will's will +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 From 59dd45f62632a55045a0e5374018e7bb2f7fd774 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Fri, 6 Jun 2025 05:39:07 +0800 Subject: [PATCH 3/7] Update regex patterns in test cases for 'will' to be case-insensitive --- internal/stage_alternation.go | 2 +- internal/test_helpers/fixtures/alternation/success | 2 +- internal/test_helpers/fixtures/backreferences_multiple/success | 2 +- internal/test_helpers/fixtures/backreferences_nested/success | 2 +- internal/test_helpers/fixtures/backreferences_single/success | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index 2a52ae4..5f62a14 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -22,7 +22,7 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { ExpectedExitCode: 0, }, { - Pattern: "^((W|w)ill(, | |'s )?)+$", + Pattern: "^([Ww]ill(, | |'s )?)+$", Input: "Will, will Will will Will Will's will", ExpectedExitCode: 0, }, diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index 0522897..86909cb 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -7,7 +7,7 @@ [stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" [your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. [stage-12] Test passed. diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index 71566da..35361fa 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -89,7 +89,7 @@ [stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" [your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. [stage-12] Test passed. diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 873b1c3..4a441d6 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -130,7 +130,7 @@ [stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" [your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. [stage-12] Test passed. diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index f368987..6fc788b 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -48,7 +48,7 @@ [stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" [your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^((W|w)ill(, | |'s )?)+$" +[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. [stage-12] Test passed. From 02e488065d0bc196eaf9ecc52e6d842dbb84f6f4 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Sat, 7 Jun 2025 04:15:31 +0800 Subject: [PATCH 4/7] Update test cases to use a simplified input for 'Buffalo' pattern matching --- internal/stage_alternation.go | 2 +- internal/test_helpers/fixtures/alternation/success | 4 ++-- .../test_helpers/fixtures/backreferences_multiple/success | 4 ++-- internal/test_helpers/fixtures/backreferences_nested/success | 4 ++-- internal/test_helpers/fixtures/backreferences_single/success | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index 5f62a14..ac9a4e4 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -18,7 +18,7 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { }, { Pattern: "^((Buffalo|buffalo)[ ]?)+$", - Input: "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo", + Input: "Buffalo buffalo buffalo Buffalo buffalo", ExpectedExitCode: 0, }, { diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index 86909cb..a2fe85b 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -4,8 +4,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index 35361fa..a4981cb 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -86,8 +86,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 4a441d6..5361b7a 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -127,8 +127,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index 6fc788b..3f28051 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -45,8 +45,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" +[your_program] Buffalo buffalo buffalo Buffalo buffalo [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will From 83fb4138714df67548bab837c26862a5ea72ce1e Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Sat, 7 Jun 2025 04:58:10 +0800 Subject: [PATCH 5/7] Update test cases to replace 'Buffalo' pattern with a new regex for counting animals --- internal/stage_alternation.go | 4 ++-- internal/test_helpers/fixtures/alternation/success | 4 ++-- .../test_helpers/fixtures/backreferences_multiple/success | 4 ++-- internal/test_helpers/fixtures/backreferences_nested/success | 4 ++-- internal/test_helpers/fixtures/backreferences_single/success | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index ac9a4e4..22f9b83 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -17,8 +17,8 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { ExpectedExitCode: 1, }, { - Pattern: "^((Buffalo|buffalo)[ ]?)+$", - Input: "Buffalo buffalo buffalo Buffalo buffalo", + Pattern: "^I see (\\d (cat|dog|cow)s?(, | and )?)+$", + Input: "I see 1 cat, 2 dogs and 3 cows", ExpectedExitCode: 0, }, { diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index a2fe85b..49657b5 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -4,8 +4,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" +[your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index a4981cb..98b5974 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -86,8 +86,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" +[your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 5361b7a..48e1746 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -127,8 +127,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" +[your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index 3f28051..3c4042b 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -45,8 +45,8 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Buffalo buffalo buffalo Buffalo buffalo" | ./your_grep.sh -E "^((Buffalo|buffalo)[ ]?)+$" -[your_program] Buffalo buffalo buffalo Buffalo buffalo +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" +[your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will From 364abe46d0a505f6f17f80b686341f5e664b9e37 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Sat, 7 Jun 2025 04:58:10 +0800 Subject: [PATCH 6/7] Update test cases to replace 'Buffalo' pattern with a new regex for counting animals --- internal/stage_alternation.go | 8 ++++---- internal/test_helpers/fixtures/alternation/success | 6 +++--- .../test_helpers/fixtures/backreferences_multiple/success | 6 +++--- .../test_helpers/fixtures/backreferences_nested/success | 6 +++--- .../test_helpers/fixtures/backreferences_single/success | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index 22f9b83..bbd0eec 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -17,13 +17,13 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { ExpectedExitCode: 1, }, { - Pattern: "^I see (\\d (cat|dog|cow)s?(, | and )?)+$", - Input: "I see 1 cat, 2 dogs and 3 cows", + Pattern: "^([Ww]ill(, | |'s )?)+$", + Input: "Will, will Will will Will Will's will", ExpectedExitCode: 0, }, { - Pattern: "^([Ww]ill(, | |'s )?)+$", - Input: "Will, will Will will Will Will's will", + Pattern: "^I see (\\d (cat|dog|cow)s?(, | and )?)+$", + Input: "I see 1 cat, 2 dogs and 3 cows", ExpectedExitCode: 0, }, } diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index 49657b5..1f79627 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -4,12 +4,12 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" -[your_program] I see 1 cat, 2 dogs and 3 cows -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" +[your_program] I see 1 cat, 2 dogs and 3 cows +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index 98b5974..ed82daf 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -86,12 +86,12 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" -[your_program] I see 1 cat, 2 dogs and 3 cows -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" +[your_program] I see 1 cat, 2 dogs and 3 cows +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 48e1746..26b80a3 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -127,12 +127,12 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" -[your_program] I see 1 cat, 2 dogs and 3 cows -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" +[your_program] I see 1 cat, 2 dogs and 3 cows +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index 3c4042b..26a5f52 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -45,12 +45,12 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "I see (\d (cat|dog|cow)s?(, | and )?)+" -[your_program] I see 1 cat, 2 dogs and 3 cows -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" [your_program] Will, will Will will Will Will's will [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" +[your_program] I see 1 cat, 2 dogs and 3 cows +[stage-12] ✓ Received exit code 0. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 From f0b0d3a45fa4f584bd9e377740b78aa72759cfb0 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Sat, 7 Jun 2025 05:11:02 +0800 Subject: [PATCH 7/7] Update test cases to modify regex patterns for animal counting and adjust expected exit codes --- internal/stage_alternation.go | 8 ++++---- internal/test_helpers/fixtures/alternation/success | 5 ++--- .../test_helpers/fixtures/backreferences_multiple/success | 5 ++--- .../test_helpers/fixtures/backreferences_nested/success | 5 ++--- .../test_helpers/fixtures/backreferences_single/success | 5 ++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/internal/stage_alternation.go b/internal/stage_alternation.go index bbd0eec..508c5ae 100644 --- a/internal/stage_alternation.go +++ b/internal/stage_alternation.go @@ -17,14 +17,14 @@ func testAlternation(stageHarness *test_case_harness.TestCaseHarness) error { ExpectedExitCode: 1, }, { - Pattern: "^([Ww]ill(, | |'s )?)+$", - Input: "Will, will Will will Will Will's will", + Pattern: "^I see (\\d (cat|dog|cow)s?(, | and )?)+$", + Input: "I see 1 cat, 2 dogs and 3 cows", ExpectedExitCode: 0, }, { - Pattern: "^I see (\\d (cat|dog|cow)s?(, | and )?)+$", + Pattern: "^I see (\\d (cat|dog|cow)(, | and )?)+$", Input: "I see 1 cat, 2 dogs and 3 cows", - ExpectedExitCode: 0, + ExpectedExitCode: 1, }, } diff --git a/internal/test_helpers/fixtures/alternation/success b/internal/test_helpers/fixtures/alternation/success index 1f79627..d8a3ce0 100644 --- a/internal/test_helpers/fixtures/alternation/success +++ b/internal/test_helpers/fixtures/alternation/success @@ -4,12 +4,11 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" -[your_program] Will, will Will will Will Will's will -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" [your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)(, | and )?)+$" +[stage-12] ✓ Received exit code 1. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_multiple/success b/internal/test_helpers/fixtures/backreferences_multiple/success index ed82daf..51e280e 100644 --- a/internal/test_helpers/fixtures/backreferences_multiple/success +++ b/internal/test_helpers/fixtures/backreferences_multiple/success @@ -86,12 +86,11 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" -[your_program] Will, will Will will Will Will's will -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" [your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)(, | and )?)+$" +[stage-12] ✓ Received exit code 1. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_nested/success b/internal/test_helpers/fixtures/backreferences_nested/success index 26b80a3..ff68f1c 100644 --- a/internal/test_helpers/fixtures/backreferences_nested/success +++ b/internal/test_helpers/fixtures/backreferences_nested/success @@ -127,12 +127,11 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" -[your_program] Will, will Will will Will Will's will -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" [your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)(, | and )?)+$" +[stage-12] ✓ Received exit code 1. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3 diff --git a/internal/test_helpers/fixtures/backreferences_single/success b/internal/test_helpers/fixtures/backreferences_single/success index 26a5f52..8d9c904 100644 --- a/internal/test_helpers/fixtures/backreferences_single/success +++ b/internal/test_helpers/fixtures/backreferences_single/success @@ -45,12 +45,11 @@ [stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "a cow" | ./your_grep.sh -E "a (cat|dog)" [stage-12] ✓ Received exit code 1. -[stage-12] $ echo -n "Will, will Will will Will Will's will" | ./your_grep.sh -E "^([Ww]ill(, | |'s )?)+$" -[your_program] Will, will Will will Will Will's will -[stage-12] ✓ Received exit code 0. [stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)s?(, | and )?)+$" [your_program] I see 1 cat, 2 dogs and 3 cows [stage-12] ✓ Received exit code 0. +[stage-12] $ echo -n "I see 1 cat, 2 dogs and 3 cows" | ./your_grep.sh -E "^I see (\d (cat|dog|cow)(, | and )?)+$" +[stage-12] ✓ Received exit code 1. [stage-12] Test passed. [stage-11] Running tests for Stage #11: zb3