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 "$@" } nameref: spec test case results

Results for nameref.test.sh

statusoshosh-cpp
pass 2525
FAIL 77
total3232
caseoshosh-cppdescription
0pass pass pass array by reference
1pass pass mutate array by reference
2pass pass pass assoc array by reference
3pass pass pass local array by reference, relying on DYNAMIC SCOPING
4pass pass flag -n and +n
5pass pass mutating through nameref: ref=
6FAIL FAIL flag -n combined ${!ref} -- bash INVERTS
detailsdetails
7pass pass named ref with $# doesn't work
8pass pass named ref with $# and shopt -s strict_nameref
9pass pass named ref with 1 $1 etc.
10pass pass assign to invalid ref
11pass pass assign to invalid ref with strict_nameref
12pass pass name ref on Undef cell
13pass pass assign to empty nameref and invalid nameref
14pass pass -n attribute before it has a value
15pass pass -n attribute on array is hard error, not a warning
16pass pass exported nameref
17pass pass readonly nameref doesn't prevent assigning through it
18pass pass readonly var can't be assigned through nameref
19pass pass unset nameref
20pass pass Chain of namerefs
21pass pass Mutually recursive namerefs detected on READ
22pass pass Mutually recursive namerefs detected on WRITE
23pass pass Dynamic scope with namerefs
24pass pass change reference itself
25FAIL FAIL a[2] in nameref
detailsdetails
26FAIL FAIL a[expr] in nameref
detailsdetails
27FAIL FAIL a[@] in nameref
detailsdetails
28pass pass mutate through nameref: ref[0]=
29FAIL FAIL bad mutation through nameref: ref[0]= where ref is array[0]
detailsdetails
30FAIL FAIL @ in nameref isn't supported, unlike in ${!ref}
detailsdetails
31FAIL FAIL Unquoted assoc reference on RHS
detailsdetails
50 passed, 0 OK, 0 not implemented, 0 BUG, 7 failed, 0 timeouts, 0 cases skipped
7 failed under osh

Details on runs that didn't PASS

osh6 flag -n combined ${!ref} -- bash INVERTS

[osh stdout] Expected 'ref=x\n!ref=foo\nNOW A NAMEREF\nref=foo\n!ref=x\n' Got 'ref=x\n!ref=foo\nNOW A NAMEREF\nref=foo\n!ref=FOO\n'

stdout:
ref=x
!ref=foo
NOW A NAMEREF
ref=foo
!ref=FOO
stderr:
osh-cpp6 flag -n combined ${!ref} -- bash INVERTS

[osh-cpp stdout] Expected 'ref=x\n!ref=foo\nNOW A NAMEREF\nref=foo\n!ref=x\n' Got 'ref=x\n!ref=foo\nNOW A NAMEREF\nref=foo\n!ref=FOO\n'

stdout:
ref=x
!ref=foo
NOW A NAMEREF
ref=foo
!ref=FOO
stderr:
osh25 a[2] in nameref

[osh stdout] Expected 'ref=two\n', got 'ref=a[2]\n'

stdout:
ref=a[2]
stderr:
osh-cpp25 a[2] in nameref

[osh-cpp stdout] Expected 'ref=two\n', got 'ref=a[2]\n'

stdout:
ref=a[2]
stderr:
osh26 a[expr] in nameref

[osh stdout] Expected 'ref=three\n', got 'ref=a[$(echo 2) + 1]\n'

stdout:
ref=a[$(echo 2) + 1]
stderr:
osh-cpp26 a[expr] in nameref

[osh-cpp stdout] Expected 'ref=three\n', got 'ref=a[$(echo 2) + 1]\n'

stdout:
ref=a[$(echo 2) + 1]
stderr:
osh27 a[@] in nameref

[osh stdout] Expected "['ref', 'A B', 'C']\nstatus=1\n['ref[@]']\n['ref', 'A B', 'C']\n['a[@]', 'A B', 'C']\n" Got "['ref', 'a[@]']\nstatus=0\n['ref[@]', 'X', 'Y', 'Z']\n['ref', 'X']\n['a[@]', 'A B', 'C']\n"

stdout:
['ref', 'a[@]']
status=0
['ref[@]', 'X', 'Y', 'Z']
['ref', 'X']
['a[@]', 'A B', 'C']
stderr:
osh-cpp27 a[@] in nameref

[osh-cpp stdout] Expected "['ref', 'A B', 'C']\nstatus=1\n['ref[@]']\n['ref', 'A B', 'C']\n['a[@]', 'A B', 'C']\n" Got "['ref', 'a[@]']\nstatus=0\n['ref[@]', 'X', 'Y', 'Z']\n['ref', 'X']\n['a[@]', 'A B', 'C']\n"

stdout:
['ref', 'a[@]']
status=0
['ref[@]', 'X', 'Y', 'Z']
['ref', 'X']
['a[@]', 'A B', 'C']
stderr:
osh29 bad mutation through nameref: ref[0]= where ref is array[0]

[osh stdout] Expected 'status=1\nX Y Z\n', got ''
[osh status] Expected 0, got 1

stdout:
stderr: 
  ref[0]=foo  # error in bash: 'array[0]': not a valid identifier
  ^~~~
[ stdin ]:3: fatal: Can't assign to items in a string
osh-cpp29 bad mutation through nameref: ref[0]= where ref is array[0]

[osh-cpp stdout] Expected 'status=1\nX Y Z\n', got ''
[osh-cpp status] Expected 0, got 1

stdout:
stderr: 
  ref[0]=foo  # error in bash: 'array[0]': not a valid identifier
  ^~~~
[ stdin ]:3: fatal: Can't assign to items in a string
osh30 @ in nameref isn't supported, unlike in ${!ref}

[osh stdout] Expected u'', got 'status=0\nref=@\nstatus=0\n'
[osh status] Expected 1, got 0

stdout:
status=0
ref=@
status=0
stderr:
osh-cpp30 @ in nameref isn't supported, unlike in ${!ref}

[osh-cpp stdout] Expected u'', got 'status=0\nref=@\nstatus=0\n'
[osh-cpp status] Expected 1, got 0

stdout:
status=0
ref=@
status=0
stderr:
osh31 Unquoted assoc reference on RHS

[osh stdout] Expected "['bar']\n", got "['bashup_ev_r[foo]']\n"

stdout:
['bashup_ev_r[foo]']
stderr:
osh-cpp31 Unquoted assoc reference on RHS

[osh-cpp stdout] Expected "['bar']\n", got "['bashup_ev_r[foo]']\n"

stdout:
['bashup_ev_r[foo]']
stderr: