brintos

brintos / llvm-project-archived public Read only

0
0
Text · 868 B · 629a710 Raw
42 lines · python
1# RUN: %PYTHON %s | FileCheck %s2 3from mlir.ir import *4 5 6def run(f):7    print("\nTEST:", f.__name__)8    f()9 10 11# CHECK-LABEL: TEST: testNameIsPrivate12def testNameIsPrivate():13    # `import *` ignores private names starting with an understore, so the debug14    # flag shouldn't be visible unless explicitly imported.15    try:16        _GlobalDebug.flag = True17    except NameError:18        pass19    else:20        assert False, "_GlobalDebug must not be available by default"21 22 23run(testNameIsPrivate)24 25 26# CHECK-LABEL: TEST: testDebugDlag27def testDebugDlag():28    # Private names must be imported expilcitly.29    from mlir.ir import _GlobalDebug30 31    # CHECK: False32    print(_GlobalDebug.flag)33    _GlobalDebug.flag = True34    # CHECK: True35    print(_GlobalDebug.flag)36    _GlobalDebug.flag = False37    # CHECK: False38    print(_GlobalDebug.flag)39 40 41run(testDebugDlag)42