Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff tests/farray-misc.t @ 590:ce29bad1fd3b
farray.sh: Implement _farr_make_index().
This will be used to a more centralized and extended index computation that
also allows computing indexes relative to the length of an array.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 18 Sep 2024 14:51:27 +0200 |
| parents | fb7e5cd69494 |
| children | cf0f18d3d41b |
line wrap: on
line diff
--- a/tests/farray-misc.t Wed Sep 18 13:13:26 2024 +0200 +++ b/tests/farray-misc.t Wed Sep 18 14:51:27 2024 +0200 @@ -48,3 +48,51 @@ [1] $ _farr_is_decimal_number 0123456789abcdef [1] + + +Index Checks +============ + + $ _farr_make_index _res 5 + $ echo $_res + 5 + + $ _farr_make_index _res "" 123 + $ echo $_res + 124 + + $ _farr_make_index _res 0 123 + $ echo $_res + 123 + + $ _farr_make_index _res -122 123 + $ echo $_res + 1 + + $ _farr_make_index _res -123 123 + $ echo $_res + 0 + + $ _farr_make_index _res 124 123 + $ echo $_res + 124 + + $ _farr_make_index _res 125 123 + $ echo $_res + 125 + + $ ( _farr_make_index _res 0 ) + ERROR: cannot compute effective index because no length is given + [70] + + $ ( _farr_make_index _res "" ) + ERROR: length not given: cannot autocompute index + [70] + + $ ( _farr_make_index _res 0x1 ) + ERROR: given index is not a valid decimal number + [70] + + $ ( _farr_make_index _res 0 0x1 ) + ERROR: given length is not a valid decimal number + [70]
