Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / error_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 # no return
16 class A
17 fun + do abort
18 fun +(a: A) do abort
19 fun - do abort
20 fun -(a: A) do abort
21 fun *(a: A) do abort
22 fun /(a: A) do abort
23 fun %(a: A) do abort
24 fun <(a: A) do abort
25 fun >(a: A) do abort
26 fun <=(a: A) do abort
27 fun >=(a: A) do abort
28 fun <=>(a: A) do abort
29 fun <<(a: A) do abort
30 fun >>(a: A) do abort
31 fun foo=(a: A) do abort # should be fine
32 fun [](a: A) do abort
33 fun []=(a, b: A) do abort # should be fine
34 end
35
36 # not enough parameters
37 class B
38 fun +: A do abort # should be fine
39 fun -: A do abort # should be fine
40 fun *: A do abort
41 fun /: A do abort
42 fun %: A do abort
43 fun <: A do abort
44 fun >: A do abort
45 fun <=: A do abort
46 fun >=: A do abort
47 fun <=>: A do abort
48 fun <<: A do abort
49 fun >>: A do abort
50 fun foo= do abort
51 fun []: A do abort
52 fun []=(a: A) do abort
53 end
54
55 # too much parameters
56 class C
57 fun +(a,b,c:A): A do abort
58 fun -(a,b,c:A): A do abort
59 fun *(a,b,c:A): A do abort
60 fun /(a,b,c:A): A do abort
61 fun %(a,b,c:A): A do abort
62 fun <(a,b,c:A): A do abort
63 fun >(a,b,c:A): A do abort
64 fun <=(a,b,c:A): A do abort
65 fun >=(a,b,c:A): A do abort
66 fun <=>(a,b,c:A): A do abort
67 fun <<(a,b,c:A): A do abort
68 fun >>(a,b,c:A): A do abort
69 fun foo=(a,b,c:A) do abort # should be fine
70 fun [](a,b,c:A): A do abort # should be fine
71 fun []=(a,b,c:A) do abort # should be fine
72 end
73
74 # bad vararg
75 class D
76 fun +(a:A...): A do abort
77 fun -(a:A...): A do abort
78 fun *(a:A...): A do abort
79 fun /(a:A...): A do abort
80 fun %(a:A...): A do abort
81 fun <(a:A...): A do abort
82 fun >(a:A...): A do abort
83 fun <=(a:A...): A do abort
84 fun >=(a:A...): A do abort
85 fun <=>(a:A...): A do abort
86 fun <<(a:A...): A do abort
87 fun >>(a:A...): A do abort
88 fun foo=(a,b,c:A, d:A...) do abort
89 fun [](a,b,c:A, d:A...): A do abort # should be fine
90 fun []=(a,b,c:A, d:A...) do abort
91 end