Skip to content

Commit

Permalink
[test/spec] Mark unset -v 'a[i]' as failing.
Browse files Browse the repository at this point in the history
It shouldn't be N-I since we may implement it.

Addresses issue #651.  Also tests a corner case from #661.
  • Loading branch information
Andy Chu committed Mar 18, 2020
1 parent 15ea657 commit fff807f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 25 additions & 4 deletions spec/builtin-vars.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,33 @@ x z len=2
status=0
y z len=3
## END
## N-I osh STDOUT:
status=2
x y z len=3

#### unset -v (mentioned on issue #661)
case $SH in (dash|mksh|zsh) return; esac

declare -A dict=()
key=1],a[1
dict["$key"]=foo
echo ${#dict[@]}
echo keys=${!dict[@]}
echo vals=${dict[@]}

unset -v 'dict["$key"]'
echo ${#dict[@]}
echo keys=${!dict[@]}
echo vals=${dict[@]}
## STDOUT:
1
keys=1],a[1
vals=foo
0
keys=
vals=
## END
## N-I dash/mksh/zsh stdout-json: ""


#### Unset array member with expression
#### Unset array member with dynamic parsing
i=1
a=(w x y z)
unset 'a[ i - 1 ]' a[i+1] # note: can't have space between a and [
Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ builtin-dirs() {
}

builtin-vars() {
sh-spec spec/builtin-vars.test.sh --osh-failures-allowed 1 \
sh-spec spec/builtin-vars.test.sh --osh-failures-allowed 3 \
${REF_SHELLS[@]} $ZSH $OSH_LIST "$@"
}

Expand Down

0 comments on commit fff807f

Please sign in to comment.