summaryrefslogtreecommitdiff
path: root/bin/ai/regression/tst_stationlist
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-09-21 16:44:37 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-09-21 16:44:37 +0000
commit57d758f73ea33b4deb369074f8e1d5c911fa1e57 (patch)
tree1227d3e200e7547fe64b5c15dc6302d26fe727cc /bin/ai/regression/tst_stationlist
parentd92c95b29c6ae7b03c76852eec68fc0d425884cb (diff)
downloadopenttd-57d758f73ea33b4deb369074f8e1d5c911fa1e57.tar.xz
(svn r26896) -Codechange: Move AIStationList* tests to separate test case
Diffstat (limited to 'bin/ai/regression/tst_stationlist')
-rw-r--r--bin/ai/regression/tst_stationlist/main.nut80
-rw-r--r--bin/ai/regression/tst_stationlist/result.txt37
-rw-r--r--bin/ai/regression/tst_stationlist/test.savbin0 -> 93168 bytes
3 files changed, 117 insertions, 0 deletions
diff --git a/bin/ai/regression/tst_stationlist/main.nut b/bin/ai/regression/tst_stationlist/main.nut
new file mode 100644
index 000000000..d8ea72a67
--- /dev/null
+++ b/bin/ai/regression/tst_stationlist/main.nut
@@ -0,0 +1,80 @@
+/* $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();
+}
diff --git a/bin/ai/regression/tst_stationlist/result.txt b/bin/ai/regression/tst_stationlist/result.txt
new file mode 100644
index 000000000..eb3bec403
--- /dev/null
+++ b/bin/ai/regression/tst_stationlist/result.txt
@@ -0,0 +1,37 @@
+
+--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.
diff --git a/bin/ai/regression/tst_stationlist/test.sav b/bin/ai/regression/tst_stationlist/test.sav
new file mode 100644
index 000000000..31ea8b0ef
--- /dev/null
+++ b/bin/ai/regression/tst_stationlist/test.sav
Binary files differ