erg/tests/should_ok/context_manager.er
2024-03-13 12:40:43 +09:00

21 lines
372 B
Python

unsound = import "unsound"
x = !0
C = Class()
C|<: ContextManager|.
__enter__ self =
unsound.perform do!:
print! "C: enter"
x.inc!()
self
__exit__ self, _, _, _ =
unsound.perform do!:
print! "C: exit"
x.dec!()
False
with! C.new(), c =>
assert x == 1
print! c
assert x == 0