summaryrefslogtreecommitdiff
path: root/test/files
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
parent874773fde6c2f9309125348583d64faf7ab14e1d (diff)
downloadscala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.tar.gz
scala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.tar.bz2
scala-fcbd0e6400cb6f4625b946652ea9b40c09106c90.zip
Preliminary Map test
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/map_test.check3
-rw-r--r--test/files/run/map_test.scala47
2 files changed, 50 insertions, 0 deletions
diff --git a/test/files/run/map_test.check b/test/files/run/map_test.check
new file mode 100644
index 0000000000..a8585769e8
--- /dev/null
+++ b/test/files/run/map_test.check
@@ -0,0 +1,3 @@
+{42 -> The answer, 17 -> A small random number, 666 -> A bigger random number, 4711 -> A big random number}
+0->0 1->1 2->2 3->3 4->4 5->5 6->6 7->7 8->8 9->9 10->10 11->11 12->12 13->13 14->14 15->15 16->16 17->17 18->18 19->19 20->20 21->21 22->22 23->23 24->24 25->25 26->26 27->27 28->28 29->29 30->30 31->31 32->32 33->33 34->34 35->35 36->36 37->37 38->38 39->39 40->40 41->41 42->42 666->A bigger random number 4711->A big random number
+OK
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("");
+ }
+}
+
+