This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# probe: with over a struct with __enter__ and __exit__, normal and failing
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: begin load
|
||||
# expect-stdout: loading
|
||||
# expect-stdout: end load
|
||||
# expect-stdout: begin parse
|
||||
# expect-stdout: inside parse
|
||||
# expect-stdout: end parse after error: bad token
|
||||
# expect-stdout: done
|
||||
@fieldwise_init
|
||||
struct Section(Copyable, Movable):
|
||||
var name: String
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
print("begin", self.name)
|
||||
return self.copy()
|
||||
|
||||
def __exit__(self):
|
||||
print("end", self.name)
|
||||
|
||||
def __exit__(self, err: Error) -> Bool:
|
||||
print("end", self.name, "after error:", err)
|
||||
return True
|
||||
|
||||
|
||||
def main() raises:
|
||||
with Section("load"):
|
||||
print("loading")
|
||||
with Section("parse") as s:
|
||||
print("inside", s.name)
|
||||
raise Error("bad token")
|
||||
print("done")
|
||||
Reference in new issue
Block a user