run-file () { local spec_name=$1; shift; local spec_file=spec/$spec_name.test.sh; local suite; suite=$(test/sh_spec.py --print-spec-suite $spec_file); local spec_subdir; case $suite in osh) spec_subdir='osh-cpp' ;; ysh) spec_subdir='ysh-cpp' ;; *) die "Invalid suite $suite" ;; esac; local base_dir=_tmp/spec/$spec_subdir; mkdir -v -p $base_dir; sh-spec $spec_file --timeout 10 --oils-bin-dir $PWD/bin --oils-cpp-bin-dir $REPO_ROOT/_bin/cxx-asan --tsv-output $base_dir/${spec_name}.tsv "$@" } assoc: spec test case results

Results for assoc.test.sh

statusoshosh-cpp
pass 3737
ok 11
N-I 11
FAIL 44
total4343
caseoshosh-cppdescription
0pass pass Literal syntax ([x]=y)
1pass pass set associative array to indexed array literal (very surprising bash behavior)
2pass pass Can't initialize assoc array with indexed array
3pass pass Initializing indexed array with assoc array
4pass pass create empty assoc array, put, then get
5pass pass Empty value (doesn't use EmptyWord?)
6pass pass retrieve keys with !
7pass pass retrieve values with ${A[@]}
8FAIL FAIL coerce to string with ${A[*]}, etc.
detailsdetails
9pass pass ${A[@]/b/B}
10pass pass ${A[@]#prefix}
11pass pass ${assoc} is like ${assoc[0]}
12pass pass length ${#a[@]}
13pass pass lookup with ${a[0]} -- "0" is a string
14pass pass lookup with double quoted strings "mykey"
15pass pass lookup with single quoted string
16pass pass lookup with unquoted $key and quoted "$i$i"
17pass pass lookup by unquoted string doesn't work in OSH because it's a variable
18pass pass bash bug: "i+1" and i+1 are the same key
19pass pass Array stored in associative array gets converted to string (without strict_array)
20pass pass Indexed array as key of associative array coerces to string (without shopt -s strict_array)
21pass pass Append to associative array value A['x']+='suffix'
22pass pass Slice of associative array doesn't make sense in bash
23N-I N-I bash variable can have an associative array part and a string part
detailsdetails
24pass pass Associative array expressions inside (( )) with keys that look like numbers
25pass pass (( A[5] += 42 ))
26pass pass (( A[5] += 42 )) with empty cell
27pass pass setting key to itself (from bash-bug mailing list)
28ok ok readonly associative array can't be modified
detailsdetails
29pass pass associative array and brace expansion
30pass pass bash mangles array #1
31pass pass bash mangles array and brace #2
32pass pass declare -A A=() allowed
33pass pass unset -v and assoc array
34FAIL FAIL nameref and assoc array
detailsdetails
35pass pass ${!ref} and assoc array
36pass pass printf -v and assoc array
37pass pass bash bug: (( A["$key"] = 1 )) doesn't work
38FAIL FAIL Implicit increment of keys
detailsdetails
39pass pass test -v assoc[key]
40FAIL FAIL test -v with dynamic parsing
detailsdetails
41pass pass [[ -v assoc[key] ]]
42pass pass [[ -v assoc[key] ]] syntax errors
74 passed, 2 OK, 2 not implemented, 0 BUG, 4 failed, 0 timeouts, 0 cases skipped
4 failed under osh

Details on runs that didn't PASS

osh8 coerce to string with ${A[*]}, etc.

[osh stdout] Expected "['xx yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n" Got "['xx', 'yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n"

stdout:
['xx', 'yy']
['X X Y Y']
['xx', 'yy']
['X', 'X', 'Y', 'Y']
stderr:
osh-cpp8 coerce to string with ${A[*]}, etc.

[osh-cpp stdout] Expected "['xx yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n" Got "['xx', 'yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n"

stdout:
['xx', 'yy']
['X X Y Y']
['xx', 'yy']
['X', 'X', 'Y', 'Y']
stderr:
osh23 bash variable can have an associative array part and a string part

stdout:
1 2
1 2 zero
stderr:
  echo ${assoc[1]} ${assoc[2]} ${assoc}
         ^~~~~
[ stdin ]:8: fatal: Can't index string 'assoc' with integer
osh-cpp23 bash variable can have an associative array part and a string part

stdout:
1 2
1 2 zero
stderr:
  echo ${assoc[1]} ${assoc[2]} ${assoc}
         ^~~~~
[ stdin ]:8: fatal: Can't index string 'assoc' with integer
osh28 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh-cpp28 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh34 nameref and assoc array

[osh stdout] Expected 'values: val\nbefore val\nafter val2\nvalues: val2\n---\nbefore val2\nafter val3\nvalues: val3\n' Got 'values: val\nbefore A["K"]\nafter val2\nvalues: val\n---\nbefore A[$key]\nafter val3\nvalues: val\n'

stdout:
values: val
before A["K"]
after val2
values: val
---
before A[$key]
after val3
values: val
stderr:
osh-cpp34 nameref and assoc array

[osh-cpp stdout] Expected 'values: val\nbefore val\nafter val2\nvalues: val2\n---\nbefore val2\nafter val3\nvalues: val3\n' Got 'values: val\nbefore A["K"]\nafter val2\nvalues: val\n---\nbefore A[$key]\nafter val3\nvalues: val\n'

stdout:
values: val
before A["K"]
after val2
values: val
---
before A[$key]
after val3
values: val
stderr:
osh38 Implicit increment of keys

[osh stdout] Expected "['30', '31', '40', '41']\n['a', 'b', 'x', 'y']\n" Got ''
[osh status] Expected 0, got 2

stdout:
stderr: 
  declare -a arr=( [30]=a b [40]=x y)
                          ^
[ stdin ]:1: Expected associative array pair
osh-cpp38 Implicit increment of keys

[osh-cpp stdout] Expected "['30', '31', '40', '41']\n['a', 'b', 'x', 'y']\n" Got ''
[osh-cpp status] Expected 0, got 2

stdout:
stderr: 
  declare -a arr=( [30]=a b [40]=x y)
                          ^
[ stdin ]:1: Expected associative array pair
osh40 test -v with dynamic parsing

[osh stdout] Expected 'empty=0\nk=0\nnonexistent=1\n', got 'empty=1\nk=1\nnonexistent=1\n'

stdout:
empty=1
k=1
nonexistent=1
stderr:
osh-cpp40 test -v with dynamic parsing

[osh-cpp stdout] Expected 'empty=0\nk=0\nnonexistent=1\n', got 'empty=1\nk=1\nnonexistent=1\n'

stdout:
empty=1
k=1
nonexistent=1
stderr: