Files
clang-p2996/mlir/test/python/ir/debug.py
Stella Laurenzo 9f3f6d7bd8 Move MLIR python sources to mlir/python.
* NFC but has some fixes for CMake glitches discovered along the way (things not cleaning properly, co-mingled depends).
* Includes previously unsubmitted fix in D98681 and a TODO to fix it more appropriately in a smaller followup.

Differential Revision: https://reviews.llvm.org/D101493
2021-05-03 18:36:48 +00:00

40 lines
820 B
Python

# RUN: %PYTHON %s | FileCheck %s
from mlir.ir import *
def run(f):
print("\nTEST:", f.__name__)
f()
# CHECK-LABEL: TEST: testNameIsPrivate
def testNameIsPrivate():
# `import *` ignores private names starting with an understore, so the debug
# flag shouldn't be visible unless explicitly imported.
try:
_GlobalDebug.flag = True
except NameError:
pass
else:
assert False, "_GlobalDebug must not be available by default"
run(testNameIsPrivate)
# CHECK-LABEL: TEST: testDebugDlag
def testDebugDlag():
# Private names must be imported expilcitly.
from mlir.ir import _GlobalDebug
# CHECK: False
print(_GlobalDebug.flag)
_GlobalDebug.flag = True
# CHECK: True
print(_GlobalDebug.flag)
_GlobalDebug.flag = False
# CHECK: False
print(_GlobalDebug.flag)
run(testDebugDlag)