Skip to content

Commit

Permalink
Failing test for appending to associative array.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Sep 29, 2018
1 parent 5b51278 commit 72f5761
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions osh/osh.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ module osh
| StringWord(id id, string s)

-- TODO: Need more tokens/spids to translate a[x++]=1
-- These don't follow the LST design, because they're shared for
-- s['x']+='y' and (( s[ 42 ] ++ )).
-- It would be better runtime.lvalue were be the shared representation, and
-- there were 2 different lhs_expr types. They both should contribute their
-- location information.
lhs_expr =
LhsName(string name)
| LhsIndexedName(string name, arith_expr index)
Expand Down
10 changes: 10 additions & 0 deletions spec/assoc.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,13 @@ echo "${a[@]}"
#echo "${!a[@]}"
## N-I mksh stdout-json: ""
## BUG bash stdout-json: "3\n"

#### Append to associative array value
declare -A a
a['x']+='foo'
a['x']+='bar'
argv.py "${a["x"]}"
## STDOUT:
['foobar']
## END

2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ append() {

# associative array -- mksh and zsh implement different associative arrays.
assoc() {
sh-spec spec/assoc.test.sh --osh-failures-allowed 10 \
sh-spec spec/assoc.test.sh --osh-failures-allowed 11 \
$BASH $OSH_LIST "$@"
}

Expand Down

0 comments on commit 72f5761

Please sign in to comment.