annotate tests/farray-alist.t @ 604:45c47bc1f7d2

farray.sh: Moved all currently existing tests for alists into cram tests. Removed existing tests from farray.sh -- and put them into farray-alist.t.
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 18 Sep 2024 23:08:06 +0200
parents
children 96366e2075fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
604
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 Basic tests of farray.sh's falist_XXX functions
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 Shell is /bin/sh.
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 Setup
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 =====
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 $ set -u
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 $ . "${TESTDIR}/testsetup.sh"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 $ _p_datadir="${TESTDIR}/../share/local-bsdtools"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 $ . "${_p_datadir}/farray.sh"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 Basic Creation and Destruction
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 ==============================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 Create an empty alist
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24 $ test "${_i}" -eq 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26 0 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29 DEBUG: alist `LIST' has length 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 $ ( falist_destroy LIST )
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33 ERROR: falist `LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 Clear
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 =====
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 $ falist_set LIST K2 V2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46 DEBUG: alist `LIST' has length 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 DEBUG: `K2' -> `V2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
55 $ falist_clear LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 0 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66 Get / Set / Contains
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67 ====================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
70 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 $ falist_set LIST K2 V2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 DEBUG: alist `LIST' has length 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
75 DEBUG: `K2' -> `V2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
81
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 $ falist_set LIST K2 "V2 2"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
83 $ falist_set LIST K3 $'" 111222333" \\\'444555 ' # '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
85 DEBUG: alist `LIST' has length 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 DEBUG: `K2' -> `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88 DEBUG: `K3' -> `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 3 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 $ falist_contains LIST K1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96 $ falist_contains LIST K
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 $ falist_get _var LIST K2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 $ echo "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
100 V2 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 $ falist_tryget _var LIST K1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
102 $ echo "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 $ falist_tryget _i LIST K
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106 $ _var="$(falist_print_length NON_EXISTING_LIST)"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
107 ERROR: falist `NON_EXISTING_LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 $ echo "${_var}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 -1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
110
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
111 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
112 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
113
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 Iteration
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
116 =========
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
117
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
118 ITERATE (manual indexing)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
121 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 $ falist_set LIST K2 "V2 2"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
123 $ falist_set LIST K3 $'" 111222333" \\\'444555 ' # '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 Iteration by indexing key and values separately
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 $ _i=1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 > while falist_tryget_key_at_index _k LIST ${_i}; do
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 > # cannot fail under "normal" circumstances
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 > falist_tryget_value_at_index _v LIST ${_i}
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 > printf " KEY: \`%s', VAL: \`%s'\\n" "${_k}" "${_v}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
132 > _i=$((_i + 1))
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 > done
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 KEY: `K1', VAL: `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135 KEY: `K2', VAL: `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136 KEY: `K3', VAL: `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 ITERATE (manual indexing over items)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140 $ _i=1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 > while falist_tryget_item_at_index _k _v LIST ${_i}; do
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142 > printf " KEY: \`%s', VAL: \`%s'\\n" "${_k}" "${_v}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 > _i=$((_i + 1))
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 > done
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
145 KEY: `K1', VAL: `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
146 KEY: `K2', VAL: `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
147 KEY: `K3', VAL: `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
148
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
149 ITERATE (for each)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
150
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
151 $ falist_for_each LIST $'printf "EACH: %s key \\`%s\\\', value \\`%s\\\' at idx %d\\n"' # `
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
152 EACH: LIST key `K1', value `V1' at idx 1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
153 EACH: LIST key `K2', value `V2 2' at idx 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
154 EACH: LIST key `K3', value `" 111222333" \'444555 ' at idx 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
155
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
156 $ falist_clear LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
157 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
158 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
159 ERROR: falist `LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
160 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
161
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
162
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
163 Deletion of keys
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
164 ================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
165
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
166 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
167 $ falist_set LIST 'key 1' 'value 1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
168 $ falist_set LIST 'key 2' 'value 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
169 $ falist_set LIST 'key 3' 'value 3'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
170 $ falist_set LIST 'key 4' 'value 4'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
171 $ falist_set LIST 'key 5' 'value 5'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
172 $ falist_trydel LIST 'key 1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
173 $ falist_trydel LIST 'key 5'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
174 $ falist_trydel LIST 'key 3'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
175 $ falist_trydel LIST "non-existing key"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
176 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
177 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
178 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
179 $ falist_get _var LIST 'key 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
180 $ printf '%s' "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
181 value 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
182 $ falist_get _var LIST 'key 4'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
183 $ printf '%s' "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
184 value 4 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
185
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
186 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
187
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
188 $ check_no_alist_artifacts