Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_attr_lazy.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import kernel
16
17 class Foo
18 var a1: Object = fa1 is lazy
19 var a2: Object = fa2 is lazy
20 fun fa1: Object do
21 1.output
22 return 10
23 end
24 fun fa2: Object do
25 2.output
26 return 20
27 end
28 #alt1#var a3: Object is lazy
29 #alt2#fun a4: Object is lazy
30 end
31
32 var f = new Foo
33 f.a1.output
34 f.a1.output
35 f.a2.output
36 f.a2.output
37 '\n'.output
38
39 var g = new Foo
40 g.a2.output
41 g.a1.output
42 g.a2.output
43 g.a1.output
44 '\n'.output
45
46 var h = new Foo
47 h.a1 = 100
48 h.a1.output
49 h.a1.output