update NOTICE and LICENSE
[nit.git] / tests / base_var_null.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 kernel
18
19 class A
20 var _foo: Int = 1
21 fun +(i: Int): A do return new A
22 redef fun output do 1.output
23 end
24
25 fun unknown: nullable A do return new A
26
27 var a = null
28 #alt1#a.output
29 #alt2#a._foo.output
30 #alt3#a._foo = 5
31 #alt4#a += 5
32
33 var b: nullable A
34 b = null
35 #alt5#b.output
36 #alt6#b._foo.output
37 #alt7#b._foo = 5
38 #alt8#b += 5
39
40 var c = unknown
41 if c == null then
42 #alt9# c.output
43 #alt10# c._foo.output
44 #alt11# c._foo = 5
45 #alt12# c += 5
46 else
47 c.output
48 c._foo.output
49 c._foo = 5
50 c += 5
51 end