update NOTICE and LICENSE
[nit.git] / tests / error_expr_not_ok.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2009 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 class A
19 var _x: Object = fail
20 var _i: Int = 1
21 fun y do fail
22 fun z: Object do return fail
23 fun t do
24 _i = fail
25 _i += fail
26 end
27
28 end
29
30 fun trash(x: A) do end
31
32 #alt1#fun fail: Fail do return new Fail
33 #alt2#var fail: Fail = new Fail
34 #alt3#var fail = fail(5)
35 #alt4#var fail: Object = 5
36 #alt5#var fail: Object = 5
37 #alt5#fail = fail2(5)
38 #alt6#var fail = null
39 var ok = 5
40 ok.fail
41 var nok: Int = fail
42 trash(nok)
43 nok.fail
44 var nok2 = fail
45 trash(nok2) # no rtype
46 nok2.fail
47
48 fail
49 trash(fail) # no rtype
50 fail.trash
51 fail = ok
52 ok = fail
53 fail += 1
54 ok += fail
55 fail += fail
56
57 do
58 fail
59 end
60 if fail then trash(0)
61 if true then fail else fail
62 trash(if fail then 1 else 2)
63 trash(if true then 1 else fail) # no rtype
64 trash(if true then fail else fail) # no rtype
65
66 while fail do trash(0)
67 while true do fail
68
69 for i in fail do trash(0) # no rtype (hum...)
70 for j in [0..1] do fail
71 assert fail
72 trash(once fail) # no rtype
73 trash(fail or true)
74 trash(true or fail)
75 trash(fail or fail)
76 trash(fail and true)
77 trash(fail and fail)
78 trash(fail and fail)
79 trash(not fail)
80 trash(fail == 1) # no rtype
81 trash(1 == fail)
82 trash(fail == fail) # no rtype
83 trash(fail != 1) # no rtype
84 trash(1 != fail)
85 trash(fail != fail) # no rtype
86 trash(fail is 1)
87 trash(1 is fail)
88 trash(fail is fail)
89 trash(fail < 1) # no rtype
90 trash(1 < fail)
91 trash(fail < fail) # no rtype
92 trash(fail > 1) # no rtype
93 trash(1 > fail)
94 trash(fail > fail) # no rtype
95 trash(fail <= 1) # no rtype
96 trash(1 <= fail)
97 trash(fail <= fail) # no rtype
98 trash(fail >= 1) # no rtype
99 trash(1 >= fail)
100 trash(fail >= fail) # no rtype
101 trash(fail <=> 1) # no rtype
102 trash(1 <=> fail)
103 trash(fail <=> fail) # no rtype
104 trash(fail + 1) # no rtype
105 trash(1 + fail)
106 trash(fail + fail) # no rtype
107 trash(fail - 1) # no rtype
108 trash(1 - fail)
109 trash(fail - fail) # no rtype
110 trash(fail * 1) # no rtype
111 trash(1 * fail)
112 trash(fail * fail) # no rtype
113 trash(fail / 1) # no rtype
114 trash(1 / fail)
115 trash(fail / fail) # no rtype
116 trash(fail % 1) # no rtype
117 trash(1 % fail)
118 trash(fail % fail) # no rtype
119 trash(-fail) # no rtype
120
121 var str = "XXX"
122 trash(str._fail) # no rtype
123 str._fail = 1
124 str._fail += 1
125
126 trash(fail._x) # no rtype
127 fail._x = 4
128 fail._x += 5
129
130 var arr = [1, 2]
131 trash(arr[fail])
132 arr[1] = fail
133 arr[1] += fail
134 trash(fail[1]) # no rtype
135 fail[1] = 2
136 fail[1] += 2
137 fail[fail] = fail
138
139 trash([1..fail]) # no rtype
140 trash([fail..1]) # no rtype
141 trash([fail..fail]) # no rtype
142 trash([1..fail[) # no rtype
143 trash([fail..1[) # no rtype
144 trash([fail..fail[) # no rtype
145 trash([1, fail]) # no rtype
146 trash([fail, 1]) # no rtype
147 trash([fail, fail]) # no rtype
148
149 trash("hello{fail}world")
150 trash(fail.as(Int)) # no rtype
151 trash(fail.as(not null))
152 trash(fail isa Int) # no rtype
153