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