First NIT release and new clean mercurial repository
[nit.git] / tests / test_multiconstraint.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 import kernel
18
19 class A
20 meth foo
21 do
22 11.output
23 end
24
25 init do end
26 end
27
28 class B
29 special A
30 redef meth foo
31 do
32 21.output
33 end
34 meth bar
35 do
36 22.output
37 end
38
39 init do end
40 end
41
42 class C
43 special B
44 redef meth foo
45 do
46 31.output
47 end
48 redef meth bar
49 do
50 32.output
51 end
52
53 init do end
54 end
55
56 class G[E]
57 meth out0
58 do
59 0.output
60 end
61
62 init do end
63 end
64 class G[E: A]
65 meth out1(e: E)
66 do
67 e.foo
68 end
69 end
70 class G[E: B]
71 meth out2(e: E)
72 do
73 e.foo
74 e.bar
75 end
76 end
77
78 var a = new A
79 var b = new B
80 var c = new C
81 var ga = new G[A]
82 var gb = new G[B]
83 var gc = new G[C]
84 ga.out0
85 ga.out1(a)
86 #ga.out2(a)
87 gb.out1(b)
88 gb.out2(b)
89 gc.out1(c)
90 gc.out2(c)