changeset 732:d92e7203a14d

farray.sh: an official function fobject_type() instead of an internal one
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 07 Oct 2024 13:34:28 +0200
parents cf0f18d3d41b
children 772e4999562b
files share/local-bsdtools/farray.sh tests/farray-object.t
diffstat 2 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/share/local-bsdtools/farray.sh	Mon Oct 07 13:26:25 2024 +0200
+++ b/share/local-bsdtools/farray.sh	Mon Oct 07 13:34:28 2024 +0200
@@ -88,7 +88,7 @@
 #:   for private use in this module.
 #:   Do not use such names in your scripts.
 #:
-#:   Public functions start with ``farray_`` or ``falist_``.
+#:   Public functions start with ``farray_, ``falist_`` or ``fobject_``.
 #:
 
 
@@ -357,10 +357,10 @@
 
 
 #:
-#: Internal implementation of typing
+#: Implementation of typing
 #:
 #: Args:
-#:   $1 (str): The name of an object
+#:   $1 (str): The (variable) name of an object
 #:
 #: Output (stdout):
 #:   - array: an array
@@ -372,7 +372,7 @@
 #: Returns:
 #:   int: 0 always
 #:
-_farr_type() {
+fobject_type() {
     local __farr_type_name
 
     local __farr_type_token
@@ -409,10 +409,10 @@
 
 
 #:
-#: Just an official alias for `_farr_type`
+#: Just an official alias for `fobject_type`
 #:
 farray_type() {
-    _farr_type "$@"
+    fobject_type "$@"
 }
 
 
@@ -426,7 +426,7 @@
 #:   int: 0 if `$1` is an array, 1 otherwise
 #:
 farray_isarray() {
-    [ "$(_farr_type "$@")" = 'array' ]
+    [ "$(fobject_type "$@")" = 'array' ]
 }
 
 
@@ -1652,10 +1652,10 @@
 
 
 #:
-#: Just an official alias for `_farr_type`
+#: Just an official alias for `fobject_type`
 #:
 falist_type() {
-    _farr_type "$@"
+    fobject_type "$@"
 }
 
 
@@ -1669,7 +1669,7 @@
 #:   int: 0 if `$1` is an alist, 1 otherwise
 #:
 falist_isalist() {
-    [ "$(_farr_type "$@")" = 'alist' ]
+    [ "$(fobject_type "$@")" = 'alist' ]
 }
 
 
--- a/tests/farray-object.t	Mon Oct 07 13:26:25 2024 +0200
+++ b/tests/farray-object.t	Mon Oct 07 13:34:28 2024 +0200
@@ -16,6 +16,12 @@
 =====
 
   $ farray_create ARRAY1 i1 i2
+  $ fobject_type ARRAY1
+  array (no-eol)
+  $ farray_type ARRAY1
+  array (no-eol)
+  $ falist_type ARRAY1
+  array (no-eol)
   $ farray_create ITEM1 i11 i22
   $ farray_append ARRAY1 "$ITEM1"
   $ farray_release ITEM1
@@ -47,6 +53,12 @@
 =====
 
   $ falist_create LIST1 k1 v1
+  $ fobject_type LIST1
+  alist (no-eol)
+  $ falist_type LIST1
+  alist (no-eol)
+  $ farray_type LIST1
+  alist (no-eol)
   $ falist_create ITEM1 k11 v11 k22 v22 k33 v33 k44 v44
   $ falist_set LIST1 k2 "$ITEM1"
   $ falist_release ITEM1