Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_attr5.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 A
18 fun foo: Int do return 1
19 fun bar=(i: Int)
20 do
21 '#'.output
22 i.output
23 end
24 fun baz: Int do return 3
25 fun baz=(i: Int)
26 do
27 '#'.output
28 i.output
29 end
30 end
31
32 class B
33 super A
34 #alt1#var foo: Int = 10
35 #alt2#redef var foo: Int = 10
36 #alt3#var foo: Int = 10 is writable
37 #alt4#redef var foo: Int = 10 is writable
38 #alt5#var foo: Int = 10 is redef writable
39 #alt6#redef var foo: Int = 10 is redef writable
40 #alt7#redef var foo
41 #alt11#var bar: Int = 20
42 #alt12#redef var bar: Int = 20
43 #alt13#var bar: Int = 20 is writable
44 #alt14#redef var bar: Int = 20 is writable
45 #alt15#var bar: Int = 20 is redef writable
46 #alt16#redef var bar: Int = 20 is redef writable
47 #alt17#redef var bar
48 #alt21#var baz: Int = 30
49 #alt22#redef var baz: Int = 30
50 #alt23#var baz: Int = 30 is writable
51 #alt24#redef var baz: Int = 30 is writable
52 #alt25#var baz: Int = 30 is redef writable
53 #alt26#redef var baz: Int = 30 is redef writable
54 #alt27#redef var baz
55 end
56
57 var b = new B #alt7,17,27# var b = new B(100)
58 b.foo.output
59 #alt2#b.foo = 100
60 #alt4#b.foo = 100
61 b.foo.output
62 '\n'.output
63 #alt15#b.bar.output
64 b.bar = 200
65 #alt15#b.bar.output
66 '\n'.output
67 b.baz.output
68 b.baz = 300
69 b.baz.output