Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
view tests/farray-object.t @ 726:23f6d2993fa2
farray.sh: Test the debug output and the destruction of complex objects.
BUGS: No formal ownership management is done yet.
It is planned to implement resource management with reference counting.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 06 Oct 2024 16:19:45 +0200 |
| parents | |
| children | 858f4208d9cb |
line wrap: on
line source
Complex object tests of farray.sh Shell is /bin/sh. Setup ===== $ set -u $ . "${TESTDIR}/testsetup.sh" $ _p_datadir="${TESTDIR}/../share/local-bsdtools" $ . "${_p_datadir}/farray.sh" Array ===== $ farray_create ARRAY1 i1 i2 $ farray_create ITEM1 i11 i22 This also transfers ownership $ farray_append ARRAY1 "$ITEM1" $ ITEM1='' $ falist_create LIST2 k1 v1 k2 v2 k3 v3 This also transfers ownership $ farray_append ARRAY1 "$LIST2" $ LIST2='' $ farray_debug ARRAY1 DEBUG: array `ARRAY1' has length 4 DEBUG: its contents: DEBUG: 1: `i1' DEBUG: 2: `i2' DEBUG: 3: --> DEBUG: array with token `[a-f0-9]+' has length 2 (re) DEBUG: its contents: DEBUG: 1: `i11' DEBUG: 2: `i22' DEBUG: 4: --> DEBUG: alist with token `[a-f0-9]+' has length 3 (re) DEBUG: `k1' -> `v1' DEBUG: `k2' -> `v2' DEBUG: `k3' -> `v3' $ farray_destroy ARRAY1 $ check_no_array_artifacts $ check_no_alist_artifacts AList ===== $ falist_create LIST1 k1 v1 $ falist_create ITEM1 k11 v11 k22 v22 k33 v33 k44 v44 This also transfers ownership $ falist_set LIST1 k2 "$ITEM1" $ ITEM1='' $ farray_create ARRAY2 a1 a2 a3 This also transfers ownership $ falist_set LIST1 k3 "$ARRAY2" $ ARRAY2='' $ falist_debug LIST1 DEBUG: alist `LIST1' has length 3 DEBUG: `k1' -> `v1' DEBUG: `k2': --> DEBUG: alist with token `[a-f0-9]+' has length 4 (re) DEBUG: `k11' -> `v11' DEBUG: `k22' -> `v22' DEBUG: `k33' -> `v33' DEBUG: `k44' -> `v44' DEBUG: `k3': --> DEBUG: array with token `[a-f0-9]+' has length 3 (re) DEBUG: its contents: DEBUG: 1: `a1' DEBUG: 2: `a2' DEBUG: 3: `a3' $ falist_destroy LIST1 $ check_no_array_artifacts $ check_no_alist_artifacts
