1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 fun test1
(h
: Map[Int, Int])
23 printn
(h
[1], " - ", h
[2], "\n")
25 printn
(h
[1], " - ", h
[2], "\n")
28 print
(not h
.has_key
(3))
40 fun test2
(h
: Map[Int, Int])
55 if (h
[i
*31+13] != i
* 2) then
56 print
("{i}: {i*31+13} != {h[i]}")
74 if (i
* 2) % 3 != 0 then
76 print
("{i}: {j} should be removed")
78 else if (h
[j
] != i
* 2) then
79 print
("{i}: {j} != {h[i]}")
86 fun test3
(m
: Map[String, String])
92 print
(m
.has_only
("vert"))
93 print
(m
.count
("vert") == 0)
96 print
(m
.has_only
("vert"))
97 print
(m
.count
("vert") == 1)
99 print
(not m
.has_only
("vert"))
105 m
["yellow"] = "jaune"
106 m
["orange"] = "orange"
112 print
(m
.count
("vert") == 0)
113 print
(m
.count
("gris") == 2)
114 print
(m
["blue"] == "bleu")
115 print
(not m
.has
("vert"))
117 print
(not m
.has
("blue"))
118 print
(m
.has_key
("blue"))
119 print
(not m
.has_key
("green"))
120 print
(not m
.has_key
("vert"))
124 print
(m
.count
("rose") == 1)
127 print
(m
.count
("rose") == 0)
130 print
(m
.count
("gris") == 0)
133 print
(m
.count
("bleu") == 0)
139 test1
(new ArrayMap[Int, Int])
140 test2
(new ArrayMap[Int, Int])
141 test3
(new ArrayMap[String, String])