#!/bin/sh

echo -n $0: 'MID$ on left side... '

cat >test.bas <<'eof'
 10 mid$(a$,6,4)="ABCD"
 20 print a$
 30 a$="0123456789"
 40 mid$(a$,6,4)="ABCD"
 50 print a$
 60 a$="0123456789"
 70 let mid$(a$,6,4)="ABCD"
 80 print a$
 90 ' Test underrun
100 a$="0123456789"
110 let mid$(a$,5,4)="AB"
120 print a$
130 ' Test overrun
140 a$="0123456789"
150 let mid$(a$,5,4)="ABCDEFGHIJKL"
160 print a$
170 ' Test short dest$
180 a$="0123456"
190 let mid$(a$,5,4)="ABCDEFGHIJKL"
200 print a$
eof

cat >test.ref <<'eof'

01234ABCD9
01234ABCD9
0123AB6789
0123ABCD89
0123ABC
eof

sh ./test/runbas test.bas >test.data

if cmp test.ref test.data
then
  rm -f test.*
  echo passed
else
  echo failed
  exit 1
fi
