From 31a50cbf2ca9a352fb56d06b9e014c32e35b0a74 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 4 Sep 2020 15:29:06 -0600 Subject: [PATCH] category.go working well --- cmd/mothd/testdata/testpiler.sh | 52 +++++---- cmd/transpile/category.go | 93 +++++++++++++-- cmd/transpile/category_test.go | 110 ++++++++++++++++++ cmd/transpile/main.go | 16 +-- cmd/transpile/main_test.go | 3 +- cmd/transpile/puzzle.go | 8 +- cmd/transpile/puzzle_test.go | 2 +- cmd/transpile/testdata/generated/mkcategory | 45 +++++++ .../testdata/{ => static}/1/puzzle.md | 0 cmd/transpile/testdata/{ => static}/2/moo.js | 0 cmd/transpile/testdata/{ => static}/2/moo.txt | 0 .../testdata/{ => static}/2/puzzle.md | 0 .../testdata/{ => static}/3/mkpuzzle | 0 13 files changed, 281 insertions(+), 48 deletions(-) create mode 100644 cmd/transpile/category_test.go create mode 100755 cmd/transpile/testdata/generated/mkcategory rename cmd/transpile/testdata/{ => static}/1/puzzle.md (100%) rename cmd/transpile/testdata/{ => static}/2/moo.js (100%) rename cmd/transpile/testdata/{ => static}/2/moo.txt (100%) rename cmd/transpile/testdata/{ => static}/2/puzzle.md (100%) rename cmd/transpile/testdata/{ => static}/3/mkpuzzle (100%) diff --git a/cmd/mothd/testdata/testpiler.sh b/cmd/mothd/testdata/testpiler.sh index 2450d96..60da536 100755 --- a/cmd/mothd/testdata/testpiler.sh +++ b/cmd/mothd/testdata/testpiler.sh @@ -6,31 +6,35 @@ fail () { } case "$ACTION:$CAT:$POINTS" in -inventory::) - echo "pategory 1 2 3 4 5 10 20 300" - echo "nealegory 1 3 2" - ;; -open:*:*) - case "$CAT:$POINTS:$FILENAME" in - *:*:moo.txt) - echo "Moo." + inventory::) + cat <&2 + exit 1 +} + +case $1:$2:$3 in + inventory::) + echo "[1,2,3," + echo "4,5]" + ;; + puzzle:1:) + cat <moo." + } +} +EOT + ;; + puzzle:*:) + fail "No such puzzle" + ;; + file:1:moo.txt) + echo "Moo." + ;; + file:*:*) + fail "No such file: $2" + ;; + answer:1:answer1.0) + echo "correct" + ;; + answer:1:*) + echo "incorrect" + ;; + answer:*:*) + fail "Fail answer" + ;; + *) + fail "What is $1" 1>&2 + ;; +esac diff --git a/cmd/transpile/testdata/1/puzzle.md b/cmd/transpile/testdata/static/1/puzzle.md similarity index 100% rename from cmd/transpile/testdata/1/puzzle.md rename to cmd/transpile/testdata/static/1/puzzle.md diff --git a/cmd/transpile/testdata/2/moo.js b/cmd/transpile/testdata/static/2/moo.js similarity index 100% rename from cmd/transpile/testdata/2/moo.js rename to cmd/transpile/testdata/static/2/moo.js diff --git a/cmd/transpile/testdata/2/moo.txt b/cmd/transpile/testdata/static/2/moo.txt similarity index 100% rename from cmd/transpile/testdata/2/moo.txt rename to cmd/transpile/testdata/static/2/moo.txt diff --git a/cmd/transpile/testdata/2/puzzle.md b/cmd/transpile/testdata/static/2/puzzle.md similarity index 100% rename from cmd/transpile/testdata/2/puzzle.md rename to cmd/transpile/testdata/static/2/puzzle.md diff --git a/cmd/transpile/testdata/3/mkpuzzle b/cmd/transpile/testdata/static/3/mkpuzzle similarity index 100% rename from cmd/transpile/testdata/3/mkpuzzle rename to cmd/transpile/testdata/static/3/mkpuzzle