Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_attr_nullable.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 enum Bool end
22 enum Int
23 fun output is intern
24 fun +(o: Int): Int is intern
25 end
26
27 class Integer
28 var val: Int
29 fun output do _val.output
30 end
31
32 class Foo
33 var a1: Integer is noinit
34 var a2: Integer is noinit
35 fun run
36 do
37 _a1.output
38 _a2.output
39 end
40
41 fun run_other(o: Foo)
42 do
43 o._a1.output
44 o._a2.output
45 end
46
47 init
48 do
49 #alt1#run
50 _a1 = new Integer(1)
51 #alt2#run
52 _a2 = new Integer(_a1._val + 1)
53 end
54
55 init nop do end
56 end
57
58 class Bar
59 super Foo
60 var a3: Integer is noinit
61 redef fun run
62 do
63 _a1.output
64 _a2.output
65 _a3.output
66 end
67
68 init
69 do
70 if false then super # no auto super init call
71 #alt3#run
72 _a1 = new Integer(10)
73 #alt4#run_other(self)
74 _a2 = new Integer(20)
75 #alt5#run
76 _a3 = new Integer(30)
77 end
78 end
79
80 var f = new Foo
81 var b = new Bar
82 f.run
83 b.run