tests: add test_catch_runtime
[nit.git] / tests / test_catch_runtime.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 fun foo is abstract
18 fun bar is intern
19
20 class A
21 var a: A is noautoinit
22 fun foo do 0.output
23 end
24
25 var a = new A
26 var n: nullable A = null
27 var o: Object = 1
28
29 do
30 1.output
31 if true then abort
32 666.output
33 catch
34 1.output
35 end
36
37 do
38 2.output
39 n.foo
40 666.output
41 catch
42 2.output
43 end
44
45 do
46 3.output
47 foo
48 666.output
49 catch
50 3.output
51 end
52
53 do
54 4.output
55 assert false
56 666.output
57 catch
58 4.output
59 end
60
61 do
62 5.output
63 o.as(A).foo
64 666.output
65 catch
66 5.output
67 end
68
69 do
70 6.output
71 a.a.foo
72 666.output
73 catch
74 6.output
75 end
76
77 do
78 7.output
79 bar
80 666.output
81 catch
82 7.output
83 end