xymus.net: update xymus.net nitcorn config to include an opportunity client
[nit.git] / tests / base_new.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 interface A
18 new do return new B(1)
19 new n2 do return new B(2)
20 new n3: B do return new B(3)
21 new n4: Int do return 4
22 new n5: Int do return new B.ni(5)
23 #alt1#new n do return 5
24 #alt2#new n do 0.output
25 #alt3#new n do return self
26 #alt4#new n: Int do return object_id
27 end
28
29 class B
30 super A
31 var i: Int
32 redef fun output do
33 'B'.output
34 i.output
35 end
36 new n2 do return new B(22)
37 new n3: B do return new B(33)
38 new n4: Int do return 44
39 new n5: Int do return new B.ni(55)
40 new ni(i: Int): Int do return i*10
41 end
42
43 class C
44 super B
45 new(i: Int): B do return new B(i)
46 redef fun output do
47 'C'.output
48 i.output
49 end
50 end
51
52 redef class Int
53 new z do return 0
54 new a: A do return new A
55 end
56
57 (new A).output
58 #alt5#(new A).i.output
59 (new A.n2).output
60 #alt6#(new A.n2).i.output
61 (new A.n3).i.output
62 (new A.n4).output
63 (new A.n5).output
64 #alt1-4#(new A.n).output
65
66 '\n'.output
67
68 (new B(11)).output
69 (new B.n2).i.output
70 (new B.n3).i.output
71 (new B.n4).output
72 (new B.n5).output
73 (new B.ni(66)).output
74
75 '\n'.output
76
77 (new C(111)).output
78 #alt7#(new C.n2).output
79
80 '\n'.output
81
82 #alt8#(new Int).output
83 (new Int.z).output
84 (new Int.a).output