Wiki

root/cobra/trunk/Tests/100-basics/042-int.cobra

Revision 2636, 0.7 KB (checked in by Charles.Esterbrook, 7 weeks ago)

JVM back-end progress.
credit:hopscc

  • Property svn:eol-style set to native
Line 
1namespace Test
2
3    class Test
4
5        def main
6            is shared
7
8            assert 1
9            assert 2+2==4
10            assert 4-2==2
11
12            # unary minus
13            assert -1
14            assert -1==-1
15            assert -1==0-1
16            assert 2+-1==1
17
18            # unary plus
19            assert +1
20            assert 2+ +1==3
21
22            # multiply
23            assert 2*4==8
24            assert 2*-4==-8
25
26            # modified assignment
27            x as int = 0
28            assert x==0
29            x += 1
30            assert x==1
31            x += 1
32            x *= 2
33            assert x==4
34            x -= 1
35            assert x==3
36
37            # see also: 053-division.cobra
38
39            x = 1_000_000  # underscores are ignored by Cobra, but useful to people for separating thousands
40            assert x==1000000
41
42            assert 2*3 + 4
43            assert (2*3 + 4) == 10
44            assert 2*3 + 4*5 == 26
45            assert (2*3 + 4*5) == 26
46
Note: See TracBrowser for help on using the browser.