syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_isa_cast3.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 import kernel
18
19 class A
20 init do end
21 end
22 class B
23 special A
24 fun foo(i: Int) do i.output
25 fun bar: Bool do return true
26 init do end
27 end
28
29 var a: A = new B
30
31 if a isa B then
32 a.foo(1)
33 else
34 #alt1#a.foo(-1)
35 end
36 #alt2#a.foo(-2)
37
38 if not a isa B then
39 #alt3#a.foo(-3)
40 else
41 a.foo(2)
42 end
43 #alt4#a.foo(-4)
44
45 if a isa B and false then
46 a.foo(3)
47 else
48 #alt5#a.foo(-5)
49 end
50 #alt6#a.foo(-6)
51
52 if not a isa B or true then
53 #alt7#a.foo(-7)
54 else
55 a.foo(3)
56 end
57 #alt8#a.foo(-8)
58
59 if a isa B and a.bar then
60 a.foo(4)
61 end
62
63 if not a isa B or not a.bar then
64 #alt9# a.foo(-9)
65 else
66 a.foo(5)
67 end
68
69 if not (not a isa B or not a.bar) then
70 a.foo(6)
71 end
72