Initial commit
Test (in pplus-core) / in-core (push) Failing after 28m44s

This commit is contained in:
alexm committed 2026-11-12 22:23:48 -05:00
commit 568474d52f
1591 files changed
+528213

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
# probe: a struct method that raises, caught by the caller
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
# expect-stdout: withdrew 30 left 120
# expect-stdout: refused 200 : insufficient funds
# expect-stdout: withdrew 120 left 0
# expect-stdout: ada 0
struct Account(Movable):
var owner: String
var balance: Int
def __init__(out self, owner: String, balance: Int):
self.owner = owner
self.balance = balance
def withdraw(mut self, amount: Int) raises:
if amount > self.balance:
raise Error("insufficient funds")
self.balance -= amount
def deposit(mut self, amount: Int):
self.balance += amount
def main():
var acct = Account("ada", 100)
acct.deposit(50)
for amount in [30, 200, 120]:
try:
acct.withdraw(amount)
print("withdrew", amount, "left", acct.balance)
except e:
print("refused", amount, ":", e)
print(acct.owner, acct.balance)