Skip to content

Commit

Permalink
tests: Add test for class self-mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Sep 10, 2024
1 parent 6e108e0 commit 64523fa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/class_self_mutation.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Self-mutation.

class Incrementor(initial: int) {
let x = initial

fn inc {
x = x + 1
}

fn dec {
x = x - 1
}

fn cur {
return x
}
}

let inc = Incrementor(0)

inc.inc()
inc.inc()
inc.dec()
inc.inc()
inc.inc()

assert inc.cur() == 3

0 comments on commit 64523fa

Please sign in to comment.