syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_var_assignment_flow.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2009 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 fun output is abstract
21 end
22
23 universal Int
24 redef fun output is intern
25 end
26
27 universal Bool
28 redef fun output is intern
29 end
30
31 fun maybe: Bool do return false
32
33 var a: Object
34 #alt1#a.output
35 a = 1
36 a.output
37
38 var b = a
39 b.output
40
41 var c: Object
42 if maybe then
43 c = 2 #!alt2# #!alt4#
44 else
45 c = 2 #!alt3# #!alt4#
46 end
47 c.output
48
49 var d: Object
50 if maybe then
51 d = 3
52 d.output
53 end
54 #alt5#d.output
55
56 var e: Object
57 do
58 e = 4
59 e.output
60 end
61 e.output
62
63 var f: Object
64 while maybe do
65 f = 5
66 f.output
67 end
68 #alt6#f.output