#!/bin/sh
################################################################
#
#  [# Edit, Date, User, Module #]
#
#  test-script for monopoly-template
#
here=`pwd`
if test $? -ne 0 ; then exit 1; fi
tmp=/tmp/$$
mkdir $tmp
if test $? -ne 0 ; then exit 1; fi
cd $tmp
if test $? -ne 0 ; then exit 1; fi

fail()
{
	echo FAILED 1>&2
	cd $here
	chmod u+w `find $tmp -type d -print`
	rm -rf $tmp
	exit 1
}

pass()
{
	cd $here
	chmod u+w `find $tmp -type d -print`
	rm -rf $tmp
	exit 0
}

trap 'fail' 1 2 3 15

# find game file
gamefile=$here/game.data
if [ ! -r $gamefile ]; then
  gamefile=$here/baseline/game.data
  if [ ! -r $gamefile ]; then
    fail;
  fi
fi

###  Enter argument list for `monopoly' here ###
arglist='checkSpaceL'

cat > test.test 2>/dev/null << 'endOfSampleInput'

endOfSampleInput
if test $? -ne 0 ; then fail; fi

cat $gamefile test.test | /public/public/monopoly/diffpp > test.in
if test $? -ne 0 ; then fail; fi

cat > test.test 2>/dev/null << 'endOfExpectedOutput'
Going forward -7 steps
Passing
 DeedSpace  Key  p8b  end 
 DeedPtr  Key  p8b  end 
 end 
 end 
Passing
 TaxSpace  Key  luxury-tax  end 
 100  end 
Passing
 DeedSpace  Key  p8a  end 
 DeedPtr  Key  p8a  end 
 end 
 end 
Passing
 ChanceSpace  Key  chance3  end 
 end 
Passing
 DeedSpace  Key  s4  end 
 DeedPtr  Key  s4  end 
 end 
 end 
Passing
 DeedSpace  Key  p7c  end 
 DeedPtr  Key  p7c  end 
 end 
 end 
Stopping
 ChestSpace  Key  community3  end 
 end 
Going forward -6 steps
Passing
 DeedSpace  Key  p7b  end 
 DeedPtr  Key  p7b  end 
 end 
 end 
Passing
 DeedSpace  Key  p7a  end 
 DeedPtr  Key  p7a  end 
 end 
 end 
Passing
 GotoJailSpace  Key  police  end 
 end 
Passing
 DeedSpace  Key  p6c  end 
 DeedPtr  Key  p6c  end 
 end 
 end 
Passing
 DeedSpace  Key  u2  end 
 DeedPtr  Key  u2  end 
 end 
 end 
Stopping
 DeedSpace  Key  p6b  end 
 DeedPtr  Key  p6b  end 
 end 
 end 
Going forward -5 steps
Passing
 DeedSpace  Key  p6a  end 
 DeedPtr  Key  p6a  end 
 end 
 end 
Passing
 DeedSpace  Key  s3  end 
 DeedPtr  Key  s3  end 
 end 
 end 
Passing
 DeedSpace  Key  p5c  end 
 DeedPtr  Key  p5c  end 
 end 
 end 
Passing
 DeedSpace  Key  p5b  end 
 DeedPtr  Key  p5b  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance2  end 
 end 
Going forward -4 steps
Passing
 DeedSpace  Key  p5a  end 
 DeedPtr  Key  p5a  end 
 end 
 end 
Passing
 FreeSpace  Key  free-parking  end 
 end 
Passing
 DeedSpace  Key  p4c  end 
 DeedPtr  Key  p4c  end 
 end 
 end 
Stopping
 DeedSpace  Key  p4b  end 
 DeedPtr  Key  p4b  end 
 end 
 end 
Going forward -3 steps
Passing
 ChestSpace  Key  community2  end 
 end 
Passing
 DeedSpace  Key  p4a  end 
 DeedPtr  Key  p4a  end 
 end 
 end 
Stopping
 DeedSpace  Key  s2  end 
 DeedPtr  Key  s2  end 
 end 
 end 
Going forward -2 steps
Passing
 DeedSpace  Key  p3c  end 
 DeedPtr  Key  p3c  end 
 end 
 end 
Stopping
 DeedSpace  Key  p3b  end 
 DeedPtr  Key  p3b  end 
 end 
 end 
Going forward -1 steps
Stopping
 DeedSpace  Key  u1  end 
 DeedPtr  Key  u1  end 
 end 
 end 
Going forward 0 steps
Stopping
 DeedSpace  Key  u1  end 
 DeedPtr  Key  u1  end 
 end 
 end 
Going forward 1 steps
Stopping
 DeedSpace  Key  p3b  end 
 DeedPtr  Key  p3b  end 
 end 
 end 
