Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 733:772e4999562b
farray.sh: Unified the output of farray_debug() and falist_debug()
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 07 Oct 2024 14:08:29 +0200 |
| parents | d92e7203a14d |
| children | 4cd2fd7ccf76 |
| files | share/local-bsdtools/farray.sh tests/farray-alist.t tests/farray-array.t tests/farray-object.t |
| diffstat | 4 files changed, 85 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/share/local-bsdtools/farray.sh Mon Oct 07 13:34:28 2024 +0200 +++ b/share/local-bsdtools/farray.sh Mon Oct 07 14:08:29 2024 +0200 @@ -1618,7 +1618,7 @@ printf "%sDEBUG: array with token \`%s' has length %s\\n" "${__farr_debug_indent}" "${__farr_token}" "${__farr_len}" 1>&2 fi if [ ${__farr_len} -gt 0 ]; then - printf '%sDEBUG: its contents:\n' "${__farr_debug_indent}" 1>&2 + printf '%sDEBUG: the items:\n' "${__farr_debug_indent}" 1>&2 farray_for_each "${__farr_name_or_token}" _farr_debug_print_value "${__farr_debug_indent}" || true fi return 0 @@ -1634,12 +1634,12 @@ _farr_debug_print_value() { case "$3" in "${_farr_array_token_prefix}"*) - printf "%sDEBUG: %s: -->\\n" "$4" "$2" 1>&2 + printf "%sDEBUG: %s: >>>\\n" "$4" "$2" 1>&2 _farr_array_debug "$4 " "$3" # let the return value pass through ;; "${_farr_alist_token_prefix}"*) - printf "%sDEBUG: %s: -->\\n" "$4" "$2" 1>&2 + printf "%sDEBUG: %s: >>>\\n" "$4" "$2" 1>&2 _farr_alist_debug "$4 " "$3" # let the return value pass through ;; @@ -2980,6 +2980,9 @@ else printf "%sDEBUG: alist with token \`%s' has length %s\\n" "${__farr_debug_indent}" "${__farr_token}" "${__farr_len}" 1>&2 fi + if [ ${__farr_len} -gt 0 ]; then + printf '%sDEBUG: the items:\n' "${__farr_debug_indent}" 1>&2 + fi __farr_idx=1 while [ ${__farr_idx} -le ${__farr_len} ]; do eval __farr_el_key=\"\$\{${__farr_keyname}_${__farr_idx}+SET\}\" @@ -2995,11 +2998,11 @@ eval __farr_el_val=\"\$\{${__farr_valname}_${__farr_idx}\}\" case "${__farr_el_val}" in "${_farr_array_token_prefix}"*) - printf "%sDEBUG: \`%s': -->\\n" "${__farr_debug_indent}" "${__farr_el_key}" 1>&2 + printf "%sDEBUG: \`%s' -> >>>\\n" "${__farr_debug_indent}" "${__farr_el_key}" 1>&2 _farr_array_debug "${__farr_debug_indent} " "${__farr_el_val}" ;; "${_farr_alist_token_prefix}"*) - printf "%sDEBUG: \`%s': -->\\n" "${__farr_debug_indent}" "${__farr_el_key}" 1>&2 + printf "%sDEBUG: \`%s' -> >>>\\n" "${__farr_debug_indent}" "${__farr_el_key}" 1>&2 _farr_alist_debug "${__farr_debug_indent} " "${__farr_el_val}" ;; *)
--- a/tests/farray-alist.t Mon Oct 07 13:34:28 2024 +0200 +++ b/tests/farray-alist.t Mon Oct 07 14:08:29 2024 +0200 @@ -49,6 +49,7 @@ $ falist_set LIST K2 V2 $ falist_debug LIST DEBUG: alist `LIST' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2' $ falist_length _i LIST @@ -81,6 +82,7 @@ $ falist_set LIST K2 V2 $ falist_debug LIST DEBUG: alist `LIST' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2' $ falist_length _i LIST @@ -95,6 +97,7 @@ $ falist_set LIST K3 $'" 111222333" \\\'444555 ' # ' $ falist_debug LIST DEBUG: alist `LIST' has length 3 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2 2' DEBUG: `K3' -> `" 111222333" \'444555 ' @@ -122,6 +125,7 @@ $ falist_set_unique LIST K4 "V4" $ falist_debug LIST DEBUG: alist `LIST' has length 4 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2 2' DEBUG: `K3' -> `" 111222333" \'444555 ' @@ -234,6 +238,7 @@ $ falist_trydel LIST 'key 3' $ falist_debug LIST DEBUG: alist `LIST' has length 2 + DEBUG: the items: DEBUG: `key 2' -> `value 2' DEBUG: `key 4' -> `value 4' $ falist_trydel LIST "non-existing key" @@ -258,24 +263,28 @@ $ falist_create LIST1 K1 V1 K2 V2 $ falist_debug LIST1 DEBUG: alist `LIST1' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2' $ falist_create LIST2 K2 V2 K1 V1 $ falist_debug LIST2 DEBUG: alist `LIST2' has length 2 + DEBUG: the items: DEBUG: `K2' -> `V2' DEBUG: `K1' -> `V1' $ falist_create LIST3 K1 V1 K2 V2 $ falist_debug LIST3 DEBUG: alist `LIST3' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2' $ falist_create LIST4 K1 V1 K2 V2-4 $ falist_debug LIST4 DEBUG: alist `LIST4' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' DEBUG: `K2' -> `V2-4' @@ -319,6 +328,7 @@ $ falist_update ARR UPDATE2 $ falist_debug ARR DEBUG: alist `ARR' has length 3 + DEBUG: the items: DEBUG: `Key 1' -> `Value 1' DEBUG: `Key 2' -> `Value 2 (Updated) '' DEBUG: `Key 3' -> `Value 3' @@ -328,10 +338,12 @@ $ falist_update EMPTY UPDATE1 $ falist_debug EMPTY DEBUG: alist `EMPTY' has length 2 + DEBUG: the items: DEBUG: `Key 1' -> `Value 1' DEBUG: `Key 2' -> `Value 2 '' $ falist_debug UPDATE1 DEBUG: alist `UPDATE1' has length 2 + DEBUG: the items: DEBUG: `Key 1' -> `Value 1' DEBUG: `Key 2' -> `Value 2 '' @@ -353,7 +365,7 @@ $ falist_items ITEMS LIST $ farray_debug ITEMS DEBUG: array `ITEMS' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `Key 1' DEBUG: 2: `Value 1' DEBUG: 3: `Key 2' @@ -361,13 +373,13 @@ $ falist_keys KEYS LIST $ farray_debug KEYS DEBUG: array `KEYS' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `Key 1' DEBUG: 2: `Key 2' $ falist_values VALUES LIST $ farray_debug VALUES DEBUG: array `VALUES' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `Value 1' DEBUG: 2: `Value 2 '' @@ -419,6 +431,7 @@ $ falist_create LIST k1 v2 $ falist_debug LIST DEBUG: alist `LIST' has length 1 + DEBUG: the items: DEBUG: `k1' -> `v2' $ _farr_release_object "$LIST" $ check_no_alist_artifacts @@ -440,9 +453,11 @@ $ falist_release ITEM1 $ falist_debug LIST DEBUG: alist `LIST' has length 2 + DEBUG: the items: DEBUG: `K1' -> `V1' - DEBUG: `K2': --> + DEBUG: `K2' -> >>> DEBUG: alist with token `[a-f0-9]+' has length 2 (re) + DEBUG: the items: DEBUG: `K11' -> `V11' DEBUG: `K22' -> `V22' $ falist_release LIST
--- a/tests/farray-array.t Mon Oct 07 13:34:28 2024 +0200 +++ b/tests/farray-array.t Mon Oct 07 14:08:29 2024 +0200 @@ -39,7 +39,7 @@ $ farray_istrue TEST $ farray_debug TEST DEBUG: array `TEST' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -47,7 +47,7 @@ DEBUG: 5: `" 678" \'90 ' # $ farray_debug "$TEST" # DEBUG: array with token `[a-f0-9]+' has length 5 (re) -# DEBUG: its contents: +# DEBUG: the items: # DEBUG: 1: `0' # DEBUG: 2: `1' # DEBUG: 3: `2' @@ -66,7 +66,7 @@ $ test ${_var} -eq 5 $ farray_debug TEST DEBUG: array `TEST' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -201,7 +201,7 @@ $ farray_del TEST 1 $ farray_debug TEST DEBUG: array `TEST' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `1' DEBUG: 2: `2' DEBUG: 3: `3 4 5' @@ -214,7 +214,7 @@ $ farray_del TEST 0 $ farray_debug TEST DEBUG: array `TEST' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -227,7 +227,7 @@ $ farray_del TEST 4 $ farray_debug TEST DEBUG: array `TEST' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -262,7 +262,7 @@ $ farray_set TEST "" $'the new value \\ \'' $ farray_debug TEST DEBUG: array `TEST' has length 7 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -279,7 +279,7 @@ $ farray_set TEST 7 $'the new value \\ \'' $ farray_debug TEST DEBUG: array `TEST' has length 7 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -296,7 +296,7 @@ $ farray_set TEST 0 $'the new replaced value \\ \'' $ farray_debug TEST DEBUG: array `TEST' has length 6 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -312,7 +312,7 @@ $ farray_set TEST 1 $'the new replaced value \\ \'' $ farray_debug TEST DEBUG: array `TEST' has length 6 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `the new replaced value \ '' DEBUG: 2: `1' DEBUG: 3: `2' @@ -328,7 +328,7 @@ $ farray_set TEST 5 $'the new replaced value \\ \' 2 ' $ farray_debug TEST DEBUG: array `TEST' has length 6 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `0' DEBUG: 2: `1' DEBUG: 3: `2' @@ -359,7 +359,7 @@ $ farray_splice DELETED TEST 1 "" INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -371,7 +371,7 @@ DEBUG: 9: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` I 1 ' DEBUG: 2: ` I 2 ' DEBUG: 3: ` I 3 ' @@ -390,7 +390,7 @@ DEBUG: array `DELETED' has length 0 $ farray_debug TEST DEBUG: array `TEST' has length 12 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` I 1 ' DEBUG: 2: ` I 2 ' DEBUG: 3: ` I 3 ' @@ -418,7 +418,7 @@ DEBUG: array `DELETED' has length 0 $ farray_debug TEST DEBUG: array `TEST' has length 12 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -446,7 +446,7 @@ DEBUG: array `DELETED' has length 0 $ farray_debug TEST DEBUG: array `TEST' has length 12 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -472,7 +472,7 @@ $ farray_splice DELETED TEST 1 "" INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -496,7 +496,7 @@ $ farray_splice DELETED TEST 1 "" $ farray_debug DELETED DEBUG: array `DELETED' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -519,7 +519,7 @@ $ farray_splice DELETED TEST 2 5 $ farray_debug DELETED DEBUG: array `DELETED' has length 5 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 2 ' DEBUG: 2: ` v 3 ' DEBUG: 3: ` v 4 ' @@ -527,7 +527,7 @@ DEBUG: 5: ` v 6 ' $ farray_debug TEST DEBUG: array `TEST' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 7 ' DEBUG: 3: ` v 8 ' @@ -543,7 +543,7 @@ $ farray_splice DELETED TEST 1 6 $ farray_debug DELETED DEBUG: array `DELETED' has length 6 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -552,7 +552,7 @@ DEBUG: 6: ` v 6 ' $ farray_debug TEST DEBUG: array `TEST' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 7 ' DEBUG: 2: ` v 8 ' DEBUG: 3: ` v 9 ' @@ -567,11 +567,11 @@ $ farray_splice DELETED TEST 0 1 $ farray_debug DELETED DEBUG: array `DELETED' has length 1 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 8 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -591,12 +591,12 @@ $ farray_splice DELETED TEST -1 "" $ farray_debug DELETED DEBUG: array `DELETED' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 8 ' DEBUG: 2: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 7 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -616,14 +616,14 @@ $ farray_splice DELETED TEST 1 4 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' DEBUG: 4: ` v 4 ' $ farray_debug TEST DEBUG: array `TEST' has length 8 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` I 1 ' DEBUG: 2: ` I 2 ' DEBUG: 3: ` I 3 ' @@ -645,14 +645,14 @@ $ farray_splice DELETED TEST -3 4 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 6 ' DEBUG: 2: ` v 7 ' DEBUG: 3: ` v 8 ' DEBUG: 4: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 8 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -674,14 +674,14 @@ $ farray_splice DELETED TEST 3 4 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 3 ' DEBUG: 2: ` v 4 ' DEBUG: 3: ` v 5 ' DEBUG: 4: ` v 6 ' $ farray_debug TEST DEBUG: array `TEST' has length 8 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` I 1 ' @@ -703,12 +703,12 @@ $ farray_splice DELETED TEST 1 2 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' $ farray_debug TEST DEBUG: array `TEST' has length 10 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` I 1 ' DEBUG: 2: ` I 2 ' DEBUG: 3: ` I 3 ' @@ -732,12 +732,12 @@ $ farray_splice DELETED TEST -1 2 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 8 ' DEBUG: 2: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 10 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -761,12 +761,12 @@ $ farray_splice DELETED TEST 3 2 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 3 ' DEBUG: 2: ` v 4 ' $ farray_debug TEST DEBUG: array `TEST' has length 10 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` I 1 ' @@ -790,13 +790,13 @@ $ farray_splice DELETED TEST 1 3 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' $ farray_debug TEST DEBUG: array `TEST' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` I 1 ' DEBUG: 2: ` I 2 ' DEBUG: 3: ` I 3 ' @@ -819,13 +819,13 @@ $ farray_splice DELETED TEST -2 3 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 7 ' DEBUG: 2: ` v 8 ' DEBUG: 3: ` v 9 ' $ farray_debug TEST DEBUG: array `TEST' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -848,13 +848,13 @@ $ farray_splice DELETED TEST 4 3 INSERTED $ farray_debug DELETED DEBUG: array `DELETED' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 4 ' DEBUG: 2: ` v 5 ' DEBUG: 3: ` v 6 ' $ farray_debug TEST DEBUG: array `TEST' has length 9 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: ` v 1 ' DEBUG: 2: ` v 2 ' DEBUG: 3: ` v 3 ' @@ -1141,7 +1141,7 @@ $ farray_create TEST i1 i2 $ farray_debug TEST DEBUG: array `TEST' has length 2 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `i1' DEBUG: 2: `i2' $ _farr_release_object "$TEST" @@ -1163,12 +1163,12 @@ $ farray_release ITEM1 $ farray_debug TEST DEBUG: array `TEST' has length 3 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `i1' DEBUG: 2: `i2' - DEBUG: 3: --> + DEBUG: 3: >>> DEBUG: array with token `[a-f0-9]+' has length 2 (re) - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `i11' DEBUG: 2: `i22' $ farray_release TEST
--- a/tests/farray-object.t Mon Oct 07 13:34:28 2024 +0200 +++ b/tests/farray-object.t Mon Oct 07 14:08:29 2024 +0200 @@ -31,16 +31,17 @@ $ falist_release LIST2 $ farray_debug ARRAY1 DEBUG: array `ARRAY1' has length 4 - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `i1' DEBUG: 2: `i2' - DEBUG: 3: --> + DEBUG: 3: >>> DEBUG: array with token `[a-f0-9]+' has length 2 (re) - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `i11' DEBUG: 2: `i22' - DEBUG: 4: --> + DEBUG: 4: >>> DEBUG: alist with token `[a-f0-9]+' has length 3 (re) + DEBUG: the items: DEBUG: `k1' -> `v1' DEBUG: `k2' -> `v2' DEBUG: `k3' -> `v3' @@ -67,16 +68,18 @@ $ farray_release ARRAY2 $ falist_debug LIST1 DEBUG: alist `LIST1' has length 3 + DEBUG: the items: DEBUG: `k1' -> `v1' - DEBUG: `k2': --> + DEBUG: `k2' -> >>> DEBUG: alist with token `[a-f0-9]+' has length 4 (re) + DEBUG: the items: DEBUG: `k11' -> `v11' DEBUG: `k22' -> `v22' DEBUG: `k33' -> `v33' DEBUG: `k44' -> `v44' - DEBUG: `k3': --> + DEBUG: `k3' -> >>> DEBUG: array with token `[a-f0-9]+' has length 3 (re) - DEBUG: its contents: + DEBUG: the items: DEBUG: 1: `a1' DEBUG: 2: `a2' DEBUG: 3: `a3'
