annotate tests/farray-object.t @ 781:aead7cf1cb9a

farray.sh: Extensive comment on index computation for heaps and variable usage for Heapsort
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 26 Oct 2024 14:09:47 +0200
parents 03350d2a2af6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 Complex object tests of farray.sh
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 Shell is /bin/sh.
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 Setup
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 =====
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 $ set -u
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 $ . "${TESTDIR}/testsetup.sh"
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 $ _p_datadir="${TESTDIR}/../share/local-bsdtools"
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 $ . "${_p_datadir}/farray.sh"
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 Array
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 =====
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 $ farray_create ARRAY1 i1 i2
732
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
19 $ fobject_type ARRAY1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
20 array (no-eol)
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
21 $ farray_type ARRAY1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
22 array (no-eol)
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
23 $ falist_type ARRAY1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
24 array (no-eol)
769
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
25 $ fobject_isref "$ARRAY1"
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
26 $ fobject_isref ARRAY1
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
27 [1]
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
28 $ fobject_isref ''
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
29 [1]
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30 $ farray_create ITEM1 i11 i22
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 $ farray_append ARRAY1 "$ITEM1"
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
32 $ farray_release ITEM1
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33 $ falist_create LIST2 k1 v1 k2 v2 k3 v3
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 This also transfers ownership
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35 $ farray_append ARRAY1 "$LIST2"
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
36 $ falist_release LIST2
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 $ farray_debug ARRAY1
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38 DEBUG: array `ARRAY1' has length 4
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
39 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 DEBUG: 1: `i1'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41 DEBUG: 2: `i2'
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
42 DEBUG: 3: >>>
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43 DEBUG: array with token `[a-f0-9]+' has length 2 (re)
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
44 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45 DEBUG: 1: `i11'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46 DEBUG: 2: `i22'
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
47 DEBUG: 4: >>>
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 DEBUG: alist with token `[a-f0-9]+' has length 3 (re)
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
49 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 DEBUG: `k1' -> `v1'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51 DEBUG: `k2' -> `v2'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 DEBUG: `k3' -> `v3'
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
53 $ farray_release ARRAY1
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54 $ check_no_array_artifacts
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
55 $ check_no_alist_artifacts
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 AList
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59 =====
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 $ falist_create LIST1 k1 v1
732
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
62 $ fobject_type LIST1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
63 alist (no-eol)
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
64 $ falist_type LIST1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
65 alist (no-eol)
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
66 $ farray_type LIST1
d92e7203a14d farray.sh: an official function fobject_type() instead of an internal one
Franz Glasner <fzglas.hg@dom66.de>
parents: 730
diff changeset
67 alist (no-eol)
769
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
68 $ fobject_isref "$LIST1"
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
69 $ fobject_isref LIST1
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
70 [1]
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
71 $ fobject_isref ''
03350d2a2af6 farray.sh: Add public functions to check whether a given value refers to a object (array, alist).
Franz Glasner <fzglas.hg@dom66.de>
parents: 758
diff changeset
72 [1]
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 $ falist_create ITEM1 k11 v11 k22 v22 k33 v33 k44 v44
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 $ falist_set LIST1 k2 "$ITEM1"
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
75 $ falist_release ITEM1
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76 $ farray_create ARRAY2 a1 a2 a3
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 $ falist_set LIST1 k3 "$ARRAY2"
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
78 $ farray_release ARRAY2
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 $ falist_debug LIST1
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 DEBUG: alist `LIST1' has length 3
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
81 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 DEBUG: `k1' -> `v1'
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
83 DEBUG: `k2' -> >>>
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 DEBUG: alist with token `[a-f0-9]+' has length 4 (re)
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
85 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 DEBUG: `k11' -> `v11'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 DEBUG: `k22' -> `v22'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88 DEBUG: `k33' -> `v33'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 DEBUG: `k44' -> `v44'
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
90 DEBUG: `k3' -> >>>
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 DEBUG: array with token `[a-f0-9]+' has length 3 (re)
733
772e4999562b farray.sh: Unified the output of farray_debug() and falist_debug()
Franz Glasner <fzglas.hg@dom66.de>
parents: 732
diff changeset
92 DEBUG: the items:
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 DEBUG: 1: `a1'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94 DEBUG: 2: `a2'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 DEBUG: 3: `a3'
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96
730
8f1583faf9ea farray.sh: Rename farray_destroy() to farray_release() and falist_destroy() to falist_release()
Franz Glasner <fzglas.hg@dom66.de>
parents: 728
diff changeset
97 $ falist_release LIST1
726
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 $ check_no_array_artifacts
23f6d2993fa2 farray.sh: Test the debug output and the destruction of complex objects.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 $ check_no_alist_artifacts
758
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
100
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
101
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
102 No Locals
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
103 =========
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
104
7ead30e3b2f9 farray.sh: Check for typos in local variable names or missing "local" declarations for variables
Franz Glasner <fzglas.hg@dom66.de>
parents: 733
diff changeset
105 $ check_no_local_artifacts