Going forward 2 steps
Passing
 DeedSpace  Key  p3c  end 
 DeedPtr  Key  p3c  end 
 end 
 end 
Stopping
 DeedSpace  Key  s2  end 
 DeedPtr  Key  s2  end 
 end 
 end 
Going forward 3 steps
Passing
 DeedSpace  Key  p4a  end 
 DeedPtr  Key  p4a  end 
 end 
 end 
Passing
 ChestSpace  Key  community2  end 
 end 
Stopping
 DeedSpace  Key  p4b  end 
 DeedPtr  Key  p4b  end 
 end 
 end 
Going forward 4 steps
Passing
 DeedSpace  Key  p4c  end 
 DeedPtr  Key  p4c  end 
 end 
 end 
Passing
 FreeSpace  Key  free-parking  end 
 end 
Passing
 DeedSpace  Key  p5a  end 
 DeedPtr  Key  p5a  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance2  end 
 end 
Going forward 5 steps
Passing
 DeedSpace  Key  p5b  end 
 DeedPtr  Key  p5b  end 
 end 
 end 
Passing
 DeedSpace  Key  p5c  end 
 DeedPtr  Key  p5c  end 
 end 
 end 
Passing
 DeedSpace  Key  s3  end 
 DeedPtr  Key  s3  end 
 end 
 end 
Passing
 DeedSpace  Key  p6a  end 
 DeedPtr  Key  p6a  end 
 end 
 end 
Stopping
 DeedSpace  Key  p6b  end 
 DeedPtr  Key  p6b  end 
 end 
 end 
Going forward 6 steps
Passing
 DeedSpace  Key  u2  end 
 DeedPtr  Key  u2  end 
 end 
 end 
Passing
 DeedSpace  Key  p6c  end 
 DeedPtr  Key  p6c  end 
 end 
 end 
Passing
 GotoJailSpace  Key  police  end 
 end 
Passing
 DeedSpace  Key  p7a  end 
 DeedPtr  Key  p7a  end 
 end 
 end 
Passing
 DeedSpace  Key  p7b  end 
 DeedPtr  Key  p7b  end 
 end 
 end 
Stopping
 ChestSpace  Key  community3  end 
 end 
Going forward 7 steps
Passing
 DeedSpace  Key  p7c  end 
 DeedPtr  Key  p7c  end 
 end 
 end 
Passing
 DeedSpace  Key  s4  end 
 DeedPtr  Key  s4  end 
 end 
 end 
Passing
 ChanceSpace  Key  chance3  end 
 end 
Passing
 DeedSpace  Key  p8a  end 
 DeedPtr  Key  p8a  end 
 end 
 end 
Passing
 TaxSpace  Key  luxury-tax  end 
 100  end 
Passing
 DeedSpace  Key  p8b  end 
 DeedPtr  Key  p8b  end 
 end 
 end 
Stopping
 GoSpace  Key  GO  end 
 200  end 
Going backward -7 steps
Passing
 DeedSpace  Key  p1a  end 
 DeedPtr  Key  p1a  end 
 end 
 end 
Passing
 ChestSpace  Key  community1  end 
 end 
Passing
 DeedSpace  Key  p1b  end 
 DeedPtr  Key  p1b  end 
 end 
 end 
Passing
 TaxSpace  Key  income-tax  end 
 200  end 
Passing
 DeedSpace  Key  s1  end 
 DeedPtr  Key  s1  end 
 end 
 end 
Passing
 DeedSpace  Key  p2a  end 
 DeedPtr  Key  p2a  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance1  end 
 end 
Going backward -6 steps
Passing
 DeedSpace  Key  p2b  end 
 DeedPtr  Key  p2b  end 
 end 
 end 
Passing
 DeedSpace  Key  p2c  end 
 DeedPtr  Key  p2c  end 
 end 
 end 
Passing
 JailSpace  Key  just_visiting  end 
 end 
Passing
 DeedSpace  Key  p3a  end 
 DeedPtr  Key  p3a  end 
 end 
 end 
Passing
 DeedSpace  Key  u1  end 
 DeedPtr  Key  u1  end 
 end 
 end 
Stopping
 DeedSpace  Key  p3b  end 
 DeedPtr  Key  p3b  end 
 end 
 end 
Going backward -5 steps
Passing
 DeedSpace  Key  p3c  end 
 DeedPtr  Key  p3c  end 
 end 
 end 
Passing
 DeedSpace  Key  s2  end 
 DeedPtr  Key  s2  end 
 end 
 end 
Passing
 DeedSpace  Key  p4a  end 
 DeedPtr  Key  p4a  end 
 end 
 end 
Passing
 ChestSpace  Key  community2  end 
 end 
Stopping
 DeedSpace  Key  p4b  end 
 DeedPtr  Key  p4b  end 
 end 
 end 
