update NOTICE and LICENSE
[nit.git] / tests / base_assert2.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 fun foo do 1.output
21 end
22
23 class B
24 super A
25 fun bar do 2.output
26 end
27
28 fun test1(a: A)
29 do
30 assert a isa B else
31 false.output
32 a.foo
33 #alt1#a.bar
34 end
35 true.output
36 a.foo
37 a.bar
38 '\n'.output
39 end
40
41 fun test2(a: A)
42 do
43 assert not a isa B else
44 false.output
45 a.foo
46 a.bar
47 end
48 true.output
49 a.foo
50 #alt2#a.bar
51 '\n'.output
52 end
53
54 #alt3#test1(new A)
55 test2(new A)
56 test1(new B)
57 #alt4#test2(new B)
58 1.output