Wiki

root/cobra/trunk/Tests/100-basics/101-if-else.cobra

Revision 1177, 0.7 KB (checked in by chuck, 4 years ago)

Importing test cases.

  • Property svn:eol-style set to native
Line 
1namespace Test
2
3    class Test
4
5        def main
6            is shared
7
8            x as int
9
10            x = 0
11            if true
12                x = 1
13            assert x == 1
14
15            x = 0
16            if 1
17                x = 1
18            assert x == 1
19
20            x = 0
21            if 2+2
22                x = 1
23            assert x == 1
24
25            x = 0
26            if -1.0
27                x = 1
28            assert x == 1
29
30            x = 0
31            if -1.0f
32                x = 1
33            assert x == 1
34
35            x = 0
36            if nil  # .warning. always
37                x = 1
38            assert x == 0
39
40            x = 0
41            if 0
42                x = 1
43            assert x == 0
44
45
46            # use variables
47
48            i as int = 1
49            x = 0
50            if i
51                x = 1
52            assert x == 1
53
54            i = 0
55            x = 0
56            if i
57                x = 1
58            assert x == 0
59
60            o as Object = 1
61            x = 0
62            if o  # .warning. always
63                x = 1
64            assert x == 1
65
66            o = 0
67            x = 0
68            if o  # .warning. always
69                x = 1
70            assert x == 1
Note: See TracBrowser for help on using the browser.