nitc: fix calling extern constructors from extern code in separate compiler
[nit.git] / tests / base_at_cached.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 Base
18 var foo: Int = 10
19 fun -: Int do return foo + 20
20 fun bar: Int do return -self + 40
21 #alt1#fun fail is cached do end
22 #alt2#fun fail(i: Int): Int is cached do return i
23 end
24
25 class CMinus
26 super Base
27
28 redef fun - is cached do return foo + 1
29 end
30
31 class CBar
32 super Base
33
34 redef fun bar is cached do return -self + 2
35 end
36
37 #alt3#fun fail: Int is cached do return 0
38
39 fun test(b: Base)
40 do
41 b.foo.output
42 (-b).output
43 b.bar.output
44 b.foo = 110
45 b.foo.output
46 (-b).output
47 b.bar.output
48 '\n'.output
49 end
50
51 test(new Base)
52 test(new CMinus)
53 test(new CBar)