#!/bin/sh

echo -n $0: 'XREF... '

cat >test.bas <<'eof'
 10 print "xref"
 20 a=1
 30 b=3
 35 dim c(2,3)
 40 function double(x)
 50   double=2*x
 60 end function
 70 sub hello(name$)
 80   print "Hello ";name$;"!"
 90 subend
100 print double(a)
110 hello("Peter")
120 mat print c;
xref
eof

cat >test.ref <<'eof'
Function Referenced in line
double   40 100
hello    70 110

Variable Referenced in line
a        20 100
b        30

Array    Referenced in line
c        35 120
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
