-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathexpr_09.py
48 lines (41 loc) · 1004 Bytes
/
expr_09.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from lpython import i32, f64, f32
def main0():
i1: i32 = 10
i2: i32 = 4
i1 = 3
i2 = 5
print(-i1 ^ -i2)
assert -i1 ^ -i2 == 6
def test_multiple_assign_1():
a: i32; b: i32; c: i32
d: f64; e: f64; g: i32
g = 5
d = e = f64(g) + 1.0
a = b = c = 10
assert a == b
assert b == c
assert a == 10
x: f64; y: f64
x = y = 23.0
assert abs(x - 23.0) < 1e-6
assert abs(y - 23.0) < 1e-12
assert abs(e - 6.0) < 1e-6
assert abs(d - 6.0) < 1e-12
i: list[f64]; j: list[f64]; k: list[f64] = []
g = 0
for g in range(10):
k.append(f64(g)*2.0 + 5.0)
i = j = k
for g in range(10):
assert abs(i[g] - j[g]) < 1e-12
assert abs(i[g] - k[g]) < 1e-12
assert abs(f64(g)*2.0 + 5.0 - k[g]) < 1e-12
def test_issue_928():
a: i32; b: i32; c: tuple[i32, i32]
a, b = c = 2, 1
assert a == 2
assert b == 1
assert c[0] == a and c[1] == b
test_multiple_assign_1()
test_issue_928()
main0()