#!/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

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

/public/public/monopoly/diffpp > test.in 2>/dev/null << 'endOfSampleInput'

Game
 DeedIndex
  PropertyDeed
   Key a end
   List
    DeedPtr Key b end end 
    DeedPtr Key c end end 
    DeedPtr Key d end end 
   end
   Key AA end 
   Key AA end 
   1000 400
   false
   200
   none
   none         10
   oneHouse    100
   twoHouses   200
   threeHouses 300
   fourHouses  400
   hotel       500
  end

  PropertyDeed
   Key b end
   List
    DeedPtr Key a end end 
    DeedPtr Key c end end 
    DeedPtr Key d end end 
   end
   Key BB end 
   Key BB end 
   1001 500
   false
   200
   oneHouse
   none         21
   oneHouse    101
   twoHouses   201
   threeHouses 301
   fourHouses  401
   hotel       501
  end

  PropertyDeed
   Key c end
   List
    DeedPtr Key b end end 
    DeedPtr Key a end end 
    DeedPtr Key d end end 
   end
   Key CC end 
   Key CC end 
   1002 600
   false
   200
   twoHouses
   none         32
   oneHouse    102
   twoHouses   202
   threeHouses 302
   fourHouses  402
   hotel       502
  end

  PropertyDeed
   Key d end
   List
    DeedPtr Key b end end 
    DeedPtr Key c end end 
    DeedPtr Key a end end 
   end
   Key AA end 
   Key DD end 
   1003 700
   false
   200
   threeHouses
   none         43
   oneHouse    103
   twoHouses   203
   threeHouses 303
   fourHouses  403
   hotel       503
  end

  PropertyDeed
   Key 1 end
   List
    DeedPtr Key 2 end end 
   end
   Key player end 
   Key ONE end 
   1111 111
   false
   200
   none
   none         14
   oneHouse    104
   twoHouses   204
   threeHouses 304
   fourHouses  404
   hotel       504
  end

  PropertyDeed
   Key 2 end
   List
    DeedPtr Key 1 end end 
   end
   Key player end 
   Key TWO end 
   2222 222
   false
   200
   fourHouses
   none         15
   oneHouse    105
   twoHouses   205
   threeHouses 305
   fourHouses  405
   hotel       505
  end

  PropertyDeed
   Key nobody end
   List
   end
   Key Noone end 
   Key Nowhere end 
   99999 9999
   false
   200
   hotel
   none         11
   oneHouse    106
   twoHouses   206
   threeHouses 306
   fourHouses  406
   hotel       506
  end
 end

 Dice 3 4 end
 
end 

List
 DeedPtr Key a end end 
 DeedPtr Key b end end 
 DeedPtr Key c end end 
 DeedPtr Key d end end 
 DeedPtr Key 1 end end 
 DeedPtr Key 2 end end 
 DeedPtr Key nobody end end 
end

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

/public/public/monopoly/diffpp > test.ok 2>/dev/null << 'endOfExpectedOutput'

Game
 DeedIndex
  PropertyDeed
   Key a end
   List
    DeedPtr Key b end end 
    DeedPtr Key c end end 
    DeedPtr Key d end end 
   end
   Key AA end 
   Key AA end 
   1000 400
   false
   200
   none
   none         10
   oneHouse    100
   twoHouses   200
   threeHouses 300
   fourHouses  400
   hotel       500
  end

  PropertyDeed
   Key b end
   List
    DeedPtr Key a end end 
    DeedPtr Key c end end 
    DeedPtr Key d end end 
   end
   Key BB end 
   Key BB end 
   1001 500
   false
   200
   oneHouse
   none         21
   oneHouse    101
   twoHouses   201
   threeHouses 301
   fourHouses  401
   hotel       501
  end

  PropertyDeed
   Key c end
   List
    DeedPtr Key b end end 
    DeedPtr Key a end end 
    DeedPtr Key d end end 
   end
   Key CC end 
   Key CC end 
   1002 600
   false
   200
   twoHouses
   none         32
   oneHouse    102
   twoHouses   202
   threeHouses 302
   fourHouses  402
   hotel       502
  end

  PropertyDeed
   Key d end
   List
    DeedPtr Key b end end 
    DeedPtr Key c end end 
    DeedPtr Key a end end 
   end
   Key AA end 
   Key DD end 
   1003 700
   false
   200
   threeHouses
   none         43
   oneHouse    103
   twoHouses   203
   threeHouses 303
   fourHouses  403
   hotel       503
  end

  PropertyDeed
   Key 1 end
   List
    DeedPtr Key 2 end end 
   end
   Key player end 
   Key ONE end 
   1111 111
   false
   200
   none
   none         14
   oneHouse    104
   twoHouses   204
   threeHouses 304
   fourHouses  404
   hotel       504
  end

  PropertyDeed
   Key 2 end
   List
    DeedPtr Key 1 end end 
   end
   Key player end 
   Key TWO end 
   2222 222
   false
   200
   fourHouses
   none         15
   oneHouse    105
   twoHouses   205
   threeHouses 305
   fourHouses  405
   hotel       505
  end

  PropertyDeed
   Key nobody end
   List
   end
   Key Noone end 
   Key Nowhere end 
   99999 9999
   false
   200
   hotel
   none         11
   oneHouse    106
   twoHouses   206
   threeHouses 306
   fourHouses  406
   hotel       506
  end
 end

 Dice 3 4 end
 
end 

 10  # no monopoly, no houses
101  # one house
202  # two houses
303  # three houses 
 28  # monopoly
405  # four houses
506  # hotel

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

$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
