syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_attr_nullable_int.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 end
18
19 interface Object
20 end
21
22 universal Int
23 fun output is intern
24 fun +(o: Int): Int is intern
25 end
26
27 class Foo
28 var _a1: Int
29 readable var _a2: Int
30 fun run
31 do
32 _a1.output
33 a2.output
34 end
35
36 fun run_other(o: Foo)
37 do
38 o._a1.output
39 o._a2.output
40 end
41
42 init
43 do
44 #alt1#run
45 _a1 = 1
46 #alt2#run
47 _a2 = _a1 + 1
48 end
49
50 init nop do end
51 end
52
53 class Bar
54 special Foo
55 var _a3: Int
56 redef fun run
57 do
58 _a1.output
59 _a2.output
60 _a3.output
61 end
62
63 init
64 do
65 nop
66 #alt3#run
67 _a1 = 10
68 #alt4#run_other(self)
69 _a2 = 20
70 #alt5#run
71 _a3 = 30
72 end
73 end
74
75 var f = new Foo
76 var b = new Bar
77 f.run
78 b.run