Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_meta.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 meta
16
17 class XObject
18 redef type CLASS: XClass[SELF]
19 redef fun class_factory(name) do return new XClass[SELF](name)
20 end
21
22 class XClass[E: XObject]
23 super Class[E]
24 end
25
26 class YObject
27 redef type CLASS: YClass[SELF]
28 redef fun class_factory(name) do return new YClass[SELF](name)
29 end
30
31 class YClass[E: YObject]
32 super Class[E]
33 super YObject # Yeah, a meta-loop!
34 end
35
36 var s = "hello"
37 print s.class_name
38 print s.get_class
39 print s.get_class.get_class
40 print s.get_class.get_class.get_class
41
42 print ""
43
44 var x = new XObject
45 print x.class_name
46 print x.get_class
47 print x.get_class.get_class
48 print x.get_class.get_class.get_class
49
50 print ""
51
52 var y = new YObject
53 print y.class_name
54 print y.get_class
55 print y.get_class.get_class
56 print y.get_class.get_class.get_class