summaryrefslogtreecommitdiff
path: root/bin/ai/regression/regression.nut
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/regression.nut
parentb3f2f3e278b1eaa2ecc6aa006d1789ffe2792534 (diff)
downloadopenttd-ac1a08ef4ad2414491b050b374714d7313373c1f.tar.xz
(svn r19293) -Fix [FS#3566]: Some methods of AIAbstractList left invalid iterators.
Diffstat (limited to 'bin/ai/regression/regression.nut')
-rw-r--r--bin/ai/regression/regression.nut30
1 files changed, 30 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()