Changeset - r21753:c40b0fc6418b
[Not reviewed]
master
0 2 3
fonsinchen - 10 years ago 2014-09-21 16:44:37
fonsinchen@openttd.org
(svn r26896) -Codechange: Move AIStationList* tests to separate test case
5 files changed with 118 insertions and 99 deletions:
0 comments (0 inline, 0 general)
bin/ai/regression/tst_regression/main.nut
Show inline comments
 
@@ -963,66 +963,25 @@ function Regression::Order()
 
	print("  UnshareOrders():       " + AIOrder.UnshareOrders(13));
 
	print("  AppendOrder():         " + AIOrder.AppendOrder(12, 33421, AIOrder.OF_NONE));
 

	
 
	print("  GetStopLocation():     " + AIOrder.GetStopLocation(13, 0));
 
	print("  BuildVehicle():        " + AIVehicle.BuildVehicle(23596, 8));
 
	print("  BuildRailStation():    " + AIRail.BuildRailStation(7958, AIRail.RAILTRACK_NE_SW, 1, 1, AIStation.STATION_NEW));
 
	print("  AppendOrder():         " + AIOrder.AppendOrder(20, 7958, AIOrder.OF_NONE));
 
	print("  GetOrderCount():       " + AIOrder.GetOrderCount(20));
 
	print("  GetStopLocation():     " + AIOrder.GetStopLocation(20, 0));
 
	print("  SetStopLocation():     " + AIOrder.SetStopLocation(20, 0, AIOrder.STOPLOCATION_MIDDLE));
 
	print("  GetStopLocation():     " + AIOrder.GetStopLocation(20, 0));
 

	
 
	local list = AIStationList_Vehicle(12);
 

	
 
	print("");
 
	print("--StationList_Vehicle--");
 
	print("  Count():             " + list.Count());
 
	list.Valuate(AIStation.GetLocation);
 
	print("  Location ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 0);
 
	print("  CargoWaiting(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 1);
 
	print("  CargoWaiting(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoRating, 1);
 
	print("  CargoRating(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetDistanceManhattanToTile, 30000);
 
	print("  DistanceManhattanToTile(30000) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetDistanceSquareToTile, 30000);
 
	print("  DistanceSquareToTile(30000) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.IsWithinTownInfluence, 0);
 
	print("  IsWithinTownInfluence(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 

	
 
	list = AIVehicleList_Station(3);
 
	local list = AIVehicleList_Station(3);
 

	
 
	print("");
 
	print("--VehicleList_Station--");
 
	print("  Count():             " + list.Count());
 
	list.Valuate(AIVehicle.GetLocation);
 
	print("  Location ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	print("  foreach():");
 
	foreach (idx, val in list) {
 
		print("    " + idx + " => " + val);
 
@@ -1278,45 +1237,24 @@ function Regression::Station()
 
			for (local station1 = 0; station1 <= 1000; station1 += 1000) {
 
				print("  GetCargoPlannedFrom(" + station0 + ", " + station1 + ", " + cargo + "): " +
 
						AIStation.GetCargoPlannedFrom(station0, station1, cargo));
 
				print("  GetCargoPlannedVia(" + station0 + ", " + station1 + ", " + cargo + "): " +
 
						AIStation.GetCargoPlannedFrom(station0, station1, cargo));
 
				for (local station2 = 0; station2 <= 1000; station2 += 1000) {
 
					print("  GetCargoPlannedFromVia(" + station0 + ", " + station1 + ", " + station2 + ", " + cargo + "): " +
 
							AIStation.GetCargoPlannedFromVia(station0, station1, station2, cargo));
 
				}
 
			}
 
		}
 
	}
 

	
 
	local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP);
 

	
 
	print("");
 
	print("--StationList--");
 
	print("  Count():             " + list.Count());
 
	list.Valuate(AIStation.GetLocation);
 
	print("  Location ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 0);
 
	print("  CargoWaiting(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 1);
 
	print("  CargoWaiting(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
}
 

	
 
function Regression::Tile()
 
{
 
	print("");
 
	print("--Tile--");
 
	print("  HasTreeOnTile():      " + AITile.HasTreeOnTile(33148));
 
	print("  IsFarmTile():         " + AITile.IsFarmTile(32892));
 
	print("  IsRockTile():         " + AITile.IsRockTile(31606));
 
	print("  IsRoughTile():        " + AITile.IsRoughTile(33674));
 
	print("  HasTreeOnTile():      " + AITile.HasTreeOnTile(33404));
 
	print("  IsFarmTile():         " + AITile.IsFarmTile(33404));
bin/ai/regression/tst_regression/result.txt
Show inline comments
 
@@ -7568,36 +7568,24 @@ ERROR: IsEnd() is invalid as Begin() is 
 
  GetCargoPlannedFromVia(0, 1000, 0, 1000): -1
 
  GetCargoPlannedFromVia(0, 1000, 1000, 1000): -1
 
  GetCargoPlanned(1000, 1000): -1
 
  GetCargoPlannedFrom(1000, 0, 1000): -1
 
  GetCargoPlannedVia(1000, 0, 1000): -1
 
  GetCargoPlannedFromVia(1000, 0, 0, 1000): -1
 
  GetCargoPlannedFromVia(1000, 0, 1000, 1000): -1
 
  GetCargoPlannedFrom(1000, 1000, 1000): -1
 
  GetCargoPlannedVia(1000, 1000, 1000): -1
 
  GetCargoPlannedFromVia(1000, 1000, 0, 1000): -1
 
  GetCargoPlannedFromVia(1000, 1000, 1000, 1000): -1
 

	
 
--StationList--
 
  Count():             2
 
  Location ListDump:
 
    5 => 33421
 
    4 => 33411
 
  CargoWaiting(0) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoWaiting(1) ListDump:
 
    5 => 0
 
    4 => 0
 

	
 
--Tile--
 
  HasTreeOnTile():      false
 
  IsFarmTile():         true
 
  IsRockTile():         true
 
  IsRoughTile():        true
 
  HasTreeOnTile():      true
 
  IsFarmTile():         false
 
  IsRockTile():         false
 
  IsRoughTile():        false
 
  IsSnowTile():         false
 
  IsDesertTile():       false
 
  PlantTree():          true
 
@@ -9170,48 +9158,24 @@ ERROR: IsEnd() is invalid as Begin() is 
 
  ShareOrders():         true
 
  UnshareOrders():       true
 
  AppendOrder():         true
 
  GetStopLocation():     -1
 
  BuildVehicle():        20
 
  BuildRailStation():    true
 
  AppendOrder():         true
 
  GetOrderCount():       1
 
  GetStopLocation():     2
 
  SetStopLocation():     true
 
  GetStopLocation():     1
 

	
 
--StationList_Vehicle--
 
  Count():             2
 
  Location ListDump:
 
    5 => 33421
 
    4 => 33411
 
  CargoWaiting(0) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoWaiting(1) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoRating(1) ListDump:
 
    5 => -1
 
    4 => -1
 
  DistanceManhattanToTile(30000) ListDump:
 
    5 => 106
 
    4 => 96
 
  DistanceSquareToTile(30000) ListDump:
 
    5 => 8818
 
    4 => 7058
 
  IsWithinTownInfluence(0) ListDump:
 
    5 => 0
 
    4 => 0
 

	
 
--VehicleList_Station--
 
  Count():             1
 
  Location ListDump:
 
    20 => 23596
 
  foreach():
 
    20 => 23596
 

	
 
  First Subsidy Test
 
      --Subsidy (0) --
 
        IsValidSubsidy():      true
 
        IsAwarded():           false
 
        GetAwardedTo():        -1
bin/ai/regression/tst_stationlist/main.nut
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
class Regression extends AIController {
 
	function Start();
 
};
 

	
 

	
 
function Regression::StationList()
 
{
 
	local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP);
 

	
 
	print("");
 
	print("--StationList--");
 
	print("  Count():             " + list.Count());
 
	list.Valuate(AIStation.GetLocation);
 
	print("  Location ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 0);
 
	print("  CargoWaiting(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 1);
 
	print("  CargoWaiting(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
};
 

	
 
function Regression::StationList_Vehicle()
 
{
 
	local list = AIStationList_Vehicle(12);
 

	
 
	print("");
 
	print("--StationList_Vehicle--");
 
	print("  Count():             " + list.Count());
 
	list.Valuate(AIStation.GetLocation);
 
	print("  Location ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 0);
 
	print("  CargoWaiting(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoWaiting, 1);
 
	print("  CargoWaiting(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetCargoRating, 1);
 
	print("  CargoRating(1) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetDistanceManhattanToTile, 30000);
 
	print("  DistanceManhattanToTile(30000) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.GetDistanceSquareToTile, 30000);
 
	print("  DistanceSquareToTile(30000) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
	list.Valuate(AIStation.IsWithinTownInfluence, 0);
 
	print("  IsWithinTownInfluence(0) ListDump:");
 
	for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
 
		print("    " + i + " => " + list.GetValue(i));
 
	}
 
}
 

	
 
function Regression::Start()
 
{
 
	StationList();
 
	StationList_Vehicle();
 
}
bin/ai/regression/tst_stationlist/result.txt
Show inline comments
 
new file 100644
 

	
 
--StationList--
 
  Count():             2
 
  Location ListDump:
 
    5 => 33421
 
    4 => 33411
 
  CargoWaiting(0) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoWaiting(1) ListDump:
 
    5 => 0
 
    4 => 0
 

	
 
--StationList_Vehicle--
 
  Count():             2
 
  Location ListDump:
 
    5 => 33421
 
    4 => 33411
 
  CargoWaiting(0) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoWaiting(1) ListDump:
 
    5 => 0
 
    4 => 0
 
  CargoRating(1) ListDump:
 
    5 => -1
 
    4 => -1
 
  DistanceManhattanToTile(30000) ListDump:
 
    5 => 106
 
    4 => 96
 
  DistanceSquareToTile(30000) ListDump:
 
    5 => 8818
 
    4 => 7058
 
  IsWithinTownInfluence(0) ListDump:
 
    5 => 0
 
    4 => 0
 
ERROR: The script died unexpectedly.
bin/ai/regression/tst_stationlist/test.sav
Show inline comments
 
new file 100644
 
binary diff not shown
0 comments (0 inline, 0 general)