syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / test_meta.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 A
19 fun foo
20 do
21 printn("A")
22 end
23 fun blup(a: Int)
24 do
25 blup2(a, 1)
26 end
27 fun blup2(a: Int, b : Int)
28 do
29 printn(a+b)
30 end
31 fun blop(a: Int, b: Int...)
32 do
33 var i = b.iterator
34 while i.is_ok do
35 printn(a+i.item)
36 i.next
37 end
38 end
39 end
40
41 class B
42 special A
43 redef fun foo
44 do
45 printn("B")
46 end
47 end
48
49 class C
50 special A
51 fun foo2
52 do
53 printn("C")
54 end
55 end
56
57 class D
58 special B
59 special C
60 redef fun foo
61 do
62 printn("D")
63 end
64
65 init do end
66 end
67
68 fun test1
69 do
70 var b: B
71 b = new D
72 b.foo
73 b.blup2(1,2)
74 b.blup(3)
75 end
76
77 fun test2
78 do
79 var b = new D
80 var a = [1,2,3]
81 var u: Object
82 printn("=",5)
83 b.blop(5,2,3)
84 end
85
86 test1
87 test2