syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_isa_cast.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2008 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 do 0.output
25 init do end
26 end
27 class C
28 special B
29 fun bar do 1.output
30 init do end
31 end
32
33
34 #alt5# var b: A = new B
35 var a: A = new C
36 #alt5# a = b
37 #alt6# a = new A
38 if a isa B then
39 a.foo
40 if a isa C then
41 a.bar
42 end
43 #alt1# a.bar
44 a.foo
45 else
46 #alt2# a.foo
47 end
48 #alt3#a.foo
49
50 if a isa B and a == a then
51 a.foo
52 end
53
54 if a isa B or a == a then
55 #alt4# a.foo
56 end
57
58 assert a isa B
59 a.foo