Skip to content

Commit

Permalink
Initialise dataclasses before using them
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Jul 1, 2022
1 parent 6383c55 commit cadfa88
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions integration_tests/structs_05.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ class A:
x: i32

def g():
# TODO: Replace y: A[2] with y: A[2] = [None, None]
# TODO: And enable cpython in integration_tests.
y: A[2]
eps: f64 = 1e-12
y[0].x = 1
y[0].y = 1.1
y[1].x = 2
y[1].y = 2.2
y[0] = A(1.1, 1)
y[1] = A(2.2, 2)
print(y[0].x, y[0].y)
assert y[0].x == 1
assert abs(y[0].y - 1.1) < eps
assert y[0].y == 1.1
print(y[1].x, y[1].y)
assert y[1].x == 2
assert abs(y[1].y - 2.2) < eps
assert y[1].y == 2.2
eps: f64 = 1e-12
y[0].x = 2
y[0].y = 1.2
y[1].x = 3
y[1].y = 2.3
print(y[0].x, y[0].y)
assert y[0].x == 2
assert abs(y[0].y - 1.2) < eps
print(y[1].x, y[1].y)
assert y[1].x == 3
assert abs(y[1].y - 2.3) < eps

g()

0 comments on commit cadfa88

Please sign in to comment.