| 1 | #
 | 
| 2 | # word-eval.test.sh: Test the word evaluation pipeline in order.
 | 
| 3 | #
 | 
| 4 | # Part evaluation, splitting, joining, elision, globbing.
 | 
| 5 | 
 | 
| 6 | # TODO: Rename word-eval-smoke.test.sh?
 | 
| 7 | # Word sequence evaluation.
 | 
| 8 | # This is more like a vertical slice.  For exhaustive tests, see:
 | 
| 9 | # 
 | 
| 10 | # word-split.test.sh (perhaps rename word-reframe?)
 | 
| 11 | # glob.test.sh
 | 
| 12 | 
 | 
| 13 | #### Evaluation of constant parts
 | 
| 14 | argv.py bare 'sq'
 | 
| 15 | ## stdout: ['bare', 'sq']
 | 
| 16 | 
 | 
| 17 | #### Evaluation of each part
 | 
| 18 | #set -o noglob
 | 
| 19 | HOME=/home/bob
 | 
| 20 | str=s
 | 
| 21 | array=(a1 a2)
 | 
| 22 | argv.py bare 'sq' ~ $str "-${str}-" "${array[@]}" $((1+2)) $(echo c) `echo c`
 | 
| 23 | ## stdout: ['bare', 'sq', '/home/bob', 's', '-s-', 'a1', 'a2', '3', 'c', 'c']
 | 
| 24 | ## N-I dash stdout-json: ""
 | 
| 25 | ## N-I dash status: 2
 | 
| 26 | 
 | 
| 27 | #### Word splitting
 | 
| 28 | s1='1 2'
 | 
| 29 | s2='3 4'
 | 
| 30 | s3='5 6'
 | 
| 31 | argv.py $s1$s2 "$s3"
 | 
| 32 | ## stdout: ['1', '23', '4', '5 6']
 | 
| 33 | 
 | 
| 34 | #### Word joining
 | 
| 35 | set -- x y z
 | 
| 36 | s1='1 2'
 | 
| 37 | array=(a1 a2)
 | 
| 38 | argv.py $s1"${array[@]}"_"$@"
 | 
| 39 | ## stdout: ['1', '2a1', 'a2_x', 'y', 'z']
 | 
| 40 | ## N-I dash stdout-json: ""
 | 
| 41 | ## N-I dash status: 2
 | 
| 42 | 
 | 
| 43 | #### Word elision
 | 
| 44 | s1=''
 | 
| 45 | argv.py $s1 - "$s1"
 | 
| 46 | ## stdout: ['-', '']
 | 
| 47 | 
 | 
| 48 | #### Default values -- more cases
 | 
| 49 | argv.py ${undef:-hi} ${undef:-'a b'} "${undef:-c d}" "${un:-"e f"}" "${un:-'g h'}"
 | 
| 50 | ## stdout: ['hi', 'a b', 'c d', 'e f', "'g h'"]
 | 
| 51 | 
 | 
| 52 | #### Globbing after splitting
 | 
| 53 | touch _tmp/foo.gg _tmp/bar.gg _tmp/foo.hh
 | 
| 54 | pat='_tmp/*.hh _tmp/*.gg'
 | 
| 55 | argv.py $pat
 | 
| 56 | ## stdout: ['_tmp/foo.hh', '_tmp/bar.gg', '_tmp/foo.gg']
 | 
| 57 | 
 | 
| 58 | #### Globbing escaping
 | 
| 59 | touch '_tmp/[bc]ar.mm' # file that looks like a glob pattern
 | 
| 60 | touch _tmp/bar.mm _tmp/car.mm
 | 
| 61 | argv.py '_tmp/[bc]'*.mm - _tmp/?ar.mm
 | 
| 62 | ## stdout: ['_tmp/[bc]ar.mm', '-', '_tmp/bar.mm', '_tmp/car.mm']
 |