Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff tests/farray-alist.t @ 723:a97ec3f07bdb
farray.sh: REFACTOR: More flexible metadata retrieval.
Using an array or alist variable name or token value (with prefix) is now
supported in every function.
This is possible because the value prefixes contain questin marks (?) which
are not allowed in shell variable names.
This again is a major precondition for recursive data structures
(arrays/alists in arrays/alists).
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 05 Oct 2024 21:55:55 +0200 |
| parents | b2757e72b517 |
| children | 3adb26525b19 |
line wrap: on
line diff
--- a/tests/farray-alist.t Sat Oct 05 14:49:34 2024 +0200 +++ b/tests/farray-alist.t Sat Oct 05 21:55:55 2024 +0200 @@ -164,13 +164,20 @@ KEY: `K2', VAL: `V2 2' KEY: `K3', VAL: `" 111222333" \'444555 ' -ITERATE (for each) +ITERATE (for each, by name) $ falist_for_each LIST $'printf "EACH: %s key \\`%s\\\', value \\`%s\\\' at idx %d\\n"' # ` EACH: LIST key `K1', value `V1' at idx 1 EACH: LIST key `K2', value `V2 2' at idx 2 EACH: LIST key `K3', value `" 111222333" \'444555 ' at idx 3 +ITERATE (for each, by value) + + $ falist_for_each "$LIST" $'printf "EACH: %s key \\`%s\\\', value \\`%s\\\' at idx %d\\n"' # ` + EACH: _farr_KV\?\?_[a-f0-9]+ key `K1', value `V1' at idx 1 (re) + EACH: _farr_KV\?\?_[a-f0-9]+ key `K2', value `V2 2' at idx 2 (re) + EACH: _farr_KV\?\?_[a-f0-9]+ key `K3', value `" 111222333" \\'444555 ' at idx 3 (re) + $ falist_clear LIST $ falist_destroy LIST $ falist_destroy LIST @@ -416,8 +423,8 @@ $ _farr_destroy_object "$LIST" $ check_no_alist_artifacts $ (_farr_destroy_object "$LIST") - ERROR: falist with token value `_farr_KV\*_([a-f0-9]+)' not created properly: no object for token `\1' (re) - [1] + ERROR: falist `_farr_KV\?\?_([a-f0-9]+)' not created properly: no object for token `\1' (re) + [70] $ LIST='' $ _farr_destroy_object "$LIST" $ check_no_alist_artifacts
