Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_attr_abstract.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 a: Object is abstract
19 var b: Object = 10 is abstract
20 #alt1#var b is abstract, noautoinit
21 #alt1#var c = 1 is abstract, lazy
22 #alt1#var d = 1 is abstract, autoinit
23 #alt1#var e = 1 is abstract, readonly
24 end
25
26 class Bar
27 super Foo
28 redef var a
29 redef var b is noinit
30 end
31
32 class Baz
33 super Foo
34 redef fun a do return 100 #alt2#
35 redef fun a=(x) do (101).output #alt3#
36 redef fun b do return 200 #alt4#
37 redef fun b=(x) do (201).output #alt5#
38 end
39
40 var f: Foo = new Bar(1)
41 f.a.output
42 f.a = 2
43 f.a.output
44
45 '\n'.output
46
47 f.b.output
48 f.b = 20
49 f.b.output
50
51 '\n'.output
52
53 f = new Baz
54 f.a.output
55 f.a = 3
56 f.a.output
57
58 '\n'.output
59
60 f.b.output
61 f.b = 30
62 f.b.output