Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_operators.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 core::kernel
16
17 class A
18 fun +: A
19 do
20 0.output
21 return self
22 end
23 fun +(a: A): A
24 do
25 2.output
26 return self
27 end
28 fun -: A
29 do
30 1.output
31 return self
32 end
33 fun -(a: A): A
34 do
35 6.output
36 return self
37 end
38 fun *(a: A): A
39 do
40 3.output
41 return self
42 end
43 fun /(a: A): A
44 do
45 4.output
46 return self
47 end
48 fun %(a: A): A
49 do
50 5.output
51 return self
52 end
53 redef fun ==(a: nullable Object): Bool
54 do
55 7.output
56 return true
57 end
58 fun <(a: A): Bool
59 do
60 9.output
61 return true
62 end
63 fun >(a: A): Bool
64 do
65 10.output
66 return true
67 end
68 fun <=(a: A): Bool
69 do
70 11.output
71 return true
72 end
73 fun >=(a: A): Bool
74 do
75 12.output
76 return true
77 end
78 fun <=>(a: A): Int
79 do
80 13.output
81 return 0
82 end
83 fun <<(a: A): A
84 do
85 14.output
86 return a
87 end
88 fun >>(a: A): A
89 do
90 15.output
91 return a
92 end
93 fun **(a: A): A
94 do
95 16.output
96 return a
97 end
98 fun |(a: A): A
99 do
100 16.output
101 return a
102 end
103 fun ^(a: A): A
104 do
105 17.output
106 return a
107 end
108 fun &(a: A): A
109 do
110 18.output
111 return a
112 end
113 fun ~: A
114 do
115 19.output
116 return self
117 end
118
119 init do end
120 end
121
122 var a = new A
123 var a2 = new A
124 var b : Bool
125 var i: Int
126
127 a = +a + -a - a * a / a % a >> a << a ** a | ~a ^ a & a
128 b = a == a2 and a < a and a > a and a <= a and a >= a
129 i = a <=> a
130
131 '\n'.output
132
133 a += a
134 a -= a
135 a *= a
136 a /= a
137 a %= a
138 a **= a
139 a <<= a
140 a >>= a
141 a |= a
142 a ^= a
143 a &= a