| 1 | # source script for ble.sh interactive sessions -*- mode: sh; mode: sh-bash -*- |
| 2 | |
| 3 | ble-import lib/core-syntax |
| 4 | ble-import lib/core-test |
| 5 | |
| 6 | ble/test/start-section 'ble/syntax' 22 |
| 7 | |
| 8 | ( |
| 9 | func=ble/syntax:bash/simple-word/evaluate-last-brace-expansion |
| 10 | collect='ret=$simple_ibrace/$ret' |
| 11 | ble/test "$func 'a{b,c}x' ; $collect" ret='6:2/acx' |
| 12 | ble/test "$func 'a{b,{c,d}x' ; $collect" ret='9:2/adx' |
| 13 | ble/test "$func 'a{b,{c,d}}x'; $collect" ret='10:2/adx' |
| 14 | ble/test "$func 'a{{c,dx' ; $collect" ret='5:1/adx' |
| 15 | ble/test "$func 'a{b{c,dx' ; $collect" ret='6:2/abdx' |
| 16 | ble/test "$func 'a{b,c}{d}x' ; $collect" ret='7:2/acd}x' |
| 17 | ) |
| 18 | |
| 19 | ( |
| 20 | func=ble/syntax:bash/simple-word/reconstruct-incomplete-word |
| 21 | collect='ret=$?:$simple_flags:[$simple_ibrace]:$ret' |
| 22 | ble/test "$func 'hello-word' ; $collect" ret='0::[0:0]:hello-word' |
| 23 | ble/test "$func 'hello word' ; $collect" ret='1::[0:0]:hello' |
| 24 | ble/test "$func 'hello-word\"a' ; $collect" ret='0:D:[0:0]:hello-word"a"' |
| 25 | ble/test "$func 'a{b,c}x' ; $collect" ret='0::[6:2]:acx' |
| 26 | ble/test "$func 'a{b,{c,d}x' ; $collect" ret='0::[9:2]:adx' |
| 27 | ble/test "$func 'a{b,{c,d}}x' ; $collect" ret='0::[10:2]:adx' |
| 28 | ble/test "$func 'a{{c,dx' ; $collect" ret='0::[5:1]:adx' |
| 29 | ble/test "$func 'a{b{c,dx' ; $collect" ret='0::[6:2]:abdx' |
| 30 | ble/test "$func 'a{b,c}{d}x' ; $collect" ret='0::[7:2]:acd}x' |
| 31 | ble/test "$func 'a{b,c}x\"hello, world'; $collect" ret='0:D:[6:2]:acx"hello, world"' |
| 32 | ble/test "$func 'a{b,{c,d}x'\''a' ; $collect" ret='0:S:[9:2]:adx'\''a'\' |
| 33 | ble/test "$func 'a{b,{c,d}}x\$'\''\e[m'; $collect" ret='0:E:[10:2]:adx$'\''\e[m'\' |
| 34 | ble/test "$func 'a{{c,dx\$\"aa' ; $collect" ret='0:I:[5:1]:adx$"aa"' |
| 35 | ) |
| 36 | |
| 37 | ( |
| 38 | func=ble/syntax:bash/simple-word/evaluate-path-spec |
| 39 | collect='ret="${spec[*]} >>> ${path[*]}"' |
| 40 | ble/test "$func '~/a/b/c' ; $collect" ret="~ ~/a ~/a/b ~/a/b/c >>> $HOME $HOME/a $HOME/a/b $HOME/a/b/c" |
| 41 | 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" |
| 42 | ble/test "$func '/x/y/z' / after-sep ; $collect" ret="/ /x/ /x/y/ /x/y/z >>> / /x/ /x/y/ /x/y/z" |
| 43 | ) |
| 44 | |
| 45 | ble/test/end-section |