comparison 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
comparison
equal deleted inserted replaced
725:33293795caa6 726:23f6d2993fa2
1 Complex object tests of farray.sh
2
3 Shell is /bin/sh.
4
5
6 Setup
7 =====
8
9 $ set -u
10 $ . "${TESTDIR}/testsetup.sh"
11 $ _p_datadir="${TESTDIR}/../share/local-bsdtools"
12 $ . "${_p_datadir}/farray.sh"
13
14
15 Array
16 =====
17
18 $ farray_create ARRAY1 i1 i2
19 $ farray_create ITEM1 i11 i22
20 This also transfers ownership
21 $ farray_append ARRAY1 "$ITEM1"
22 $ ITEM1=''
23 $ falist_create LIST2 k1 v1 k2 v2 k3 v3
24 This also transfers ownership
25 $ farray_append ARRAY1 "$LIST2"
26 $ LIST2=''
27 $ farray_debug ARRAY1
28 DEBUG: array `ARRAY1' has length 4
29 DEBUG: its contents:
30 DEBUG: 1: `i1'
31 DEBUG: 2: `i2'
32 DEBUG: 3: -->
33 DEBUG: array with token `[a-f0-9]+' has length 2 (re)
34 DEBUG: its contents:
35 DEBUG: 1: `i11'
36 DEBUG: 2: `i22'
37 DEBUG: 4: -->
38 DEBUG: alist with token `[a-f0-9]+' has length 3 (re)
39 DEBUG: `k1' -> `v1'
40 DEBUG: `k2' -> `v2'
41 DEBUG: `k3' -> `v3'
42 $ farray_destroy ARRAY1
43 $ check_no_array_artifacts
44 $ check_no_alist_artifacts
45
46
47 AList
48 =====
49
50 $ falist_create LIST1 k1 v1
51 $ falist_create ITEM1 k11 v11 k22 v22 k33 v33 k44 v44
52 This also transfers ownership
53 $ falist_set LIST1 k2 "$ITEM1"
54 $ ITEM1=''
55 $ farray_create ARRAY2 a1 a2 a3
56 This also transfers ownership
57 $ falist_set LIST1 k3 "$ARRAY2"
58 $ ARRAY2=''
59 $ falist_debug LIST1
60 DEBUG: alist `LIST1' has length 3
61 DEBUG: `k1' -> `v1'
62 DEBUG: `k2': -->
63 DEBUG: alist with token `[a-f0-9]+' has length 4 (re)
64 DEBUG: `k11' -> `v11'
65 DEBUG: `k22' -> `v22'
66 DEBUG: `k33' -> `v33'
67 DEBUG: `k44' -> `v44'
68 DEBUG: `k3': -->
69 DEBUG: array with token `[a-f0-9]+' has length 3 (re)
70 DEBUG: its contents:
71 DEBUG: 1: `a1'
72 DEBUG: 2: `a2'
73 DEBUG: 3: `a3'
74
75 $ falist_destroy LIST1
76 $ check_no_array_artifacts
77 $ check_no_alist_artifacts