summaryrefslogtreecommitdiff
path: root/bin/ai/regression
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-02-28 19:53:11 +0000
committerfrosch <frosch@openttd.org>2010-02-28 19:53:11 +0000
commitac1a08ef4ad2414491b050b374714d7313373c1f (patch)
treeb5129d8724bb4706b793c15d0cccf6040529cb6a /bin/ai/regression
parentb3f2f3e278b1eaa2ecc6aa006d1789ffe2792534 (diff)
downloadopenttd-ac1a08ef4ad2414491b050b374714d7313373c1f.tar.xz
(svn r19293) -Fix [FS#3566]: Some methods of AIAbstractList left invalid iterators.
Diffstat (limited to 'bin/ai/regression')
-rw-r--r--bin/ai/regression/regression.nut30
-rw-r--r--bin/ai/regression/regression.txt8
2 files changed, 38 insertions, 0 deletions
diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut
index 69019f04f..c27929d6b 100644
--- a/bin/ai/regression/regression.nut
+++ b/bin/ai/regression/regression.nut
@@ -785,6 +785,36 @@ function Regression::List()
list.Clear();
print(" IsEmpty(): " + list.IsEmpty());
+
+ for (local i = 0; i < 10; i++) {
+ list.AddItem(i, 5 + i / 2);
+ }
+
+ local it = list.Begin();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+ list.Sort(list.SORT_BY_VALUE, list.SORT_ASCENDING);
+ it = list.Next();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+
+ it = list.Begin();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+
+ list.SetValue(it + 1, -5);
+ it = list.Next();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+
+ list.RemoveValue(list.GetValue(it) + 1);
+ it = list.Next();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+
+ list.RemoveAboveValue(list.GetValue(it));
+ it = list.Next();
+ print(" " + it + " => " + list.GetValue(it) + " (" + list.HasNext() + ")");
+
+ while (list.HasNext()) {
+ it = list.Next();
+ print(" " + it + " => " + list.GetValue(it));
+ }
}
function Regression::Map()
diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt
index aa45f1151..2b499f62c 100644
--- a/bin/ai/regression/regression.txt
+++ b/bin/ai/regression/regression.txt
@@ -569,6 +569,14 @@
[]:
4000 => 50
IsEmpty(): true
+ 0 => 5 (true)
+ERROR: Next() is invalid as Begin() is never called
+ERROR: HasNext() is invalid as Begin() is never called
+ 0 => 5 (false)
+ 0 => 5 (true)
+ 2 => 6 (true)
+ 3 => 6 (true)
+ 9 => 0 (false)
--Company--
SetName(): true