Going backward -4 steps
Passing
 DeedSpace  Key  p4c  end 
 DeedPtr  Key  p4c  end 
 end 
 end 
Passing
 FreeSpace  Key  free-parking  end 
 end 
Passing
 DeedSpace  Key  p5a  end 
 DeedPtr  Key  p5a  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance2  end 
 end 
Going backward -3 steps
Passing
 DeedSpace  Key  p5b  end 
 DeedPtr  Key  p5b  end 
 end 
 end 
Passing
 DeedSpace  Key  p5c  end 
 DeedPtr  Key  p5c  end 
 end 
 end 
Stopping
 DeedSpace  Key  s3  end 
 DeedPtr  Key  s3  end 
 end 
 end 
Going backward -2 steps
Passing
 DeedSpace  Key  p6a  end 
 DeedPtr  Key  p6a  end 
 end 
 end 
Stopping
 DeedSpace  Key  p6b  end 
 DeedPtr  Key  p6b  end 
 end 
 end 
Going backward -1 steps
Stopping
 DeedSpace  Key  u2  end 
 DeedPtr  Key  u2  end 
 end 
 end 
Going backward 0 steps
Stopping
 DeedSpace  Key  u2  end 
 DeedPtr  Key  u2  end 
 end 
 end 
Going backward 1 steps
Stopping
 DeedSpace  Key  p6b  end 
 DeedPtr  Key  p6b  end 
 end 
 end 
Going backward 2 steps
Passing
 DeedSpace  Key  p6a  end 
 DeedPtr  Key  p6a  end 
 end 
 end 
Stopping
 DeedSpace  Key  s3  end 
 DeedPtr  Key  s3  end 
 end 
 end 
Going backward 3 steps
Passing
 DeedSpace  Key  p5c  end 
 DeedPtr  Key  p5c  end 
 end 
 end 
Passing
 DeedSpace  Key  p5b  end 
 DeedPtr  Key  p5b  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance2  end 
 end 
Going backward 4 steps
Passing
 DeedSpace  Key  p5a  end 
 DeedPtr  Key  p5a  end 
 end 
 end 
Passing
 FreeSpace  Key  free-parking  end 
 end 
Passing
 DeedSpace  Key  p4c  end 
 DeedPtr  Key  p4c  end 
 end 
 end 
Stopping
 DeedSpace  Key  p4b  end 
 DeedPtr  Key  p4b  end 
 end 
 end 
Going backward 5 steps
Passing
 ChestSpace  Key  community2  end 
 end 
Passing
 DeedSpace  Key  p4a  end 
 DeedPtr  Key  p4a  end 
 end 
 end 
Passing
 DeedSpace  Key  s2  end 
 DeedPtr  Key  s2  end 
 end 
 end 
Passing
 DeedSpace  Key  p3c  end 
 DeedPtr  Key  p3c  end 
 end 
 end 
Stopping
 DeedSpace  Key  p3b  end 
 DeedPtr  Key  p3b  end 
 end 
 end 
Going backward 6 steps
Passing
 DeedSpace  Key  u1  end 
 DeedPtr  Key  u1  end 
 end 
 end 
Passing
 DeedSpace  Key  p3a  end 
 DeedPtr  Key  p3a  end 
 end 
 end 
Passing
 JailSpace  Key  just_visiting  end 
 end 
Passing
 DeedSpace  Key  p2c  end 
 DeedPtr  Key  p2c  end 
 end 
 end 
Passing
 DeedSpace  Key  p2b  end 
 DeedPtr  Key  p2b  end 
 end 
 end 
Stopping
 ChanceSpace  Key  chance1  end 
 end 
Going backward 7 steps
Passing
 DeedSpace  Key  p2a  end 
 DeedPtr  Key  p2a  end 
 end 
 end 
Passing
 DeedSpace  Key  s1  end 
 DeedPtr  Key  s1  end 
 end 
 end 
Passing
 TaxSpace  Key  income-tax  end 
 200  end 
Passing
 DeedSpace  Key  p1b  end 
 DeedPtr  Key  p1b  end 
 end 
 end 
Passing
 ChestSpace  Key  community1  end 
 end 
Passing
 DeedSpace  Key  p1a  end 
 DeedPtr  Key  p1a  end 
 end 
 end 
Stopping
 GoSpace  Key  GO  end 
 200  end 
endOfExpectedOutput
if test $? -ne 0 ; then fail; fi

cat $gamefile test.test | /public/public/monopoly/diffpp > test.ok
  
$here/monopoly $arglist < test.in | /public/public/monopoly/diffpp > test.out 2>/dev/null
if test $? -ne 0 ; then fail; fi

diff test.ok test.out
if test $? -ne 0 ; then fail; fi

# it probably worked
pass
