First NIT release and new clean mercurial repository
[nit.git] / tests / base_if_expr.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 redef meth output do 'A'.output
22 end
23
24 meth max(a: Int, b: Int): Int do return if a > b then a else b
25
26 var x = if true then 1 else 0
27 x.output
28
29 max(1,2).output
30 max(2,2).output
31 max(2,1).output
32
33 var o: Object = 1
34 var y = if true then new A else o
35 y.output
36 var y2 = if true then o else new A
37 var y3 = if true then null else new A
38 var y4 = if true then new A else null
39 #alt1# var y5 = if true then new A else 1
40
41 var z = 0
42 while z <=4 do
43 var i = if z < 2 then
44 if z == 0 then 'a'
45 else 'b'
46 else
47 if z == 2 then 'c'
48 else 'd'
49 i.output
50 z = z + 1
51 end
52 '\n'.output
53