You aren't passing an array; you are only passing the values stored in the array. In fact, you cannot pass the array as a whole, because there is no such thing as an array value in shell, just names with an array attribute set.
To do what you want, you have to use the array as a global variable, which means you can only do this with a function, not a script. Also, while it might be possible to do using indirect parameter expansion alone, it's far simpler to do using namerefs (requiring bash 4.3 or later):
foo () {
declare -n a=$1
for key in "${!a[@]}"; do
echo "key: $key"
echo "value: ${a[$key]}"
done
}
Note that you'll get a circular name reference error, though, if the internal array name set by the declare command is the same as the global you are trying to pass; caveat emptor.
To create a series of alternating keys and values to pass as separate arguments, use a regular array.
declare -A arr
arr[romeo]="John Doe"
arr[juliet]="Jane Smith"
kvpairs=()
for k in "${!arr[@]}"; do
kvpairs+=( "$k" "${arr[$k]}" )
done
./test.sh "${kvpairs[@]}"
(Note: I don't recall if the array keys are stored or iterated in any particular order; assume they are not.)
Inside test.sh, you can reconstruct the array:
declare -A arr
while (( $# > 0 )); do
arr["$1"]="$2"
shift 2
done