Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mlir/test/python/ir/module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# RUN: %PYTHON %s | FileCheck %s

import gc
from pathlib import Path
from tempfile import NamedTemporaryFile
from mlir.ir import *


Expand All @@ -27,6 +29,24 @@ def testParseSuccess():
print(str(module))


# Verify successful parse from file.
# CHECK-LABEL: TEST: testParseFromFileSuccess
# CHECK: module @successfulParse
@run
def testParseFromFileSuccess():
ctx = Context()
with NamedTemporaryFile(mode="w") as tmp_file:
tmp_file.write(r"""module @successfulParse {}""")
tmp_file.flush()
module = Module.parse(Path(tmp_file.name), ctx)
assert module.context is ctx
print("CLEAR CONTEXT")
ctx = None # Ensure that module captures the context.
gc.collect()
module.dump() # Just outputs to stderr. Verifies that it functions.
print(str(module))


# Verify parse error.
# CHECK-LABEL: TEST: testParseError
# CHECK: testParseError: <
Expand Down