First NIT release and new clean mercurial repository
[nit.git] / tests / test_obj.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
18 class O
19 meth foo
20 do
21 printn(10)
22 end
23
24 meth bar
25 do
26 printn(20)
27 end
28
29 init do end
30 end
31
32 class A
33 special O
34 redef meth foo
35 do
36 printn(11)
37 end
38
39 redef meth bar
40 do
41 printn(21)
42 end
43
44 init do end
45 end
46
47 class B
48 special A
49 redef meth foo
50 do
51 printn(12)
52 end
53
54 meth baz
55 do
56 printn(32)
57 end
58
59 init do end
60 end
61
62 var a = new A
63 var ab: A = new B
64 var b = new B
65 a.foo
66 a.bar
67 ab.foo
68 ab.bar
69 b.foo
70 b.bar
71 b.baz