1# RUN: %PYTHON %s | FileCheck %s 2 3from mlir.ir import * 4 5 6def run(f): 7 print("\nTEST:", f.__name__) 8 f() 9 10 11# CHECK-LABEL: TEST: testNameIsPrivate 12def testNameIsPrivate(): 13 # `import *` ignores private names starting with an understore, so the debug 14 # flag shouldn't be visible unless explicitly imported. 15 try: 16 _GlobalDebug.flag = True 17 except NameError: 18 pass 19 else: 20 assert False, "_GlobalDebug must not be available by default" 21 22 23run(testNameIsPrivate) 24 25 26# CHECK-LABEL: TEST: testDebugDlag 27def testDebugDlag(): 28 # Private names must be imported expilcitly. 29 from mlir.ir import _GlobalDebug 30 31 # CHECK: False 32 print(_GlobalDebug.flag) 33 _GlobalDebug.flag = True 34 # CHECK: True 35 print(_GlobalDebug.flag) 36 _GlobalDebug.flag = False 37 # CHECK: False 38 print(_GlobalDebug.flag) 39 40 41run(testDebugDlag) 42