Implemented reading from struct fields
This commit is contained in:
parent
03a3bd8f02
commit
bde68d4d64
10 changed files with 112 additions and 15 deletions
34
tests/programs/struct.q
Normal file
34
tests/programs/struct.q
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue