From c3362aefa2e762211409923cfff065541bebf9e7 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 22 May 2022 00:37:40 +0530 Subject: ble.sh & z4h addition --- .local/src/blesh/lib/test-complete.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .local/src/blesh/lib/test-complete.sh (limited to '.local/src/blesh/lib/test-complete.sh') 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 -- cgit v1.2.3