summaryrefslogtreecommitdiff
path: root/.local/src/blesh/lib/test-syntax.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-syntax.sh
parent4df17a688ba54d710a1d46ee47cb65b5c9e75764 (diff)
ble.sh & z4h addition
Diffstat (limited to '.local/src/blesh/lib/test-syntax.sh')
-rw-r--r--.local/src/blesh/lib/test-syntax.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/.local/src/blesh/lib/test-syntax.sh b/.local/src/blesh/lib/test-syntax.sh
new file mode 100644
index 0000000..4e339a7
--- /dev/null
+++ b/.local/src/blesh/lib/test-syntax.sh
@@ -0,0 +1,39 @@
+# this script is a part of blesh (https://github.com/akinomyoga/ble.sh) under BSD-3-Clause license
+ble-import lib/core-syntax
+ble-import lib/core-test
+ble/test/start-section 'ble/syntax' 22
+(
+ _func=ble/syntax:bash/simple-word/evaluate-last-brace-expansion
+ _collect='ret=$simple_ibrace/$ret'
+ ble/test "$_func 'a{b,c}x' ; $_collect" ret='6:2/acx'
+ ble/test "$_func 'a{b,{c,d}x' ; $_collect" ret='9:2/adx'
+ ble/test "$_func 'a{b,{c,d}}x'; $_collect" ret='10:2/adx'
+ ble/test "$_func 'a{{c,dx' ; $_collect" ret='5:1/adx'
+ ble/test "$_func 'a{b{c,dx' ; $_collect" ret='6:2/abdx'
+ ble/test "$_func 'a{b,c}{d}x' ; $_collect" ret='7:2/acd}x'
+)
+(
+ _func=ble/syntax:bash/simple-word/reconstruct-incomplete-word
+ _collect='ret=$?:$simple_flags:[$simple_ibrace]:$ret'
+ ble/test "$_func 'hello-word' ; $_collect" ret='0::[0:0]:hello-word'
+ ble/test "$_func 'hello word' ; $_collect" ret='1::[0:0]:hello'
+ ble/test "$_func 'hello-word\"a' ; $_collect" ret='0:D:[0:0]:hello-word"a"'
+ ble/test "$_func 'a{b,c}x' ; $_collect" ret='0::[6:2]:acx'
+ ble/test "$_func 'a{b,{c,d}x' ; $_collect" ret='0::[9:2]:adx'
+ ble/test "$_func 'a{b,{c,d}}x' ; $_collect" ret='0::[10:2]:adx'
+ ble/test "$_func 'a{{c,dx' ; $_collect" ret='0::[5:1]:adx'
+ ble/test "$_func 'a{b{c,dx' ; $_collect" ret='0::[6:2]:abdx'
+ ble/test "$_func 'a{b,c}{d}x' ; $_collect" ret='0::[7:2]:acd}x'
+ ble/test "$_func 'a{b,c}x\"hello, world'; $_collect" ret='0:D:[6:2]:acx"hello, world"'
+ ble/test "$_func 'a{b,{c,d}x'\''a' ; $_collect" ret='0:S:[9:2]:adx'\''a'\'
+ ble/test "$_func 'a{b,{c,d}}x\$'\''\e[m'; $_collect" ret='0:E:[10:2]:adx$'\''\e[m'\'
+ ble/test "$_func 'a{{c,dx\$\"aa' ; $_collect" ret='0:I:[5:1]:adx$"aa"'
+)
+(
+ _func=ble/syntax:bash/simple-word/evaluate-path-spec
+ _collect='ret="${spec[*]} >>> ${path[*]}"'
+ ble/test "$_func '~/a/b/c' ; $_collect" ret="~ ~/a ~/a/b ~/a/b/c >>> $HOME $HOME/a $HOME/a/b $HOME/a/b/c"
+ ble/test "$_func '~/a/b/c' / after-sep; $_collect" ret="~/ ~/a/ ~/a/b/ ~/a/b/c >>> $HOME/ $HOME/a/ $HOME/a/b/ $HOME/a/b/c"
+ ble/test "$_func '/x/y/z' / after-sep ; $_collect" ret="/ /x/ /x/y/ /x/y/z >>> / /x/ /x/y/ /x/y/z"
+)
+ble/test/end-section