Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 589:d791601ac1be | 590:ce29bad1fd3b |
|---|---|
| 46 [1] | 46 [1] |
| 47 $ _farr_is_decimal_number 0x0123456789abcdef | 47 $ _farr_is_decimal_number 0x0123456789abcdef |
| 48 [1] | 48 [1] |
| 49 $ _farr_is_decimal_number 0123456789abcdef | 49 $ _farr_is_decimal_number 0123456789abcdef |
| 50 [1] | 50 [1] |
| 51 | |
| 52 | |
| 53 Index Checks | |
| 54 ============ | |
| 55 | |
| 56 $ _farr_make_index _res 5 | |
| 57 $ echo $_res | |
| 58 5 | |
| 59 | |
| 60 $ _farr_make_index _res "" 123 | |
| 61 $ echo $_res | |
| 62 124 | |
| 63 | |
| 64 $ _farr_make_index _res 0 123 | |
| 65 $ echo $_res | |
| 66 123 | |
| 67 | |
| 68 $ _farr_make_index _res -122 123 | |
| 69 $ echo $_res | |
| 70 1 | |
| 71 | |
| 72 $ _farr_make_index _res -123 123 | |
| 73 $ echo $_res | |
| 74 0 | |
| 75 | |
| 76 $ _farr_make_index _res 124 123 | |
| 77 $ echo $_res | |
| 78 124 | |
| 79 | |
| 80 $ _farr_make_index _res 125 123 | |
| 81 $ echo $_res | |
| 82 125 | |
| 83 | |
| 84 $ ( _farr_make_index _res 0 ) | |
| 85 ERROR: cannot compute effective index because no length is given | |
| 86 [70] | |
| 87 | |
| 88 $ ( _farr_make_index _res "" ) | |
| 89 ERROR: length not given: cannot autocompute index | |
| 90 [70] | |
| 91 | |
| 92 $ ( _farr_make_index _res 0x1 ) | |
| 93 ERROR: given index is not a valid decimal number | |
| 94 [70] | |
| 95 | |
| 96 $ ( _farr_make_index _res 0 0x1 ) | |
| 97 ERROR: given length is not a valid decimal number | |
| 98 [70] |
