-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transforms.artiq_ir_generator: add support for user-defined context m…
…anagers.
whitequark
committed
Jan 5, 2016
1 parent
d633c8e
commit 6a6d7da
Showing
2 changed files
with
173 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# RUN: %python -m artiq.compiler.testbench.jit %s | ||
# RUN: %python %s | ||
|
||
class contextmgr: | ||
def __enter__(self): | ||
print(2) | ||
|
||
def __exit__(self, n1, n2, n3): | ||
print(4) | ||
|
||
# CHECK-L: a 1 | ||
# CHECK-L: 2 | ||
# CHECK-L: a 3 | ||
# CHECK-L: 4 | ||
# CHECK-L: a 5 | ||
print("a", 1) | ||
with contextmgr(): | ||
print("a", 3) | ||
print("a", 5) | ||
|
||
# CHECK-L: b 1 | ||
# CHECK-L: 2 | ||
# CHECK-L: 4 | ||
# CHECK-L: b 6 | ||
try: | ||
print("b", 1) | ||
with contextmgr(): | ||
[0][1] | ||
print("b", 3) | ||
print("b", 5) | ||
except: | ||
pass | ||
print("b", 6) |