From 522dee8d3c69762ad25ca8626122b257f9ff5a64 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 31 Dec 2024 13:14:37 +0000 Subject: [PATCH] Tweak test cases for quoted strings with no whitespace between them --- internal/stage_q1.go | 4 ++-- internal/stage_q2.go | 4 ++-- internal/test_helpers/fixtures/quoting/pass | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/stage_q1.go b/internal/stage_q1.go index 3ba029d6..758917a0 100644 --- a/internal/stage_q1.go +++ b/internal/stage_q1.go @@ -44,13 +44,13 @@ func testQ1(stageHarness *test_case_harness.TestCaseHarness) error { inputs := []string{ fmt.Sprintf(`echo '%s %s'`, L[0], L[1]), fmt.Sprintf(`echo %s %s`, L[1], L[4]), - fmt.Sprintf(`echo '%s %s'`, L[2], L[3]), + fmt.Sprintf(`echo '%s %s' '%s''%s'`, L[2], L[3], L[4], L[0]), fmt.Sprintf(`cat '%s' '%s' '%s'`, filePaths[0], filePaths[1], filePaths[2]), } expectedOutputs := []string{ fmt.Sprintf("%s %s", L[0], L[1]), fmt.Sprintf("%s %s", L[1], L[4]), - fmt.Sprintf("%s %s", L[2], L[3]), + fmt.Sprintf("%s %s %s%s", L[2], L[3], L[4], L[0]), fileContents[0] + fileContents[1] + strings.TrimRight(fileContents[2], "\n"), } testCaseContents := newTestCaseContents(inputs, expectedOutputs) diff --git a/internal/stage_q2.go b/internal/stage_q2.go index a1db8b72..8ffa49aa 100644 --- a/internal/stage_q2.go +++ b/internal/stage_q2.go @@ -43,13 +43,13 @@ func testQ2(stageHarness *test_case_harness.TestCaseHarness) error { L := random.RandomElementsFromArray(LARGE_WORDS, 5) inputs := []string{ fmt.Sprintf(`echo "%s %s"`, L[0], L[1]), - fmt.Sprintf(`echo "%s %s" "%s"`, L[1], L[2], L[3]), + fmt.Sprintf(`echo "%s %s" "%s""%s"`, L[1], L[2], L[3], L[0]), fmt.Sprintf(`echo "%s" "%s's" "%s"`, L[3], L[4], L[1]), fmt.Sprintf(`cat "%s" "%s" "%s"`, filePaths[0], filePaths[1], filePaths[2]), } expectedOutputs := []string{ fmt.Sprintf("%s %s", L[0], L[1]), - fmt.Sprintf("%s %s %s", L[1], L[2], L[3]), + fmt.Sprintf("%s %s %s%s", L[1], L[2], L[3], L[0]), fmt.Sprintf(`%s %s's %s`, L[3], L[4], L[1]), fileContents[0] + fileContents[1] + strings.TrimRight(fileContents[2], "\n"), } diff --git a/internal/test_helpers/fixtures/quoting/pass b/internal/test_helpers/fixtures/quoting/pass index fd6ba7be..70785561 100644 --- a/internal/test_helpers/fixtures/quoting/pass +++ b/internal/test_helpers/fixtures/quoting/pass @@ -8,8 +8,8 @@ Debug = true [your-program] $ echo world script [your-program] world script [stage-6] ✓ Received expected response -[your-program] $ echo 'shell example' -[your-program] shell example +[your-program] $ echo 'shell example' 'script''test' +[your-program] shell example scripttest [stage-6] ✓ Received expected response [stage-6] Writing file "/tmp/foo/f 30" with content "grape banana." [stage-6] Writing file "/tmp/foo/f 67" with content "strawberry apple." @@ -25,8 +25,8 @@ Debug = true [your-program] $ echo "world shell" [your-program] world shell [stage-5] ✓ Received expected response -[your-program] $ echo "shell script" "hello" -[your-program] shell script hello +[your-program] $ echo "shell script" "hello""world" +[your-program] shell script helloworld [stage-5] ✓ Received expected response [your-program] $ echo "hello" "test's" "shell" [your-program] hello test's shell