nitc: fix calling extern constructors from extern code in separate compiler
[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 end
30
31 var f = new Foo
32 f.a1.output
33 f.a1.output
34 f.a2.output
35 f.a2.output
36 '\n'.output
37
38 var g = new Foo
39 g.a2.output
40 g.a1.output
41 g.a2.output
42 g.a1.output
43 '\n'.output
44
45 var h = new Foo
46 h.a1 = 100
47 h.a1.output
48 h.a1.output