summaryrefslogtreecommitdiff
path: root/.local/src/blesh/lib/test-complete.sh
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-05-22 00:37:40 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-05-22 00:37:40 +0530
commitc3362aefa2e762211409923cfff065541bebf9e7 (patch)
treee48e225190fc0bb1a2db18ae2510a89a6f0d8653 /.local/src/blesh/lib/test-complete.sh
parent4df17a688ba54d710a1d46ee47cb65b5c9e75764 (diff)
ble.sh & z4h addition
Diffstat (limited to '.local/src/blesh/lib/test-complete.sh')
-rw-r--r--.local/src/blesh/lib/test-complete.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/src/blesh/lib/test-complete.sh b/.local/src/blesh/lib/test-complete.sh
new file mode 100644
index 0000000..cd7c0e1
--- /dev/null
+++ b/.local/src/blesh/lib/test-complete.sh
@@ -0,0 +1,28 @@
+# this script is a part of blesh (https://github.com/akinomyoga/ble.sh) under BSD-3-Clause license
+ble-import lib/core-complete
+ble-import lib/core-test
+ble/test/start-section 'ble/complete' 7
+(
+ function _collect {
+ local text=${args[1]} p0=0 i out=
+ for ((i=0;i<${#ret[@]};i++)); do
+ ((p=ret[i]))
+ if ((i%2==0)); then
+ out=$out${text:p0:p-p0}'['
+ else
+ out=$out${text:p0:p-p0}']'
+ fi
+ p0=$p
+ done
+ ((p0<${#text})) && out=$out${text:p0}
+ ret=$out
+ }
+ ble/test 'args=(akf Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ak]e[f]ile'
+ ble/test 'args=(akf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='Makefile'
+ ble/test 'args=(Mkf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[M]a[k]e[f]ile'
+ ble/test 'args=(Maf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Ma]ke[f]ile'
+ ble/test 'args=(Mak Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Mak]efile'
+ ble/test 'args=(ake Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ake]file'
+ ble/test 'args=(afe Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[a]ke[f]il[e]'
+)
+ble/test/end-section