summaryrefslogtreecommitdiff
path: root/test/files/run/map_test.scala
diff options
context:
space:
mode:
authorstenman <stenman@epfl.ch>2003-09-11 17:42:19 +0000
committerstenman <stenman@epfl.ch>2003-09-11 17:42:19 +0000
commitfcbd0e6400cb6f4625b946652ea9b40c09106c90 (patch)
tree70cd6eae3456ed666237fbd74fefe7474e5196c1 /test/files/run/map_test.scala
parent874773fde6c2f9309125348583d64faf7ab14e1d (diff)
downloadscala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.tar.gz
scala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.tar.bz2
scala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.zip
Preliminary Map test
Diffstat (limited to 'test/files/run/map_test.scala')
-rw-r--r--test/files/run/map_test.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/files/run/map_test.scala b/test/files/run/map_test.scala
new file mode 100644
index 0000000000..1354577531
--- /dev/null
+++ b/test/files/run/map_test.scala
@@ -0,0 +1,47 @@
+import scala.collection.immutable.Map;
+import scala.collection.immutable.TreeMap;
+import scala.collection.immutable.ListMap;
+import scala.collection.immutable.Order;
+
+object Test with Executable {
+ // test1();
+ test2();
+ Console.println("OK");
+
+ val intOrder =
+ new Order((x:int,y:int) => x < y, (x:int,y:int) => x == y);
+
+ def test1() = {
+ val myMap:TreeMap[int,String] = new TreeMap(intOrder);
+ test_map(myMap);
+ }
+
+ def test2() = {
+ val myMap:ListMap[int,String] = new ListMap;
+ test_map(myMap);
+ }
+
+ def test_map[This <: Map[int,String,This]](myMap:Map[int,String,This]) = {
+ val map1 = myMap.update(42,"The answer");
+ val map2 = map1.update(17,"A small random number");
+ val map3 = map2.update(666,"A bigger random number");
+ val map4 = map3.update(4711,"A big random number");
+ // val map1 = myMap + 42 -> "The answer";
+ Console.println(map4);
+ var i = 0;
+ var map = map4;
+ while(i < 43) {
+ map = map.update(i,i.toString());
+ i = i + 1;
+ }
+ i = 0;
+ while(i < 4712) {
+ if(map.isDefinedAt(i))
+ Console.print(i + "->" + map(i) + " ");
+ i = i + 1;
+ }
+ Console.println("");
+ }
+}
+
+