File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # test arithmetic operators
2+
3+ @micropython .viper
4+ def add (x :int , y :int ):
5+ print (x + y )
6+ print (y + x )
7+ add (1 , 2 )
8+ add (42 , 3 )
9+ add (- 1 , 2 )
10+ add (- 42 , - 3 )
11+
12+ @micropython .viper
13+ def sub (x :int , y :int ):
14+ print (x - y )
15+ print (y - x )
16+ sub (1 , 2 )
17+ sub (42 , 3 )
18+ sub (- 1 , 2 )
19+ sub (- 42 , - 3 )
20+
21+ @micropython .viper
22+ def shl (x :int , y :int ):
23+ print (x << y )
24+ shl (1 , 0 )
25+ shl (1 , 3 )
26+ shl (1 , 30 )
27+ shl (42 , 10 )
28+ shl (- 42 , 10 )
29+
30+ @micropython .viper
31+ def shr (x :int , y :int ):
32+ print (x >> y )
33+ shr (1 , 0 )
34+ shr (1 , 3 )
35+ shr (42 , 2 )
36+ shr (- 42 , 2 )
Original file line number Diff line number Diff line change 1+ 3
2+ 3
3+ 45
4+ 45
5+ 1
6+ 1
7+ -45
8+ -45
9+ -1
10+ 1
11+ 39
12+ -39
13+ -3
14+ 3
15+ -39
16+ 39
17+ 1
18+ 8
19+ 1073741824
20+ 43008
21+ -43008
22+ 1
23+ 0
24+ 10
25+ -11
Original file line number Diff line number Diff line change 1+ # test comparison operators
2+ @micropython .viper
3+ def f (x :int , y :int ):
4+ if x < y :
5+ print (x , "<" , y )
6+ if x > y :
7+ print (x , ">" , y )
8+ if x == y :
9+ print (x , "==" , y )
10+ if x <= y :
11+ print (x , "<=" , y )
12+ if x >= y :
13+ print (x , ">=" , y )
14+ if x != y :
15+ print (x , "!=" , y )
16+
17+ f (1 , 1 )
18+ f (2 , 1 )
19+ f (1 , 2 )
20+ f (2 , - 1 )
21+ f (- 2 , 1 )
Original file line number Diff line number Diff line change 1+ 1 == 1
2+ 1 <= 1
3+ 1 >= 1
4+ 2 > 1
5+ 2 >= 1
6+ 2 != 1
7+ 1 < 2
8+ 1 <= 2
9+ 1 != 2
10+ 2 > -1
11+ 2 >= -1
12+ 2 != -1
13+ -2 < 1
14+ -2 <= 1
15+ -2 != 1
You can’t perform that action at this time.
0 commit comments