From 5781be4cd5b40266fe6713387cd6c8d902b89cd1 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 23 Nov 2020 11:24:38 -0500 Subject: [PATCH] fail in reg-test/run on num_invocations_attempted==0, and count those correctly --- go/reg-test/cases/case-altkv.sh | 19 ++- .../cases/case-c-dsl-filter-pattern-action.sh | 19 ++- .../cases/case-c-dsl-functional-tests.sh | 114 ++++++++++++++---- .../cases/case-c-dsl-regex-captures.sh | 19 ++- .../cases/case-c-dsl-triple-for-loops.sh | 6 +- .../cases/case-c-dsl-type-inference.sh | 16 ++- go/reg-test/cases/case-c-truncate.sh | 9 +- go/reg-test/cases/case-cat.sh | 8 +- .../case-go-dsl-json-collection-output.sh | 102 +++++++++++++--- go/reg-test/cases/case-go-dsl-length.sh | 39 ++++-- go/reg-test/cases/case-go-dsl-subs.sh | 14 ++- go/reg-test/cases/case-go-dsl-substr.sh | 44 +++++-- go/reg-test/cases/case-go-dsl-whitespace.sh | 27 ++++- go/reg-test/cases/case-go-io.sh | 41 +++++-- go/reg-test/cases/case-min-max-types.sh | 89 ++++++++++++++ go/reg-test/expected/case-altkv.sh.out | 8 +- go/reg-test/run | 32 ++++- go/todo.txt | 16 ++- 18 files changed, 509 insertions(+), 113 deletions(-) create mode 100644 go/reg-test/cases/case-min-max-types.sh diff --git a/go/reg-test/cases/case-altkv.sh b/go/reg-test/cases/case-altkv.sh index 42d58061d..3ec2d58ce 100644 --- a/go/reg-test/cases/case-altkv.sh +++ b/go/reg-test/cases/case-altkv.sh @@ -1,4 +1,15 @@ -echo 'a,b,c,d,e,f' | run_mlr -echo 'a,b,c,d,e,f,g' | run_mlr -echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs comma altkv -echo 'a,b,c,d,e,f,g' | run_mlr --inidx --ifs comma altkv +run_mlr altkv <>d<<\2>>g")' -echo 'abcdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' -echo 'abXdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' -echo 'abdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' +run_mlr --nidx put '$1 = sub($1, "ab(.)d(..)g", "ab<<\1>>d<<\2>>g")' <>d<<\2>>g")' <>d<<\2>>g")' <>d<<\2>>g")' < $n; + $gt["n"]["b"] = $n > $b; + $gt["n"]["v"] = $n > $v; + $gt["n"]["s"] = $n > $s; + + $gt["b"]["n"] = $b > $n; + $gt["b"]["b"] = $b > $b; + $gt["b"]["v"] = $b > $v; + $gt["b"]["s"] = $b > $s; + + $gt["v"]["n"] = $v > $n; + $gt["v"]["b"] = $v > $b; + $gt["v"]["v"] = $v > $v; + $gt["v"]["s"] = $v > $s; + + $gt["s"]["n"] = $s > $n; + $gt["s"]["b"] = $s > $b; + $gt["s"]["v"] = $s > $v; + $gt["s"]["s"] = $s > $s; +' < $outfile num_cases_attempted=`expr $num_cases_attempted + 1` + # Note that 'echo "..." | run_mlr ... ' would be nice in case-files, but, I had + # issues with the $num_invocations_attempted not tracking correctly in + # reg-test/run when run_mlr is at the end of a pipe :(. So, I enforce + # the discipline of always using here-documents ("< /dev/null 2> /dev/null + status=$? + if [ $status -eq 0 ]; then + echo "$0: Please edit $case_file and replace 'echo ... | run_mlr ...' lines with 'run_mlr ... 0" + fi + case_passed=false + fi + + if [ $num_invocations_attempted -eq 0 ]; then + if [ "$verbose" = "true" ]; then + echo "Case failed due to num_invocations_attempted == 0" + fi case_passed=false fi @@ -326,6 +349,9 @@ for case_file in $case_file_names; do fi status=$? if [ $status -ne 0 ]; then + if [ "$verbose" = "true" ]; then + echo "Case failed due to expected output != actual output" + fi case_passed=false fi diff --git a/go/todo.txt b/go/todo.txt index 2be888f24..af5f15d47 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -11,17 +11,19 @@ o iterate on a parser-generator with JSON config file no need to bootstrap a parser for the parser-generator language - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -!!! ^H two aliases ... one for paragraph one for line - * reg-test: - awkish-cond -> pattern-action everywhere - "format-" prefix etc for format-specific case; other prefixes ... ? - diff the *.err files -- ? - - double-check c/go sieve.mlr parse/execute ok - mlr label: check unique - - remove ././ from expecteds -! jvstack as no-op +! int map keys: what to do with: + o '{1:2}' treat as '{"1":2}' + o 'm[1]' treat as 'm["1"]' + o positional indexing for maps -- use [[]] [[[]]] ? + o pothole: auto-extend of foo[NR] -- this now creates an array not a map + +! --jvstack as no-op ! reconsider OFMT -- %.6f is not really OK when inputs have far more digits. * justWroteEmptyLine -> pprint too ... @@ -31,7 +33,6 @@ no need to bootstrap a parser for the parser-generator language ! nidx @ 10-min ! text-put @ 10-min - ! JSON null needs to be passed through as-is ... somehow ... new mlrval type?? o https://stedolan.github.io/jq/manual/#Builtinoperatorsandfunctions o "null can be added to any value, and returns the other value unchanged." @@ -340,3 +341,6 @@ NITS/NON-IMMEDIATE: * for-multi: C semantics 'k1: data k2: a:x v:1', sigh ... * neaten mlr gap -g (default) print * case-c-* / case-go-* -> case-* eventually +* implement min/max for array/map ... using cmp rules +! write out thorough min/max/cmp cases for all orderings by type +* note on <