Implemented reading from struct fields

This commit is contained in:
2025-02-04 20:43:15 +01:00
parent 03a3bd8f02
commit bde68d4d64
10 changed files with 112 additions and 15 deletions

34
tests/programs/struct.q Normal file
View File

@ -0,0 +1,34 @@
struct Point {
x Int
y Int
}
main() {
p := new(Point)
assert p.x == 0
assert p.y == 0
assert p.x == p.y
p.x = 1
p.y = 2
assert p.x == 1
assert p.y == 2
assert p.x != p.y
p.x = p.y
assert p.x == 2
assert p.y == 2
assert p.x == p.y
p.x = p.y + 1
assert p.x == 3
assert p.y == 2
assert p.x != p.y
p.y = p.x
assert p.x == 3
assert p.y == 3
assert p.x == p.y
delete(p)
}